Lesson2 RStudio Basics Flashcards

1
Q

console

A

lower left, with prompt to type commands

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

workspace

A

upper right panel, shows history of commands

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

R Markdown

A

Upper left panel, document

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

Lower right panel

A

plots show here, browse files, access help, manage packages

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

R Packages

A

Collections of R functions, data and compiled code in a well-defined format, we use statsr, dplyr, ggplot2

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

Install package commands

A

install.packages and install_github

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

Command for loading packages in working environment

A

library
e.g library(dplyr)
You only need to install package once but load each time you relaunch RStudio

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

How to run commands from either Red file or console

A

-click on the green arrow of the code chunk in the R Markdown(Rmd) file, or
-highlight these lines, and hit the Run button, or
-type the code in the console

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

command to load data

A

data()
eg. data(arbuthnot)

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

objects

A

as you work with R, you will create a series of objects, sometimes you will load them with data command, sometimes you create them yourself as byproduct of a computation or analysis

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

How to use dataviewer in the Environment

A

upper right window, click on name of data set that lists objects in your workspace
e.g. arbuthnot

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

data frame

A

a kind of spreadsheet or table where R stores data

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

dim() command

A

command for asking for dimension of data, eg. 82 rows and 3 columns

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

names()

A

command for asking for variable names

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

how is invoking R commands like math class

A

invoking R commands means supplying a function with some number of arguments, eg. such as a single argument of the name of a data frame

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

up and down arrow keys at prompt

A

scroll through your previous commands

17
Q

R Markdown is solution for what problem

A

documenting your code

18
Q

Knit button on RStudio

A

type the code for the questions in the code chunks provided in the Rmd document and knit the document to see results

19
Q

$

A

Access the data in a single column of a data frame separately using a command eg. arbuthnot$boys
“go to the data frame that comes before me, and find the variable that comes after me.”

20
Q

vectors

A

most common data structure in R, one dimensional array of elements, R will print out a single variable vector with a a number added in brackets, along the left side to indicate locations within the vector, ordered by entry number

21
Q

recursive vector

A

a list is a recursive vector, a vector that can contain another vector or list in each of its elements

22
Q

or ##

A

comment out in R

23
Q

ggplot() function, what does it build and what is the format?

A

function to build plots
ggplot(data= arbuthnot, aes(x = year, y= girls)) + geom-point()

looks like a function, arguments separated by commas

1st argument = dataset
2nd provide the variables to the aesthetic elements of the plot e.g. the and y axes.
3rd use another layer, separated by a + to specify the geometric object for the plot, scatterplot is geom_point

24
Q

how to ask for help for a function

A

?ggplot
a help file will replace files in the lower right panel, with a new tab

25
Q

how to add vectors

A

use variable names and addition sign and R will compute all sums simultaneously
eg arbuthnot$boys + arbuthnot$$girls

26
Q

how to save new vector

A

use piping operator %>%, takes the output of the current line and pipes it into the following line of code

eg. arbuthnot <- arbuthnot %>%
mutate(total = boys + girls)

27
Q

What does this piping code say in English?
rbuthnot <- arbuthnot %>%
mutate(total = boys + girls)

A

Take the arbuthnot dataset and pipe it into the mutate function. Using this mutate a new variable called total that is the sum of the variables called boys and girls. Then assign this new resulting dataset to the object called arbuthnot, i.e. overwrite the old arbuthnot dataset with the new one containing the new variable.

28
Q

what does >- symbol do?

A

assignment, taking the output of one line of code and saving it into an object in your workspace
rbuthnot <- arbuthnot %>%
mutate(total = boys + girls)
in this example, you already have an object called arbuthnot, so this command updates that data set with the new mutated column

29
Q

How to make a line plot instead of a scatter plot

A

using geom_line() instead of geom_point()
ggplot(data = arbuthnot, aes(x = year, y = total)) +
geom_line()

30
Q

How to do both a scatter plot and a line plot?

A

List both

ggplot(data = arbuthnot, aes(x = year, y = total)) +
geom_line() +
geom_point()

31
Q

How to use greater than, less than and equality symbols?

A

arbuthnot <- arbuthnot %>%
mutate (more_boys = boys > girls)

generates a column of true/false answers

32
Q
A