[R] R 3.2.3 on Win8; mkdir command produces error
HEATHER MICHEL
heathermichel at rocketmail.com
Wed Feb 24 06:33:08 CET 2016
I found another MOOC that teaches R at a more basic level than the one I am currently taking. Actually, it was suggested by a classmate who discovered it in her search for how to accomplish this homework assignment. It pointed me to http://www.statmethods.net/interface/workspace.html which has a very important statement that pertained to my issue:IMPORTANT NOTE FOR WINDOWS USERS:
R gets confused if you use a path in your code like
c:\mydocuments\myfile.txt
This is because R sees "\" as an escape character. Instead, use
c:\\my documents\\myfile.txt
c:/mydocuments/myfile.txt
Either will work. I use the second convention throughout this website.
This solved my initial problem with calling the correct directory for R to read from.
On Monday, February 15, 2016 4:04 PM, John Kane <jrkrideau at inbox.com> wrote:
John Kane
Kingston ON Canada
-----Original Message-----
From: istazahn at gmail.com
Sent: Mon, 15 Feb 2016 11:06:47 -0500
To: jrkrideau at inbox.com
Subject: Re: [R] R 3.2.3 on Win8; mkdir command produces error
On Feb 15, 2016 8:53 AM, "John Kane" <jrkrideau at inbox.com> wrote:
>
> 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/ [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.
I don't have any objection except the practical concern that people on this list guessing what the problem might be is less likely to lead to a satisfactory answer than asking the instructor. IMO the answers provided so far may have actually increased the OP's confusion. Asking the instructor directly seems to me more likely to produce an illuminating response.
Best,
Ista
Good point but we already started confusing her :(
>
> 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 [https://stat.ethz.ch/mailman/listinfo/r-help]
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html [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 [http://www.inbox.com/photosharing] to find out more!
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help]
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html]
> and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
[[alternative HTML version deleted]]
More information about the R-help
mailing list