Home » Uncategorized » Uploading a .csv file into R

Uploading a .csv file into R

Day 1: Using R as Calculator (We will not save files in R format for now!) 

Objective: How to upload a .csv file into R?

Step 1 Prepare your workspace

Whenever you begin/complete your work with R execute these two commands: rm(list=ls()) and ls() .

Launch R and type into console panel:

rm(list=ls()) 

press ENTER key, then check if your workspace is cleared

 by using:

ls() 

Step 2 Upload survey data, Sur1.csv by using following syntax

Sur1 <-read.csv(file.choose(),header=TRUE)

Note: You must have your .csv file already downloaded to your computer, (e.g. to your desktop).

Step 3 Check the structure of data uploaded by using the following code

Str(Sur1)

Step 4 Optional: Verify names of variables included in data by using the following syntax

names(Sur1)

Step 5 View the first five rows of Sur1 data using the following syntax:

head(Sur1, 5)

Step 6

 Attach Sur1 data in order to use names of respected variables without $ sign

attach(Sur1)

Step 7 Get a quick look at the summary of variables of Sur1

  • summary(Sur1)

 


Leave a comment

Your email address will not be published. Required fields are marked *