Intro to R Flashcards
1
Q
Install packages
A
install.packages(“packagename”)
2
Q
Load packages
A
library(packagename)
3
Q
Set working directory
A
setwd(location)
4
Q
Load data from computer
A
read.csv(“filename”)
5
Q
Load pre-assigned dataset
A
data(“filename”)
6
Q
Select specific value
A
select(filename, row, column)
7
Q
Summary statistics
A
summary(datafile).
8
Q
See specific rows
A
head(datafile, #)
tail(datafile, #)
9
Q
Omit NA values
A
na.omit(datafile)
10
Q
Remove columns
A
dplyr::select(dataset, -contains(“colname”))
11
Q
Filter values
A
filter(datafile, col <= #)
12
Q
Histogram
A
hist(dataset$col)
13
Q
Create new column/mutate using a formula
A
dataset %>% mutate (newcolname= (formula))
14
Q
Determine if columns are identical
A
identical(dataset$col1, dataset$col2)
15
Q
Save data as CSV
A
write.csv(newname)