[R] R 3.2.3 on Win8; mkdir command produces error

John Kane jrkrideau at inbox.com
Mon Feb 15 14:51:25 CET 2016


I'd say that Boris Steipe's suggestion is the most likely answer to the problem.  Also, it's been a long time since I used Windows (deo gratias) but that path name does not look right. I think I would have expected something more like:

"C:/Users/rhmichel/rprog-data-specdata/specdata/001.csv"

Any comments from Windows users?

However,  you cannot "load" a .csv file. "load" is intended to load a compiled .Rdata file as I understand it. It may do more but that's all I've ever used it for.

You probably want:
dat1  <-  read.csv("C:/Users/rhmichel/rprog-data-specdata/specdata/001.csv")

Depending on how the data file is set up you may need to add various options to the read.csv file.

read.csv()  assumes that the file has headers  for the columns and that the separator between the columns is a blank space or spaces.

Let's say the separator is a tab and there are no headers you would need to change the read.csv() to 
xx  <-  read.csv("load("C:/Users/rhmichel/rprog-data-specdata/specdata/001.csv", sep = "\t", header = FALSE)

You need to open the data file in a text editor, Notebook will do, and see what it looks like if my two suggestions, or combinations thereof, don't work.

Then do a ?read.csv or perhaps a ?read.table try to figure out what the cryptic help documentation tells you. The solution will be there, it just often is not obvious.. read.csv() is simply a subset of  the more powerful read.table().  

I have great sympathy for you. For the first six months of using R, I seemed to  spend more time trying to get the data into R than working on the problem. Just to be encouraging. :).

BTW if the instructor did not suggest it, I would recommend downloading and installing RStudio. https://www.rstudio.com/products/rstudio/download/ . It is an excellent IDE and makes working with R much easier.

@Ista
While I agree that Heather should ask her instructor for help, I don't see assisting a student getting data into R as helping with a programming assignment. Perhaps at the margins but that is all.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: r-help at r-project.org
> Sent: Sun, 14 Feb 2016 23:50:34 +0000 (UTC)
> To: r-help at r-project.org
> Subject: Re: [R] R 3.2.3 on Win8; mkdir command produces error
> 
> As a follow-up to my request for help this morning, I have watched
> tutorials on R all afternoon. Many topics come close to my problem, but
> none specifically address my situation where "specdata" is not a text
> file but a list of small files in a folder.I found a command that should
> be more right than mkdir, but it still won't work for my assignment. What
> argument am I getting wrong?To recap, I can't access in R my data files
> that are on my desktop. I need more understanding about how directories
> transfer between Windows and R.
>> dir.create('specdata')
> 
>  > dir.exists("specdata")[1] TRUE
Error:
>> bad restore file magic number (file may be corrupted) -- no data
>> loadedIn addition: Warning message:file ‘001.csv’ has magic number
>> '"Date'  Use of save versions prior to 2 is deprecated
>> pollutantmean("C:\Users\rhmichel\Desktop\rprog-data-specdata\specdata",
>> "sulfate", 1:10)Error: '\U' used without hex digits in character string
>> starting ""C:\U">
> Thank you for any help you can provide me,Heather Michel
>     On Sunday, February 14, 2016 2:40 PM, HEATHER MICHEL
> <heathermichel at rocketmail.com> wrote:
> 
> 
>  I am trying to complete a homework assignment, but I know very little
> about R.The assignment says, "For this programming assignment you will
> need to unzip this file and create the directory 'specdata".I unzipped
> the file on my desktop, and my computer automatically created a new
> folder which I renamed "specdata."However, when I try to make this
> directory within R using mkdir, I get this:
>> mkdir (specdata)Error: could not find function "mkdir"> ?mkdirNo
>> documentation for ‘mkdir’ in specified packages and libraries:you could
>> try ‘??mkdir’> ??mkdir> pwdError: object 'pwd' not found
> 
> This makes me believe that some of the old command names have been
> updated in this version that is only 2 months old. Of course, the
> lectures I took notes on used an older version of R and were created more
> than 2 months ago.
> Please tell me the command I should be using to create a directory named
> 'specdata' in R 3.2.3
> Heather Michel
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!



More information about the R-help mailing list