First time R user...cant get data into R [closed]
I'm a first time R user and I'm trying to run some data. The data consists of two columns. I copied it from the class website and pasted it on notepad. I saved the data on my desktop as : act.txt Now I'm trying to upload it into R in the same method our professor tought us :
data1<- read.table(file="act.txt",header=TRUE)
but it's giving me this error :
Error in file(file, "rt") : cannot open the connection
In addition: Warning message: In file(file, "rt") : cannot open file 'act.txt': No such file or directory
Can you please point me in the right direction? Thank you!
If you are a first time user I'd suggest you use a IDE. Will greatly help you, and make your life easier. Propably the best arround for new users is RStudio http://www.rstudio.org/
If you have Excel installed, you may want to copy from the website into Excel and then save that as CSV.
Then just set your working directory (folder where you're keeping your data) with setwd(), and type read.csv(...).
Alternatively, if you specify the full path like this "C:...\act.txt", make sure to change all "\" to "/".
data1<- read.table(file="act.txt",header=TRUE)
Maybe this is a little too obvious but are you giving the full path of the file? If you are using Windows 7 and it is on your desktop the full path should be something like this:
C:\Users\Dan\Desktop\act.txt
And because this is R, you need forward slashes in the path, not backslashes (which caught me out when I started using R). So perhaps you should try:
data1<- read.table(file="C:/Users/Dan/Desktop/act.txt",header=TRUE)
...but replacing 'Dan' in the above path with your username.
精彩评论