Which of the dataset formats listed at this link is the easiest to load for processing in R? A few minutes with a text editor should be enough to turn the text version into literal data but can one of the other forms be loaded i开发者_开发知识库n less than O(n) user effort?
I've found this laundry list of IO options but it dosn't seem especially helpful.
P.s. I've never used R before and am trying to help a friend who is the one that needs to do this.
Grab the text files and follow the instructions in the spreadsheet-like data section of R Data Import/Export. I would avoid trying to read from Excel files unless you absolutely have to.
It could be as easy as:
x <- read.table("file.txt", header=TRUE, sep="\t")
# or
x <- read.delim("file.txt") # header=TRUE and sep="\t" are already defaults
If everything else fails, why not read the manual devoted to Data Import / Export ?
You can import data from
- ascii files with whichever delimiter (csv, txt, ...)
- fixed form files
- binary files in various formats (hdf5, netcdf, ...)
- spreadsheets, in most formats even on non-Windows platforms
- databases (DBI, RODBC, ...)
- web pages (using the XML package)
- web services like SOAP, JSON, ...
- directly from other programs using connections, ...
- and more
so calling any one of these preferred is diffcult -- it all depends on the task at hand.
From the options you have available, the tab delimited text files are the easiest to import. Followed by the SPSS files and then everything else. I agree with other posters, avoid files with .xls (or convert single sheet workbooks into tsv, csv.
The foreign package can be used to open those SPSS files which is just as easy:
install.packages("foreign")
library(foreign)
setwd("/Path/to/your/files")
read.spss("FILENAME.sav", to.data.frame=T)
精彩评论