Jag utgår här från Hadleys bok:
https://github.com/hadley/devtools/wiki/
Detta är samtidigt också ett litet test för att testa versionshantering med Git!
https://github.com/hadley/devtools/wiki/Introduction
Atomic vectors are logical, integer, numeric, character and raw.
x <- 1:10
mode(x) # = numeric
## [1] "numeric"
length(x)
## [1] 10
names(x)
## NULL
names(x) <- letters[1:10]
x
## a b c d e f g h i j
## 1 2 3 4 5 6 7 8 9 10
names(x)
## [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
x <- list(list(list(list())))
x
## [[1]]
## [[1]][[1]]
## [[1]][[1]][[1]]
## list()
##
##
##
str(x)
## List of 1
## $ :List of 1
## ..$ :List of 1
## .. ..$ : list()
y <- matrix(1:20, nrow = 4, ncol = 5)
z <- array(1:24, dim = c(3, 4, 5))
nrow(y)
## [1] 4
rownames(y)
## NULL
ncol(y)
## [1] 5
colnames(y)
## NULL
dim(z)
## [1] 3 4 5
dimnames(z)
## NULL
attributes bra kommando för att se all info om objekt!
f <- function(x) {
x$a <- 2
}
x <- list(a = 1)
f()
## Error: argument "x" is missing, with no default
x$a
## [1] 1
"%+%" <- function(a, b) paste(a, b)
"new" %+% "string"
## [1] "new string"
"second<-" <- function(x, value) {
x[2] <- value
x
}
x <- 1:10
second(x) <- 5
x
## [1] 1 5 3 4 5 6 7 8 9 10
%in%, match
=, <-, <<-, assign
$, [, [[, replace, head, tail, subset
with
within
all.equal, identical
!=, ==, >, >=, <, <=
is.na, is.nan, is.finite
complete.cases
*, +, -, /, , %%, %/%
abs, sign
acos, acosh, asin, asinh, atan, atan2, atanh
sin, sinh, cos, cosh, tan, tanh
ceiling, floor, round, trunc, signif
exp, log, log10, log1p, log2, logb, sqrt
cummax, cummin, cumprod, cumsum, diff
max, min, prod, sum
range
mean, median, cor, cov, sd, var
pmax, pmin
rle
function
missing
on.exit
return, invisible
&, |, !, xor
all, any
intersect, union, setdiff, setequal
which
c, matrix
length, dim, ncol, nrow
cbind, rbind
names, colnames, rownames
t
diag
sweep
as.matrix, data.matrix
c, rep, seq, seq_along, seq_len
rev
sample
choose, factorial, combn
(is/as).(character/numeric/logical)
list, unlist
data.frame, as.data.frame
split
expand.grid
if, &&, || (short circuiting)
for, while
next, break
switch
ifelse
Statistics
fitted, predict, resid, rstandard
lm, glm
hat, influence.measures
logLik, df, deviance
formula, ~, I
anova, coef, confint, vcov
contrasts
apropos(“.test$”)
beta, binom, cauchy, chisq, exp, f, gamma, geom, hyper, lnorm, logis,
multinom, nbinom, norm, pois, signrank, t, unif, weibull, wilcox,
birthday, tukey
crossprod, tcrossprod
eigen, qr, svd
%*%, %o%, outer
rcond
solve
duplicated, unique
merge
order, rank, quantile
sort
table, ftable
Working with R
ls, exists, get, rm
getwd, setwd
q
source
install.packages, library, require
help, ?
help.search
apropos
RSiteSearch
citation
demo
example
vignette
traceback
browser
recover
options(error = )
stop, warning, message
tryCatch, try
I/O
print, cat
message, warning
dput
format
sink
data
count.fields
read.csv, read.delim, read.fwf, read.table
library(foreign)
write.table
readLines, writeLines
load, save
readRDS, saveRDS
dir
basename, dirname, file.path, path.expand
file.choose
file.copy, file.create, file.remove, file.rename, dir.create
file.exists
tempdir, tempfile
download.file
Special data
ISOdate, ISOdatetime, strftime, strptime, date
difftime
julian, months, quarters, weekdays
library(lubridate)
grep, agrep
gsub
strsplit
chartr
nchar
tolower, toupper
substr
paste
library(stringr)
factor, levels, nlevels
reorder, relevel
cut, findInterval
interaction
options(stringsAsFactors = FALSE)
array
dim
dimnames
aperm
library(abind)
get är kommando för Return the value of a named object