R studio Flashcards
str()
way of summarizing the data
count()
counts variables
group_by()
- groups a dataset
- whatever you do next to the dataset will be done separately for each group
- e.g. each gender
summarise ()
will create a table with summary stats you have requested
inner_join()
Uses matching rows from each data set to join them
e.g.
full_dat <- inner_join(x = demographic_data,
y = score_data,
by = “Participant”)
select ()
Creates a new dataset with just the columns you want
If you want to say which ones you don’t want use -variable.
filter ()
Used to pick which rows of data you want to keep based on one or more criteria
mutate()
Changing the data set
For example adding a new variable:
full_data <- full_data %>%
mutate(gender_coded = factor(gender,
levels = c(2,1, 3),
labels = c(“Man”, “Woman”, “Nonbinary”)))
How do you create a scatter plot
ggplot( data set, aes(x = variable, y = variable)) + geom_point()
How do you add a line of best fit to a scatter graph?
geom_(smooth)
pivot_longer()
transforms data from wide-form to long-form
How do you use pivot_longer?
pivot_longer (cols = first column : last column,
names to = “coloumn name”,
values to = “column name”
as.factor()
Overwrites whatever is in that column as a factor
as.character()
overwrites whatever is in that column as a character