Chapter 2 Interacting With RStudio
2.3 packages
install.packages("PACKAGE")
installs new package (required once)library(LIBRARY_NAME)
attaches (opens) a package (required every time a session opened)search()
lists packages currently attached.libPaths
lists where packages are saved in computer
2.4 import
2.4.1 csv
DF <- read.csv("FILENAME.csv", header = TRUE)
reads the.csv
file within the working directory- for files with multiple headers rows (often the case with
.csv
files from quatrics) use:DF <- read.csv("FILENAME", header = TRUE)[-1:-2,]
to import the.csv
without 2nd and 3rd rowswrite.csv(DF, "NEW_FILENAME.csv") # writes a new csv
to write a new.csv
on the working directoryDF <- read.csv("NEW_FILENAME.csv", header = TRUE)
to import the new.csv
- note that the file actions take place within the working directory, follows the code chunk
<- read.csv("FILENAME", header = TRUE)[-1:-2,] # cleans the 2nd and 3rd
DF write.csv(DF, "FILENAME.csv") # writes a new csv
<- read.csv("FILENAME.csv", header = TRUE) # writes a new DF DF