Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Importing survey on R Studio

  1. Aug 18, 2016 #1
    I am using R studio for a practical and I need to load a survey. It suggests that I place the following into the R template that I was provided:

    pulse.sf=pulse[smoke==1 & sex==2]

    Template link here.

    I have no clue WHERE one inserts these lines. I try the following:

    urvey <- read.csv(file="http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/survey.csv")
    ## 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
    ## Error in eval(expr, envir, enclos): object ’pulse.sf’ not

    What's going on? I can actually download the survey and view it on Excel. The problem is drawing the data into R studio.

    Appreciate any help that I can get.
  2. jcsd
  3. Aug 18, 2016 #2
    It works for me. So some questions:
    1) Did you actually download the survey and put it in your computer?
    2) What folder did you put in the survey? Type getwd() in R to see what folder you should put in the survey. For example if getwd() yields C:\Documents, then you should put the csv file in that folder and then access it by survey <- read.csv("survey.csv")
    3) You can change your folder in R by setwd https://stat.ethz.ch/R-manual/R-devel/library/base/html/getwd.html
  4. Aug 18, 2016 #3


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    @micromass is right. You have to have the file on your computer. You can not read it from an internet address.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted