R Scripts Flashcards

1
Q

Library(tidyverse)

A

called out database named tidyverse

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

View(msleep)

A

called out dataset known as msleep

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

?msleep

A

to know the description of the dataset

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

names(msleep)

A

to get the list of variables

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

msleep %>%

A

refer to msleep dataset

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

msleep %>%
rename(“converse”=”conservation”) %>%
View()

A

rename converse to conversation in msleep

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

msleep %>%
select(vore,name,everything()) %>%
View()

A

reorder the variable, have core column vore and name, followed by everything.

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

msleep %>%
select(vore,name,brainwt) %>%
View()

A

only want certain variables; vore, name, and brainwt.

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

msleep %>%
filter((order==”Carnivora”|order==”Primates”)& sleep_total>8) %>%
select(name,order,sleep_total) %>%

A

to filter and arrange, filter under the variables we want carnivora and primates and under sleep total we want more than 8 hours

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

arrange(-sleep_total) %>%
View()

A

arrange sleep total to descending order

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

mutate

A

changing the variable

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

msleep %>%
mutate(brainwt_in_grams=brainwt*1000) %>%
View()

A

we want to change braiwnt from kg to grams

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

drop_na(vore)

A

go to vore column and remove not available

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

mutate(brain_size=if_else(brainwt>0.01,”large”,”small”)) %>%
View()

A

change numeric to categorical

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

size_of_brain=msleep %>%

A

create a new file known as size of brain

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

Summary()

A

shows summary

17
Q

Names(Starwars)

A

list down all the variables in starwars