R studio Chapter 1 Flashcards

1
Q

R lab comment starts with?

A

#

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

Assign value 42 to a variable X

A

x< -42

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

The quotation marks” “ is to indicate…

A

the variable is of type character.

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

What are Numerics, integers, logical?

A

Numerics are decimal values like 4.5. Integers are also numerics but in natural numbers. Logical is boolean values like TRUE or FALSE.

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

Class()

A

It checks the type of data.

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

Is.character(v)

A

It checks if a variable is a character.

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

what are commands for coercion for taming the data?

A

as.logical(), as.numeric(), as.integer(), as.character()

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

Create a vector.

A

c( , )

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

Select the letter “a” from character_vector

character_vector (“a”, “b”, “c”)

A

character_vector [1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Select the second and the third element of boolean_vector 
boolean_vector c(TRUE, FALSE, FALSE)
A

boolean_vector [c(2,3)]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
for less than, 
for more than, 
for less than and equal to, 
for more than and equal to, 
equal to each other,
not equal to each other
A
<
> 
<=
>=
==
!=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
Print the items from numeric_vector that are larger than 10 
numeric_vector c(1, 10, 35)
A

numeric_vector [c(FALSE, FALSE, TRUE)]

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

Construct a matrix with 5 rows and 4 columns containing the numbers 1 up to 20 and assign it to the variable m. Specify the byrow argument to be TRUE

A

matrix(1:20, byrow=TRUE, nrow=5, ncol=4)

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

The term factor refers to…?
A good example of a categorical variable is?
Command for turning vector into a factor?

A

a statistical data type used to store categorical variables. Categorical variables, unlike continuous variables, have a limited range.
“student” and “not student” are two values of the categorical variable.
factor (variable)

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

functions to inspect the dataframes:
What command prints the first 6 rows of the dataframe?
What command prints the last 6 rows?
What command prints the structure of your dataframe?
What command prints the dimensions, that is, the number of rows and columns of your dataframe?
What command prints the names of the columns of your dataframe?

A
head
tail
str
dim
colnames
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a command for constructing dataframe?

A

data.frame( , , ,)

17
Q

In the dataframe named planet_df, how would you select elements in first row, and 2nd and 3rd column?

A

planet_df [1, 2:3] or planet_df [1, c(2,3)]

18
Q

In the dataframe named planet_df, how would you select all the elements on 3rd column?

A

planet_df [ , 3 ].

19
Q

What command allows you to gather a variety of objects under one name?

A

list(item 1, item 2 ,item 3 ) They can be vectors, matrices, or data frames.

20
Q

Grab the second element of my_list.

A

my_list [ [2] ]

21
Q

Grab the first column of the third component of my_list

A

my_list [ [3] ][ , 1]