Data Frames क्या हैं
एक data frame एक spreadsheet जैसी table है, जहाँ हर column एक तरह की information hold करता है और हर row एक case है। यह real-world data रखने का R का main तरीका है।
In this page:
Syntax
df <- data.frame(column1 = c(value1, value2),
column2 = c(value3, value4))
df$column1
df[row, col]
Data Frames
एक data frame tabular data के लिए R की table-like structure है, जहाँ हर column का अलग type हो सकता है लेकिन सारे columns की same संख्या rows हैं -- एक spreadsheet या SQL table जैसा।
यह data.frame() से बनता है और R में data analysis के लिए primary structure इस्तेमाल होता है। Columns $ से access होते हैं और rows/columns [row, col] indexing से।
Note:
किसी data frame के column names, types, और इसकी values का एक preview जल्दी देखने के लिए str(df) इस्तेमाल करें।
उदाहरण: Data Frames
df <- data.frame(
name = c("Alice", "Bob", "Cara"),
age = c(30, 25, 40)
)
print(df)
cat("Ages:", df$age, "\n")
print(df[1, ])
Login to try C/C++/Java/PHP code in the editor
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- index करते वक्त comma भूल जाना, जैसे
df[1], जो एक column को data frame की तरह return करता है, जबकिdf[1, ]पहली row है। - अलग lengths के columns बनाना, जो
arguments imply differing number of rowsसे fail होता है। - यह उम्मीद करना कि एक string column एक factor होगा या इसका उल्टा, जब R 4.0 से
stringsAsFactorsdefault सेFALSEहै।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: