Basic R Flashcards
Write a function drawing x times with replacement from the standard normal distribution, then taking an average and printing it
myfunction
Load all functions in the R file “functions.R” in the working directory
source(“functions.R”)
Show working directory
getwd()
Show contents of working directory
dir()
Choose working directory
setwd()
Get help for the source() function
?source
Find help for linear regressions
help.search(“linear regression”)
What are the five atomic classes of objects
character, numeric, integer, complex and logical
What is the difference between a list and a regular vector
The list may contain elements of different classes, the elements of a vector all have to be the same class
Assign the integer 1 (not the number) to the object x
x
Find out what class x is
class(x)
Divide 1 by infinity
1/Inf
Give examples of object attributes
Names, dimnames, dimensions, class, length, etc.
Create an empty numeric vector x with 100 elements
x
Input the letters a, b and c as elements in a vector x
x
What happens if you concatenate elements of different classes?
They are all coerced to one class
Make a vector consisteng of the integers 1 to 10 to a character format
x
What happens if you run
x
NAs are introduced by coercion for the first and second elements