Lecture 1: Introduction to R Flashcards

1
Q

What is R?

A

A free statistical programming language developed by two New Zealanders.

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

What does R enable us to do?

A
  • Do calculations that are basic/complex
  • Undertake statistical analyses of data
  • Construct graphs from data
  • Write programs to carry out statistical analyses
  • Keep records of everything you do in an analysis
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why use R (instead of SPSS)?

A
  • It is open source
  • Extremely powerful
  • Comprehensive
  • Commonly used tool
  • Easy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the basic numerical operators?

A
^ = power
* = multiplication
/ = division
\+ = summation
- = subtraction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the logical operators?

A
& = and
| = or
! = not
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are R functions?

A

Functions undertake calculations, and require a set of parentheses after their name and the arguments listed within them.

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

What are variables?

A

They provide a way of labelling and storing information, and correspond to computer memory that is allocated to each bit of information.

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

What are the requirements for variable names?

A
  • Starts with a letter
  • Letters, periods, and numbers can be used
  • An underscore can be used but should be avoided
  • Cannot contain a space or other characters
  • Cannot be a reserved word or function e.g TRUE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Advantages of variables?

A
  • They can store multiple values

- Can be combined into data frames

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

What is a variable that contains one or more values called?

A

An atomic vector.

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

Which function creates vectors?

A

c()

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

What are the ways we can identify elements within a vector?

A
  • Position number e.g boredom [1]

- Name e.g “boredom”

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

How can we select elements?

A
  • Position number e.g boredom[-2] or boredom c(1,3)
  • Logical values e.g boredom [c(TRUE, TRUE, FALSE)]
  • Logical expressions e.g boredom[boredom
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are packages?

A

User-written collections of functions, data, and help documents that can be used in data analysis.

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

What is installing and loading a package?

A

Install: The package is in your computer
Load: The package is made available in R studio

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

What are the types of variables?

A
  • Factor variables (nominal categorical variables)

- Numeric variables (continuous variables)

17
Q

What is an R script file?

A

A text file that contains all the commands required to undertake the analysis

18
Q

How do you run a script file?

A

By using the source function.

19
Q

What are simple functions of R?

A
  • sqrt() = square root
  • round() = round a number
  • log() = logarithm
  • exp() = exponentiation
  • abs() = absolute value
20
Q

What are the variable classes?

A
  • Numeric e.g 212
  • Logical e.g TRUE
  • Character e.g “a cat”
21
Q

How do you assign a variable>

A