Reputation: 738
My questions are:
I am able to read the file using read.csv but read.table gives me an error. I've also tried the following codes, but failed to read the file:
read.table("hw1_data R programming.xlsx", header = TRUE, sep = ",")
read.table("hw1_data R programming.xlsx", sep = ",")
read.table("hw1_data R programming.xlsx", header = TRUE, sep = ",",fileEncoding='UCS-2LE')
How can I use read.table
?
What are the advantages (or disadvantages) of using read.table
over
read.csv
and vice versa? [I belive one point is: read.table
don't require files to be saved in csv format, which is the case generally. Am I right?]
I've googled for ways to load excel file in R and found http://www.r-tutor.com/r-introduction/data-frame/data-import, http://www.statmethods.net/input/importingdata.html and tried installing gdata (and also with xlsx). And finally was able to load the file. But I wonder, why do we need all these steps installing packages like gdata/xlsx/etc...perl) , if we can simply do the same thing by read.csv
or read.table
.
What are the advantages (or disadvantages) of using these packages over read.table
and read.csv
and vice versa?
Upvotes: 0
Views: 1105
Reputation: 1371
Try...
install.packages("readxl")
library(readxl)
hw1 <- read_excel("hw1_data R programming.xlsx")
Upvotes: 2