1 | R: Intro Flashcards
(POLL)
SBI01 - 07 - Reading data - Which of the following command(s) load(s) data from a R package?
data
load
read.table
source
data
(POLL)
SBI01 - 08 - Which of the following data structures can store more than a single data type?
scalar
vector
matrix
list
data frame
table
list, data frame
R:
Origins of S3 and S4?
- 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.
Differences between S3 and S4 in R?
S3
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()
R:
Help in R?
?object
?cmd
help(object)
R:
In R: write code to get data from a flat file with headers
> df=read.table(‘filename’,header=TRUE)
R:
How to see all inbuilt datasets in R?
> data()
R:
Enter data via the R-console / terminal?
data.entry(x)
x = scan()
R:
How to create a vector in r ?
> xvec = c(12.2, 12, 11.8, 10, 9.5)
R:
What data types can a vector hold?
- Logical, different number types, characters…
R:
What will this do?
> LETTERS[1:4]
[1] “A” “B” “C” “D”
> L=sample(LETTERS,100,replace=TRUE)
> table(L)
- Produce a contingency table = count of how many times each letter appears
- table(s) in R are often representing counted items
R:
With which data container is nesting / embedding of containers possible?
Lists
R:
How to save all current objects in .RData without the requirement to quit the session
> save.image()
R:
R: How to see S3 methods for an object a ?
methods(a)
R:
Create an object ‘otto’ that contains information information about otto’s name, wife, children, and age
> otto=list(name=”Otto”, wife=”Maria”, children=c(“Hans”,”Katja”,”Emil”), age=32)
R:
summary() function - useful for what type of data?
useful to quickly summarize values in
- vector
- data frame
- regression model
- ANOVA model