Data wrangling Flashcards

(7 cards)

1
Q

What are the rows and columns called in a data frame?

A

Observations and variables, respectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you see the number of rows and columns in a tibble when using the dplyr library

A

They are displayed at the top of the tibble when it is printed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which dplyr verb allows you to look at a subset of observations based on a specific condition.

A

filter()

Ex: filter(my_tibble, country == “United States”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the syntax and definition of a pipe?

A

%>%

A pipe takes whatever is before it, and feeds it into the next step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which dplyr verb sorts the observations in a dataset in ascending or descending order based on one of its variables?

A

arrange()

Ex: arrange(my_tibble, gdpPerCap)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you arrange in descending order?

A

Add desc() around the variable you are arranging by.

Ex: my_tibble %>%
arrange(desc(gdpPerCap))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which dplyr verb allows you to change one of the variables in your dataset, or add a new variable?

A

mutate()

Ex: my_tibble %>%
mutate(pop = pop / 1000000)

Ex: my_tibble %>%
mutate(gdp = gdpPerCap * pop)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly