Study Guide for R Labs

¡Supera tus tareas y exámenes ahora con Quizwiz!

What values are represented by NA?

Not Available

What does NaN stand for in R?

Not a Number

What will R do if directed to paste(LETTERS, 1:4, sep = "-") where the vector LETTER is longer than the vector 1:4?

R recycles/repeats 1:4 until it matches the length of LETTERS

What will str() tell you in R?

converts values to a string form so they can be combined with other strings

In R, as in many other programming environments, what will the up-arrow button do?

cycle through previous commands

How do you get the current date in R?

d1<-System.Date()

When plotting to a file device, what command do you use to close the device?

dev.off()

What would ncol() tell you in R?

only the number of columns

What would nrow() tell you in R?

only the number of rows

1.) Before plotting data it is a good idea to get a sense of the data. Which is NOT a command for getting a sense of the data? a. dim() b. names() c. outline() d. head() e. tail() f. summary()

outline()

What does the s in sapply stand for in R?

simplify

What is a way to confirm that some time has passed between when creating an object and the current time?

sys.time()>t1 sys.time()-t1

How do you create a variable called tf that gets the result of num_vect<1

tf<- num_vect<1

What does using double quotes tell R?

that something is a character string

What will typing dev.cur() show you?

the current plotting device, the screen

What does "!" give us?

the negation of a logical expression

What does dim() function in R tell us?

dimensions

2.) Which of the following evaluates to FALSE? a. 9 < 10 b. !(0 >= -1) c. !FALSE d. 7 != 8

!(0>=-1)

When presented with a claim that something is good, what should you always ask?

"Compared to what?"

What does the abline command do?

"adds one or more straight lines through the current plot"

When using dim() with a data frame, what does the first return value tell you?

# of rows

Anytime you have questions about a particular function, you can access R's built-in help files via what command?

'?'

What command should you run to see what graphics devices are available on your system?

(This one i have no clue y'all)

1.) Which of the following evaluates to TRUE?? a. 7 == 9 b. 9 >= 10 c. -6 > -7 d. 57 < 8

-6>-7

What would be the output of creating x<-c(44,NA,5,NA) and then multiplying it by 3?

132, NA, 15, NA

What would be the result of typing 15:1 at the prompt?

15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1

What do you get if you pass the argument c(2,4,50) to the mean() function?

3.666667

To assign the result of 5 + 7 to a new variable called x, what should you type?

<-

Since NA is not a value, but rather a placeholder for an unknown quantity, what does the expression NA>0 evaluate to?

A vector of all the positive elements of y

What will typing getwd() do in R?

Determine which directory my R session is using

True or False: R automatically prevents us from asking for information that is not useful

False

True or False: Data frames can only contain a single class of data, while matrices can consist of many different classes of data

False (flip it)

True or False: If you type sample((1;6), 4, replace=True) a possible outcome could be 3 3 6 7 ?

False (not 7)

What does the l in lapply stand for?

List

Whereas sapply() tried to 'guess' the correct format of the result, what does vapply do?

allows you to specify the correct format

3.) Which one of the following expressions evaluates to TRUE? a. 99.99 > 100 || 45 < 7.3 || 4 != 4.0 b. TRUE && FALSE || 9 >= 4 && 3 < 6 c. FALSE || TRUE && FALSE d. TRUE && 62 < 62 && 44 >= 44

TRUE && FALSE || 9 >= 4 && 3 < 6

What will you get if you type Sys.Date() into R?

The computers date

True or False: Lists may contain multiple data types

True

What outcome would you expect from typing sep = " "

We want to separate the joined elements with a single space

What word is missign in this saying?: "Don't let the tool drive the [ blank ]"

analysis

What would you type if directed to "Run the R command boxplot with ppm as an input. Also specify the color parameter col equal to "blue"."?

boxplot(ppm, col = "blue")

What should you type to create a new vector that contains z, 555, then z again in that order?

c(z,555,z)

What function do you use in R to 'combine columns'?

cbind

If we are interested in determining what format the variables are being stored in a dataset, what do we type?

class(flags)

What kind of graphs are the initial step in an investigation?

exploratory graphs

How would you create a file in your working directory called "mytest.R" using the file.create() function?

file.create("mytest.R")

What does sample() function allow you to do?

generate random numbers

What do you need to type into RStudio to preview the first six lines of a dataset whose name is "flags"?

head(flags)

If at any point you'd like more information on a particular topic related to R, what can you type at the prompt?

help.start()

What function in R, generates a sample of the specified size from the data set or elements either with or without replacement?

is.na

What could you type if you wanted to know the length of a variable called my_seq?

length()

What function takes a vector of numbers as input, and returns the average of all the numbers in the input vector?

mean()

If asked to create a new variable called my_div that gets the value of z divided by my_sqrt, what would you need to type to create that variable?

my_div <- z/my_sqrt

How do you assign the value of the current working directory to a variable called "old.dir"

old.dir <- getwd()

What should you type if you want your plot shapes to be triangles?

pch = 2

What does tail() function allow you to do in R?

preview the end of the dataset

What does head() function allow you to do in R?

preview the top 6 rows of the dataset

If you want your vector to contain 10 repetitions of the vector (0,1,2) what should you type at the prompt?

rep(c(0,1,1), times=10)

What does the rep in rep() stand for?

replicate

What would you type in R if you wanted to generate 15 random numbers from a standard normal distribution?

rnorm(15)

What will typing ls() do in R?

view objects in workplace


Conjuntos de estudio relacionados

Final Practice Questions/DocCom Quizzes

View Set

U5: Agricultural and Rural Land-Use Patterns and Processes

View Set

PSY of Adulthood and Aging Test on Chpt. 5, 6 , 7 and 10

View Set