How do I import a survey into R Studio from an internet address?

  • Thread starter BubblesAreUs
  • Start date
  • Tags
    Survey
In summary, the conversation discusses the process of loading a survey into R Studio for a practical. The recommended method is to use the provided R template and insert the lines of code for reading the survey, attaching it, and creating a subset of the data. The issue at hand is the error messages that occur when attempting to execute the code. The expert suggests checking the location of the survey file and making sure it is downloaded onto the computer before attempting to read it into R Studio. They also mention the option of changing the current working directory in R Studio.
  • #1
BubblesAreUs
43
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:

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 http://www.maths.usyd.edu.au/u/UG/IM/STAT2012/r/p4.Rnw.

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")
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
foun

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.
 
Physics news on Phys.org
  • #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
 
  • Like
Likes FactChecker
  • #3
@micromass is right. You have to have the file on your computer. You can not read it from an internet address.
 

Related to How do I import a survey into R Studio from an internet address?

1. What is R Studio?

R Studio is an integrated development environment (IDE) specifically designed for statistical computing and graphics. It is a popular platform among data scientists and analysts for its powerful tools and user-friendly interface.

2. How do I import a survey on R Studio?

To import a survey on R Studio, you can use the "read.csv()" function, which reads data from a comma-separated (CSV) file and creates a data frame. You can also use the "read.table()" function for other types of files such as tab-delimited or fixed-width files.

3. What types of surveys can be imported on R Studio?

R Studio allows you to import various types of surveys, such as Likert scale, multiple-choice, open-ended, and more. As long as your survey data is in a compatible format (e.g. CSV, Excel, etc.), you should be able to import it on R Studio.

4. Can I edit my imported survey data on R Studio?

Yes, you can edit your imported survey data on R Studio. R Studio has a built-in data editor that allows you to make changes to your data, such as adding or removing columns, renaming variables, and more. You can also use the "edit()" function to make changes to specific data points.

5. Is there a limit to the size of survey data that can be imported on R Studio?

R Studio does not have a specific limit on the size of survey data that can be imported. However, it is recommended to use a computer with enough memory and processing power to handle large datasets. Additionally, you can use the "read.csv()" function with the "chunkSize" argument to read in large datasets in smaller chunks.

Back
Top