Hello, I have been given a .csv file and it is not loading. This is what I did. survey=read.csv("http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") attach(survey) pulse.sf=pulse[smoke==1 & sex==2] pulse.sf Template link here<http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/p4.Rnw>. I insert the file into the R commands section for question 1. Doing that produces the following below: survey <- read.csv(file="http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") attach(survey) ## Error in attach(survey): object 'survey' not found pulse.sf=pulse[smoke==1 & sex==2] ## Error in eval(expr, envir, enclos): object 'pulse' not found pulse.sf ## Error in eval(expr, envir, enclos): object 'pulse.sf' not found What's going on? I can actually download the survey and view it on Excel. Appreciate any help that I can get. [[alternative HTML version deleted]]
Sorry, we don't do homework on this list. You should ask your instructor. Duncan Murdoch On 18/08/2016 5:19 AM, Barathan Roy Pinas wrote:> Hello, > > > I have been given a .csv file and it is not loading. This is what I did. > > > survey=read.csv("http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > attach(survey) > pulse.sf=pulse[smoke==1 & sex==2] > pulse.sf > > Template link here<http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/p4.Rnw>. > > I insert the file into the R commands section for question 1. Doing that produces the following below: > > > survey <- read.csv(file="http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > attach(survey) > > ## Error in attach(survey): object 'survey' not found > pulse.sf=pulse[smoke==1 & sex==2] > ## Error in eval(expr, envir, enclos): object 'pulse' not found > pulse.sf > ## Error in eval(expr, envir, enclos): object 'pulse.sf' not > found > > What's going on? I can actually download the survey and view it on Excel. > > Appreciate any help that I can get. > > [[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. >
I don't think you can read files into R like that. This answer http://stackoverflow.com/questions/3236651/read-data-from-internet on Stack Overflow tells you, you could use the RCurl package. Here are more examples on getting data from online sources https://www.r-bloggers.com/getting-data-from-an-online-source/ You could also just download the file manually and open it using read.scv Hope this helps, Ulrik On Thu, 18 Aug 2016 at 19:10 Barathan Roy Pinas <bpin3104 at uni.sydney.edu.au> wrote:> Hello, > > > I have been given a .csv file and it is not loading. This is what I did. > > > survey=read.csv(" > http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > attach(survey) > pulse.sf=pulse[smoke==1 & sex==2] > pulse.sf > > Template link here<http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/p4.Rnw > >. > > I insert the file into the R commands section for question 1. Doing that > produces the following below: > > > survey <- read.csv(file=" > http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > attach(survey) > > ## Error in attach(survey): object 'survey' not found > pulse.sf=pulse[smoke==1 & sex==2] > ## Error in eval(expr, envir, enclos): object 'pulse' not found > pulse.sf > ## Error in eval(expr, envir, enclos): object 'pulse.sf' not > found > > What's going on? I can actually download the survey and view it on Excel. > > Appreciate any help that I can get. > > [[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. >[[alternative HTML version deleted]]
After: survey <- read.csv(file="http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") do: summary(survey) then bone up on "attach" and "with". Clint Bowman INTERNET: clint at ecy.wa.gov Air Quality Modeler INTERNET: clint at math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600 FAX: (360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels: 300 Desmond Drive, Lacey, WA 98503-1274 On Thu, 18 Aug 2016, Ulrik Stervbo wrote:> I don't think you can read files into R like that. This answer > http://stackoverflow.com/questions/3236651/read-data-from-internet on Stack > Overflow tells you, you could use the RCurl package. > > Here are more examples on getting data from online sources > https://www.r-bloggers.com/getting-data-from-an-online-source/ > > You could also just download the file manually and open it using read.scv > > Hope this helps, > Ulrik > > On Thu, 18 Aug 2016 at 19:10 Barathan Roy Pinas <bpin3104 at uni.sydney.edu.au> > wrote: > >> Hello, >> >> >> I have been given a .csv file and it is not loading. This is what I did. >> >> >> survey=read.csv(" >> http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") >> attach(survey) >> pulse.sf=pulse[smoke==1 & sex==2] >> pulse.sf >> >> Template link here<http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/p4.Rnw >>> . >> >> I insert the file into the R commands section for question 1. Doing that >> produces the following below: >> >> >> survey <- read.csv(file=" >> http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") >> attach(survey) >> >> ## Error in attach(survey): object 'survey' not found >> pulse.sf=pulse[smoke==1 & sex==2] >> ## Error in eval(expr, envir, enclos): object 'pulse' not found >> pulse.sf >> ## Error in eval(expr, envir, enclos): object 'pulse.sf' not >> found >> >> What's going on? I can actually download the survey and view it on Excel. >> >> Appreciate any help that I can get. >> >> [[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. >> > > [[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. >
Ulrik: you can absolutely read from a URL in read.csv() with that syntax. The error `## Error in attach(survey): object 'survey' not found` suggests that the OP mis-typed something in the `survey` name in the assignment from `read.csv()`. However, the OP has quite a bit more to be concerned about than the missing variable in the environment if their stats program is encouraging both no spaces between operators and the use of `attach()`. On Thu, Aug 18, 2016 at 1:26 PM, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote:> I don't think you can read files into R like that. This answer > http://stackoverflow.com/questions/3236651/read-data-from-internet on > Stack > Overflow tells you, you could use the RCurl package. > > Here are more examples on getting data from online sources > https://www.r-bloggers.com/getting-data-from-an-online-source/ > > You could also just download the file manually and open it using read.scv > > Hope this helps, > Ulrik > > On Thu, 18 Aug 2016 at 19:10 Barathan Roy Pinas < > bpin3104 at uni.sydney.edu.au> > wrote: > > > Hello, > > > > > > I have been given a .csv file and it is not loading. This is what I did. > > > > > > survey=read.csv(" > > http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > > attach(survey) > > pulse.sf=pulse[smoke==1 & sex==2] > > pulse.sf > > > > Template link here<http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/p4. > Rnw > > >. > > > > I insert the file into the R commands section for question 1. Doing that > > produces the following below: > > > > > > survey <- read.csv(file=" > > http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > > attach(survey) > > > > ## Error in attach(survey): object 'survey' not found > > pulse.sf=pulse[smoke==1 & sex==2] > > ## Error in eval(expr, envir, enclos): object 'pulse' not found > > pulse.sf > > ## Error in eval(expr, envir, enclos): object 'pulse.sf' not > > found > > > > What's going on? I can actually download the survey and view it on Excel. > > > > Appreciate any help that I can get. > > > > [[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. > > > > [[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. >[[alternative HTML version deleted]]
On Thu, 18 Aug 2016 09:19:05 +0000 Barathan Roy Pinas <bpin3104 at uni.sydney.edu.au> wrote:> Hello, > > > I have been given a .csv file and it is not loading. This is what I > did. > > > survey=read.csv("http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv") > attach(survey) > pulse.sf=pulse[smoke==1 & sex==2] > pulse.sf >... A couple of points. First, your question addresses RStudio which has its own list. Next, the issue appears to be homework, and that is not something many will help you with. However, since the actual issue is generic to R, let that slide. You want to be sure the address is correctly typed. Is the "r" supposed to be lower case? Then, do you have the appropriate permissions to enter that page? Since that is a university server, you may need to be logged in through your student account to access the page with the data. Even if you are, will it let RStudio access it? It would probably be simplest to simply download the data to your system, then read in the local copy. -- John