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
dbinom()
density function; gives you the probability of x successes given the number of trails and the probability of success on a single trial
pbinom()
Probability distribution fucntion: gives you the cumulative probability of getting a number of successes below a certain cut-off point, given the size and the probability
qbinom ()
the quantile function: is the opposite of pbinom(), in that gives you the x axis value for a given probability p, plus given the size and prob, that is if the probability of flipping a head is .5, how many heads would you expect to get with 10 flips
dnorm()
used for calculating the probability of a specific value
pnorm()
for calculating the probability of getting at least or at most a specific value
qnorm()
the quantile function, for calculating specific values associated with a given probability