← Back to R Course | Chapter 7: Data Structures | Lesson 3 of 7

Data Frames क्या हैं

एक data frame एक spreadsheet जैसी table है, जहाँ हर column एक तरह की information hold करता है और हर row एक case है। यह real-world data रखने का R का main तरीका है।

In this page:

  1. Data Frames
Syntax
r
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

markup
df <- data.frame(
  name = c("Alice", "Bob", "Cara"),
  age = c(30, 25, 40)
)

print(df)
cat("Ages:", df$age, "\n")
print(df[1, ])
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. #}
आम गलतियां
  1. index करते वक्त comma भूल जाना, जैसे df[1], जो एक column को data frame की तरह return करता है, जबकि df[1, ] पहली row है।
  2. अलग lengths के columns बनाना, जो arguments imply differing number of rows से fail होता है।
  3. यह उम्मीद करना कि एक string column एक factor होगा या इसका उल्टा, जब R 4.0 से stringsAsFactors default से FALSE है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.