Tab autocompletion of commands
Ctrl + Enter execute current/selected line(s)
Ctrl + ↑ autocomplete from history
A <- B of A=B store objects/values/string (B) in variables (A) (<- = operator)
A ask what is stored in variable A
TRUE of FALSE = logical
“Hi”, “1”, etc = character (“…”)
5, 1 e5 = numeric
class(…) check the type of object (logical, character, numeric)
is.<type>(…) check if it is a certain type of object (<insert type of object>)
as.<type>(…) convert the type of object (integer, character, factor, etc)
Vectors homogeneous
c(…, …, …) create/combine
…:… create numerical ranges (vb. 1:7)
A […] access elements using indices or names (vb. vec [2]) --->
A [[…]] access elements to remove attributes
A[-…] use negative indices to invert selection
A^2 squares vectors
A>3 compares vectors to 3 TRUE or FALSE
Lists heterogeneous
list1 <- list(num/char/lgl = …) create list (lgl = T of F)
list12 <- c(list1, list2) combine lists
list12[…] retain list structure
list12[[…]] access object inside list
list12$list1$char accessing by name
sapply(…, class) (list, function) ---------------------------->
names(my_list) <- c(“”, “”,) name lists
my_list[[2]][2] access entries inside object stored inside list
Matrices homogeneous
mat <- matrix(1:10, ncol = 3) create matrix function (ncol = aantal kolommen)
Surround expression with ‘(…)’ to immediately obtain the output ( A <- matrix(1:10, ncol = 3) )
mat[row, column] access certain row(s) and/or column(s) (vb. mat[2,3])
mat[c(rows), c(columns)] access multiple rows and/or columns (vb. mat[c(1,3), c(1,2)] or mat[2:4, 1:3])
Data frames heterogeneous
( data_frame <- data.frame(name = c(“John”, “Jane”, “Karen”), age = c(29, 15, 56), married = c(F, F, T) )
data_frame[data_people$married == TRUE, ] accessing using comparisons oid
mean(1:6) mean of numerical range
ln (x) gebruik log() gewone log = log10()
access dataframes with $ and the variable name/column name
ICT practical 1 (ma 2-9)
library(‘…’) check if package is already installed
install.packages(‘…’) install a package
library(…) load installed package
seq(…) generate a sequence (vb. seq(from, to, by) seq(0, 10, 0.1)
plot(x = …, y = …, ↓)
type = ‘…’ type of plot (vb. ‘p’ = points, ‘l’ = lines, etc)
main = “…” main title of plot
sub = “…” subtitle (at bottom)
xlab = “…” title for x-axis
ylab = “…” title for y-axis
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller bfw1620. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.75. You're not tied to anything after your purchase.