R CMD INSTALL BRugs_0.7.1.tar.gzdownload windows binaries than install it as a local package (in the menu)
more information here
my personal notepad - for all the things I used to write on pieces of paper ( which where never seen again esp. when I needed them ) ...
R CMD INSTALL BRugs_0.7.1.tar.gzdownload windows binaries than install it as a local package (in the menu)
head(trees)
Girth Height Volume 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2 4 10.5 72 16.4 5 10.7 81 18.8 6 10.8 83 19.7
my.col <- rainbow(100, start=0.3,end=0.9) ## provid an vector with colors with(trees, symbols(Girth,Height, circles=Volume/30, bg=my.col[Volume], inches=0.3)) ## plot the example plot (symbols plot)
my.old.par <- par()
par(mgp=c(-2,-1,0)) with(trees, symbols(Height, Girth, circles=Volume/30, bg=my.col[Volume], inches=0.3, main="Trees") )
par(mgp=c(-2,-3,0)) with(trees, symbols(Height, Girth, circles=Volume/30, bg=my.col[Volume], inches=0.3, main="Trees") )
par(mgp=c(-2,-3,-1)) with(trees, symbols(Height, Girth, circles=Volume/30, bg=my.col[Volume], inches=0.3, main="Trees") )
my.col <- rainbow(100, start=0.3,end=0.9) ## provid an vector with colors with(trees, symbols(Height, Girth, circles=Volume/30, bg=my.col[Volume], inches=0.3)) ## plot the example plot (symbols plot)
par(mgp=c(3,1,0),tcl=0.5) ### set mgp back to default, change tcl with(trees, symbols(Height, Girth, circles=Volume/30, bg=my.col[Volume], inches=0.3, main="Trees") )
my.dates <- as.Date(format(ISOdatetime(2000:2009,1:10,1:5,0,0,0),"%Y-%m-%d")) my.dates
[1] "2000-01-01" "2001-02-02" "2002-03-03" "2003-04-04" "2004-05-05" [6] "2005-06-01" "2006-07-02" "2007-08-03" "2008-09-04" "2009-10-05"(make sure your object is of date fromat, check it with str(your.object)
my.years <- format(my.dates,"%Y") # %y without century my.years
[1] "2000" "2001" "2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009"
my.months <- format(my.dates,"%m") my.months
[1] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10"
my.months <- format(my.dates,"%b") # %B for long form my.months
[1] "Jan" "Feb" "Mär" "Apr" "Mai" "Jun" "Jul" "Aug" "Sep" "Okt"
my.days <- format(my.dates,"%d") my.days
[1] "01" "02" "03" "04" "05" "01" "02" "03" "04" "05"
my.days <- format(my.dates,"%a") # %A for long form, %w (0-6) of %u (1-7) for number my.days
[1] "Sa" "Fr" "So" "Fr" "Mi" "Mi" "So" "Fr" "Do" "Mo"
my.days <- format(my.dates,"%j") my.days
[1] "001" "033" "062" "094" "126" "152" "183" "215" "248" "278"
my.weeks <- format(my.dates,"%U") # %W for monday = first day of the week my.weeks
[1] "00" "04" "09" "13" "18" "22" "27" "30" "35" "40"
my.days <- format(my.dates,"%x") my.days
[1] "01.01.2000" "02.02.2001" "03.03.2002" "04.04.2003" "05.05.2004" [6] "01.06.2005" "02.07.2006" "03.08.2007" "04.09.2008" "05.10.2009"
my.vector <- letters[1:10] # vector of a...j my.vector
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
my.index <- rep(c(TRUE,FALSE),5) # the subscript vector (of length 10) my.index
[1] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
my.vector[my.index]
[1] "a" "c" "e" "g" "i"
short.index <- c(T,F) # T is the same as TRUE, F as FALSE short.index
[1] TRUE FALSE
my.vector[short.index] # has the same result as above
[1] "a" "c" "e" "g" "i"
short.vector <- letters[1:3] short.vector
[1] "a" "b" "c"
my.index <- rep(c(T,F,NA),2) my.index
[1] TRUE FALSE NA TRUE FALSE NA
short.vector[my.index]
[1] "a" NA NA NA
named.x <- 1:10 # produce a vector containing the numbers 1...10 named.x # has no names yet
[1] 1 2 3 4 5 6 7 8 9 10
named.x["one"]
[1] NA
names(named.x) <- c("one","two","three","four","five","six","seven","eight","nine","ten") named.x
one two three four five six seven eight nine ten 1 2 3 4 5 6 7 8 9 10
named.x["one"]
one 1
names(named.x)<-rep(c("one","two","three","four","five"),rep(2,5)) named.x
one one two two three three four four five five 1 2 3 4 5 6 7 8 9 10
named.x[c("one","two","three")]
one two three 1 3 5
named.x["twenty"]
<NA> NA
named.x[c("one",NA,"three")]
one <NA> three 1 NA 5
named.x[names(named.x) %in% c("one","two")]
one one two two 1 2 3 4
install.packages("XML", repos = "http://www.omegahat.org/R")
myl <- list(one=10,two=20,three=30) myi <- "one"
one
myl[c(1,2)]
10 20
myl[myi]
10
myl["on"]
myl[[1]]
10
myl[[myi]]
10
myl[["on"]]
myl$two
20
myl$myi
myl$on
10
myv <- 1:10 myi <- c(2,4,7) myv[myi] myv[c(2,4,7)]
[1] 2 4 7 [1] 2 4 7
myv[c(1,11,3)]
[1] 1 NA 3
myv[c(1,11,NA)]
[1] 1 NA NA
myv[c(1,2,0,3)]
[1] 1 2 3
myi <- numeric() myv[myi]
integer(0)
v <- rnorm(20) myi <- seq(2,length(v),by=2) myi v[myi]
[1] 2 4 6 8 10 12 14 16 18 20 [1] 0.35380115 -0.02156840 -1.51804278 0.38278037 0.03867578 -1.25803279 [7] 0.62863255 0.07111270 -0.73416837 0.18966622
myv[-c(1,2,0,3)]
[1] 4 5 6 7 8 9 10
myv[-c(1,NA,3)]
Error in myv[-c(1, NA, 3)] : nur Nullen dürfen mit negativen Indizes gemischt werden
myv <- 1:10 myi <- numeric() myv[-myi]
integer(0)
to be continued... (most parts taken from Gentleman, R Programming for Bioinformatics) …