R Basics - Day 1 Flashcards

1
Q

What is R?

A

A programming language used for statistical analysis, data manipulation, and visualization.

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

What is RStudio?

A

An Integrated Development Environment (IDE) for writing, running, and debugging R code.

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

How do you assign a value to a variable in R?

A

Using the ‹- operator.
(e.g., x ‹- 10)

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

What is a vector in R?

A

A sequence of elements of the same type.
[e.g., c (1, 2, 3) ]

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

How do you create a vector in R?

A

Use the c () function.
example: numbers <- c(10, 20, 30)

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

What function calculates the mean of a vector?

A

mean ()
example: mean (numbers)

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

How do you access an element in a vector?

A

Use square brackets.
example: numbers[1] gives the first element

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

How do you calculate the sum of a vector?

A

Use the sum () function.
example: sum (numbers)

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

What is a data frame in R?

A

A table-like structure with rows and columns, where each column can be a different data type.

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

How do you create a data frame in R?

A

Use the data. frame() function.

example:

names <- c(“Alice”, “Bob”)
scores <- c(85, 90)
df <- data.frame(Name = names, Score = scores)

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

How do you view the first rows of a data frame?

A

Use the head () function.
example: head (df)

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

What does the print () function do in R?

A

Outputs the value of a variable or expression to the console.

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

What does the class () function do in R?

A

Returns the data type of a variable.
example: class (numbers)

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

What does the length () function do?

A

Returns the number of elements in a vector.
example: length (numbers)

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

What is the purpose of the help () function?

A

Displays documentation for a function. example: help (mean)

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

What is a logical operator in R?

A

An operator that returns TRUE or
FALSE.
examples: <, >, ==, !=

17
Q

How do you check if all elements in a vector are greater than a value?

A

Use all ().
example: all (numbers > 5)

18
Q

How do you check if any element in a vector meets a condition?

A

Use any ().
example: any (numbers > 25)

19
Q

How do you install a package in R?

A

Use install.packages(“package_name”)

20
Q

How do you load a package in R?

A

Use library(package_name)