On my computer, I saved the file as Cancer Data. csv. When I tried to put
the "Cancer Data.csv" in the working directory, under "source
file," it
says the currently active source file is not saved so doesn't have a
directory to change into. I also tried to put it in the "choose
directory"
and my file would not show. I am not sure what I am doing wrong.
When I tried to run the data set in R studio, I get unexpected symbol in
"g<-read.csv("cancer data.csv," header",despite writing
g<-read.csv
("cancer data.csv," header=TRUE, sep=',').
When I ran a Chi Square test, it said "object not found." I don't
know what
I am doing wrong
Thanks.
Attached are the files of the error message I am getting.
On Saturday, March 28, 2026, Li DiJulia <dijulia98 at gmail.com> wrote:
> 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.
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cancer data csv.PNG
Type: image/png
Size: 4298 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20260329/ae549c47/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Chi Square test.PNG
Type: image/png
Size: 4155 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20260329/ae549c47/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CSV Read.PNG
Type: image/png
Size: 35235 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20260329/ae549c47/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Unexpected string.PNG
Type: image/png
Size: 40022 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20260329/ae549c47/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Working file.PNG
Type: image/png
Size: 45393 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20260329/ae549c47/attachment-0004.png>
I don't know why you've reposted this.
However, the image is now available which shows the file is actually called
Cancer data.csv
That's how it should appear in the command. No _ no , no space before the
name. And make the C capital (windows probably won't care, Linux etc would)
Now. You also are trying to do a chisq. That seems a jump ahead.
Before I did that I would be doing head(g)
To explain your code:
g <- read.csv("Cancer data.csv" header=TRUE, sep=',')
Is what you want. And it will create an object "g".
head(g) will display the top few lines of the object. Effectively a preview
of your data
I'm assuming from your chisq example that you might want
chisq.test(x = g$five_a_day, y = g$cancer)
That said - I've never read data from a CSV and run a chisq straight off
like that.
So it may well be you need to do more work
I fear you are trying to learn R and either doing homework (in which case -
you should go back to the course and say you need help) or you are trying
to learn R with a live project and you might need to start with an online
tutorial. Beware that spelling matters in programming.
On Tue, 31 Mar 2026, 21:26 Li DiJulia, <dijulia98 at gmail.com> wrote:
> On my computer, I saved the file as Cancer Data. csv. When I tried to put
> the "Cancer Data.csv" in the working directory, under
"source file," it
> says the currently active source file is not saved so doesn't have a
> directory to change into. I also tried to put it in the "choose
directory"
> and my file would not show. I am not sure what I am doing wrong.
>
> When I tried to run the data set in R studio, I get unexpected symbol in
> "g<-read.csv("cancer data.csv," header",despite
writing g<-read.csv
> ("cancer data.csv," header=TRUE, sep=',').
>
> When I ran a Chi Square test, it said "object not found." I
don't know what
> I am doing wrong
>
> Thanks.
>
> Attached are the files of the error message I am getting.
>
> On Saturday, March 28, 2026, Li DiJulia <dijulia98 at gmail.com>
wrote:
>
> > 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 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
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
?s 01:50 de 30/03/2026, Li DiJulia escreveu:> On my computer, I saved the file as Cancer Data. csv. When I tried to put > the "Cancer Data.csv" in the working directory, under "source file," it > says the currently active source file is not saved so doesn't have a > directory to change into. I also tried to put it in the "choose directory" > and my file would not show. I am not sure what I am doing wrong. > > When I tried to run the data set in R studio, I get unexpected symbol in > "g<-read.csv("cancer data.csv," header",despite writing g<-read.csv > ("cancer data.csv," header=TRUE, sep=','). > > When I ran a Chi Square test, it said "object not found." I don't know what > I am doing wrong > > Thanks. > > Attached are the files of the error message I am getting. > > On Saturday, March 28, 2026, Li DiJulia <dijulia98 at gmail.com> wrote: > >> 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 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 https://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code.Hello, Try g <- read.csv("Cancer data.csv") This should do it. As for the other problems, can you post the output of dput(head(g)) in an e-mail, please? Hope this helps, Rui Barradas
Faith,
Computer programs are very PRECISE and you are apparently not taking enough care
and will inevitably keep running into mistakes.
Please do not insert or delete spaces. Your filename of " Cancer Data.
csv." Has an extra space before the period and maybe an extra period at the
end. It will only be opened if you type it exactly that way. Did you intend
Cancer Data.csv with no trailing period either?
Can we suggest you avoid using spaces in file names if there is no reason to?
CancerData.csv is easy enough to red s is Cancer_Data.csv too.
Until you match up the filename properly, nothing else will work.
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Li DiJulia
Sent: Sunday, March 29, 2026 8:51 PM
To: r-help at r-project.org
Subject: Re: [R] Running CSV File
On my computer, I saved the file as Cancer Data. csv. When I tried to put
the "Cancer Data.csv" in the working directory, under "source
file," it
says the currently active source file is not saved so doesn't have a
directory to change into. I also tried to put it in the "choose
directory"
and my file would not show. I am not sure what I am doing wrong.
When I tried to run the data set in R studio, I get unexpected symbol in
"g<-read.csv("cancer data.csv," header",despite writing
g<-read.csv
("cancer data.csv," header=TRUE, sep=',').
When I ran a Chi Square test, it said "object not found." I don't
know what
I am doing wrong
Thanks.
Attached are the files of the error message I am getting.
On Saturday, March 28, 2026, Li DiJulia <dijulia98 at gmail.com> wrote:
> 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.
>
>