简体   繁体   中英

Read large csv file into R

I am working in RStudio with R version 2.15.1. I saved an Excel file in CSV file and imported that to R (with the read.csv() function). When I do dim(file) , I got:

[1] 4920 23 

But when I tried to retrieve the very first element with file[1:1] , I got the entire first column! Why is that?

you need comas for each dimension. So

file[i, j]

is the element on the i^{th} row and j^{th} column. If you want the whole first row, the proper way to do it is to type

file[1, ]

What you did is useful in selecting several rows. So if you type

file[c(1:4),]

will select the first 4 columns and so on. In your particular case what you want to type is:

file[1, 1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM