[R] [Tagged] Re: Running CSV File
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Mar 29 22:55:23 CEST 2026
Re 2: While most people will prefer the hint provided by the file extension, R mostly (and particularly so in this case) ignores the file extension for data import.
General point: the file.choose function is a valuable tool for translating point and click file selection into full file paths as you learn your way around... you can either put the function call into wherever you are specifying your filename and have to select the file manually every time you read it:
g<-read. csv (file.choose(), header=True, sep ',')
or you can do it once and make a note of the file path it returns and use that in your read.csv call:
interactively:
> file.choose()
[1] "some\\long\\path\\to\\cancer_data.csv"
in your script (you are keeping your proven commands in an R file, right?), put:
g<-read. csv ("some\\long\\path\\to\\cancer_data.csv", header=True, sep ',')
On March 29, 2026 1:27:30 PM PDT, Jeff Reichman <reichmanj using sbcglobal.net> wrote:
>1. Working directory message. The message “The current active source is not
>saved so does not have a directory to change into” appears when the script
>you’re working in hasn’t been saved yet.
>Once you save the script (File → Save As), RStudio will allow you to set
>the working directory normally.
>
>2. File not appearing in the directory. The dataset was saved on your
>computer as “cancer data” without a file extension. RStudio won’t
>recognize it as a CSV unless it ends in .
>Renaming it to cancer_data.csv (or cancer data.csv) will make it show up
>correctly.
>
>3. Errors when running . The errors you received were caused by a few syntax
>issues:
>* Using instead of
>* Including a trailing comma inside the filename
>* Using instead of R’s required
>* The file not having a extension
>After correcting these, the proper command is:
>
>This should load the dataset as long as the working directory is set to the
>folder where the file is saved
>
>-----Original Message-----
>From: R-help <r-help-bounces using r-project.org> On Behalf Of Li DiJulia
>Sent: Saturday, March 28, 2026 12:27 PM
>To: r-help using r-project.org
>Subject: [R] Running CSV File
>
>To whom it may concern,
>
>I am trying to save this file "cancer data," which I have attached in this
>email, into working directory and when I click on "to source file location"
>under set working directory" it says- The current active source is not saved
>so does not have a directory to change into. I even clicked on "choose
>directory" under set working directory, my file still won't show up.
>
>As for running data, When I downloaded the cancer data into R studio and ran
>g<-read. csv (" cancer_data," header=True, sep ','), I got this error
>message: *unexpected string consonant in g<-read. csv. (" cancer_data,"
>header=True, sep ',').*
>
>Note: I saved the data in my computer as "cancer data." I am not sure what I
>am doing wrong. Please advise
>
>When I tried this g<-read.csv. ("cancer_data," header=true, sep=",") I got
>this: in read.csv. ("cancer_data, header= true, sep=','):could not find
>function "read.csv". I am not sure what I am doing wrong. Please advise
>
>
>Thanks.
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>https://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
Sent from my phone. Please excuse my brevity.
[[alternative HTML version deleted]]
More information about the R-help
mailing list