[R] Importing all observations and variables from csv file into dataframe
R. Michael Weylandt
michael.weylandt at gmail.com
Mon Oct 17 21:09:24 CEST 2011
You aren't reading the file in at all: notice that,
> summary("MooGoesTheCow",header=TRUE,as.is=TRUE)
Length Class Mode
1 character character
This is because you are asking for a summary of the string containing
the file name, not the file itself.
Rather, use
X = read.csv("C:\\Documents\\R_dfiles\\H_N_T.csv",header=TRUE,as.is=TRUE)
and then start looking at X which will be an R object (data frame most
likely) storing all the values of the spreadsheet.
Hope this helps,
Michael
On Mon, Oct 17, 2011 at 2:56 PM, Sally Ann Sims <sallysims at earthlink.net> wrote:
> Hello,
>
> I need some help getting started with data analysis. I’m having trouble getting R to read my data file. I’ve referred to various R help documentation, the website, and FAQs, but I don’t see my situation listed.
>
> I saved an Excel file (post-2007 Excel version) of data as a “.csv” file. However, the file still appears in column format when I open it. Does that happen when you save a an Excel file in .csv format? I have used the function file.choose() to pull in the file into R. When I use the summary command I get:
>
> summary("C:\\Documents\\R_dfiles\\H_N_T.csv",header=TRUE,as.is=TRUE)
> Length Class Mode
> 1 character character
> But the data table actually has five columns and 1000 rows (example of first two lines):
>
> OBJECTID X Y elev HB_NHB
> 1 265712.1 90770.42 7.6372 0
>
>
> When I look at the .csv file, I see that the OBJECTID cell is selected so I think R is just reading the one cell as my data. How can I get R to read the all the data rows and columns? Is there a way to clear the one-cell selection status? Or perhaps there is another issue that needs addressing. I would like to get this data table configured into R as a dataframe.
>
> Thank you,
> Sally
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list