6 Input, Output, Connections
6 Input, Output, Connections
Session outcomes
To understand and use:
> getwd( )
Working directory
● To set a new connection directory, use the set working directory function
> my_md <- “C://Users…/dir/” (copy the path from your directory browser)
● You can export data objects from the R environment using the save function
> load(“my_x.rda”)
>x
>y
Connections
● R can also read common data files
134
234
567
> file_list
Connections
● To read from the file
> matr
Also try
> matr
Connections
● To read from file as a data frame
> df
> df
Compare
> class(df)
> class(matr)
Connections
● To read from a spreadsheet
> df
Connections
● Writing to file
> library("readxl")
Go to http://faculty.marshall.usc.edu/gareth-james/ISL/data.html
> head(data)
Session outcomes
To understand and use: