1 | R: Intro Flashcards

1
Q

(POLL)

SBI01 - 07 - Reading data - Which of the following command(s) load(s) data from a R package?

data
load
read.table
source

A

data

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

(POLL)

SBI01 - 08 - Which of the following data structures can store more than a single data type?

scalar
vector
matrix
list
data frame
table

A

list, data frame

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

R:

Origins of S3 and S4?

A
  • S was developed at Bell Labs in the 1970s as a statistical computing language.
  • R was created in the 1990s as an open-source implementation of S.
  • Since S evolved over time, R inherited different versions of its object-oriented systems, leading to S3 and S4.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Differences between S3 and S4 in R?
S3

A

S3
- Structure: informal, no predefined structure
- Flexibility: very flexible
- Usage: simple, quick prototyping
- Class definition: assigned with class()
- Method definition: function.classname()

S4
- Structure: formal, uses slots
- Flexibility: strict and structured
- Usage: large structured applications

- Class definition: created with setclass()
- Method definition: setMethod()

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

R:

Help in R?

A

?object
?cmd
help(object)

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

R:

In R: write code to get data from a flat file with headers

A

> df=read.table(‘filename’,header=TRUE)

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

R:

How to see all inbuilt datasets in R?

A

> data()

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

R:

Enter data via the R-console / terminal?

A

data.entry(x)
x = scan()

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

R:

How to create a vector in r ?

A

> xvec = c(12.2, 12, 11.8, 10, 9.5)

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

R:

What data types can a vector hold?

A
  • Logical, different number types, characters…
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

R:

What will this do?
> LETTERS[1:4]
[1] “A” “B” “C” “D”
> L=sample(LETTERS,100,replace=TRUE)
> table(L)

A
  • Produce a contingency table = count of how many times each letter appears
  • table(s) in R are often representing counted items
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

R:

With which data container is nesting / embedding of containers possible?

A

Lists

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

R:

How to save all current objects in .RData without the requirement to quit the session

A

> save.image()

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

R:

R: How to see S3 methods for an object a ?

A

methods(a)

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

R:

Create an object ‘otto’ that contains information information about otto’s name, wife, children, and age

A

> otto=list(name=”Otto”, wife=”Maria”, children=c(“Hans”,”Katja”,”Emil”), age=32)

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

R:

summary() function - useful for what type of data?

A

useful to quickly summarize values in
- vector
- data frame
- regression model
- ANOVA model