Hi List,
I am trying to write unsuccessfully to a logfile with cat. Here my example code:
letters[1:5]->x
logf<-"test.txt"
cat('%%\n',file=logf)
catf<-function(x,...,logfile='log.txt', append=TRUE){ cat(x,'\n', file=logfile,
append=append)}
testit<-function(x,...){
paste
Hi List,
The following code returns an "Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format"
require(raster)
require(rts)
require(stringi)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
list(ID=seq(1:24),month=rep(str_pad(1:12, pad
Thanks Jim
Still getting the same error for apply.montly
Updated code:
require(raster)
require(rts)
require(stringr)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
stack(r)->s
r->rs
for(i in 1:23){
rs[]<-r[]*i
addLayer(s,rs)->s
print(nlayers(s))
}
dt<-list(ID=seq(1:24),month=rep
Last line in the following (updated) code produces the error
require(raster)
require(rts)
require(stringr)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
stack(r)->s
r->rs
for(i in 1:23){
rs[]<-r[]*i
addLayer(s,rs)->s
print(nlayers(s))
}
dt<-list(ID=seq(1:24),month=rep(formatC(1:1
It works if you use as.Date. But this defeates the purpose for the yearmon
notion...
require(raster)
require(rts)
require(stringr)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
stack(r)->s
r->rs
for(i in 1:23){
rs[]<-r[]*i
addLayer(s,rs)->s
print(nlayers(s))
}
dt<-list(ID=seq(1
Hiya,
I am trying to assign minimum values to a dataframe based on existing columns.
I can do this via loops, but surely R has much more elegant solutions...
Here is my code:
set.seed(666)
xyz<-as.data.frame(cbind(x=rep(rpois(50,10),2)+1,
y=rep(rpois(50,10),2)+1,z=runif(100, min=-3, max=40)))
Here is another solution using interaction, aggregate and merge:
interaction(xyz[,1],xyz[,2])->nf #create a unique x.y grouping
cbind(xyz[,1:2],nf)
aggregate(xyz[,3],list(nf),min)->nmins
names(nmins)<-c('nf','mins.1')
xyz$nf<-nf
merge(xyz,nmins, by='nf', all=TRUE)->nd
head(nd)
Hi List,
Trying to update a data.frame column within a foreach nested for loop
### trial data
set.seed(666)
xyz<-as.data.frame(cbind(x=rep(rpois(5000,10),2)+1,
y=rep(rpois(5000,10),2)+1,z=round(runif(1, min=-3, max=40),2)))
xyz$mins<-rep(NA, nrow(xyz))
cl<-makeCluster(16) #adjust to your
Hiya,
Yes that would work, also an aggregate with merge can work, but I really would
like to make this a parallel calculation with farming out the first loop to
different workers and put the output together again into the data.frame with
additional columns. This will speed up work with very larg
Hiya,
This now works...
test<-foreach(i=unique(xyz[,1]), .combine=rbind, .verbose=T) %dopar% {
for( j in unique(xyz[,2])) {
xyz[xyz[,2] == j & xyz[,1] == i ,4]<-min(xyz[xyz[,2] == j & xyz[,1] ==
i,3])
nr=nrow(xyz[xyz[,2] == j & xyz[,1] == i ,4])
}
retu
Actually, you'll need to identify the values of the foreach loop in the for
loop for it to work...
require(doParallel)
require(foreach)
set.seed(666)
xyz<-as.data.frame(cbind(x=rep(rpois(5,10),2)+1,
y=rep(rpois(5,10),2)+1,z=round(runif(10, min=-3, max=40),2)))
xyz$mins<-rep(NA, nrow(
Hi List,
I am trying to assign a large expression. It has about 140 lines of code, so
of course this is cumbersome:
list('10001'=list(panel=c(PanelOne=944), seltype='Equal'),
'10002'=list(panel=c(PanelOne=454), seltype='Equal'),
'10003'=list(panel=c(PanelOne=1210), seltype='Equal'),
'10004'=list(
Hi List,
I am looking for a procedure that allows selection of variables in a clustering
attempt.
Specifically I am searching for a way of selecting out noise variables from a
set of numeric/categorical variables (or of course selecting "non-noise"
variables).
The procedure should work wit
Maybe I haven't been sufficiently clear on what I am after:
I am looking for R adaptations of approaches (relevant to hierarchical
clustering of categorical variables) described in
Steinley and Brusco 2008 "Selection of variables in cluster analysis: an
empirical comparison of eight procedure
Hi List,
I am looking for a variable selection procedure with a forward-backward
selection method.
Firstly, it is meant to work with the cophenetic
correlation coefficient (CPCC) and intended to find the variable combination
with the
highest cophenetic correlation. Secondly, it is aimed at Gower
bin/WinBugs14/winbugs.exe starts up
winbugs.
I am running opensuse 10.3 with R 2.6.2 (2007-11-26), winbugs 1.4.3 (6th
August, 2007).
Any ideas on what goes wrong?
Thanks
Herry
Dr Alexander Herr - Herry
CSIRO, Sustainable Ecosystems
Gungahlin Homestead
Bellenden Street
GPO Box 284
Crace, ACT 2601
Hi List,
I am unable to read in a 7.8Gb ascii grid using readAsciiGrid {maptools} - R
runs out of memory. I have 4Gb ram and 4Gb swap, so things are getting tight.
I am wondering if anyone has alternative options (preferably with example) that
enable to read in large grids, do some calculation
Hi List,
I am trying unsucessfully to modify the fontsize of lables in mosaic:
require(vcd)
mosaic(Titanic, pop=FALSE,
labeling_args=list(rot_labels=c(bottom=90,top=90),
set_varnames = c(Sex = "Gender"),
gp_text=gpar(fontsize=20))) #can't get it to resize text
tab <- ifelse(Tita
Thanks Patric,
mosaic{vdc} takes gpar parameters. So cex.axis does not work for
mosaic(Titanic, pop=FALSE,
labeling_args=list(rot_labels=c(bottom=90,top=90),cex.axis=0.5))
or
mosaic(Titanic, pop=FALSE,
labeling_args=list(rot_labels=c(bottom=90,top=90)),cex.axis=0.5)
However,
mosaic(Titanic, po
Hi List,
I want to print ± in a lattice graph label. This works in windows, but the
linux version has problems - it cannot translate the character. Error is
"invalid input in mbcsToLatin1".
I use the standard encoding and also dev.print(file="filename",dev=pdf,
encoding="PDFDoc.enc")
I am afr
Thanks Brian,
I got lost with the coding between windows and linux. I used the ± (Windows:
Alt-0177, instead of "\u00B1") in a code writen under windows and than used on
linux.
eg:
plot(1:10)
text(3,8,paste("±", "alt-numeric 0177 works only in windows",sep=""))
text(8,3,paste("\u00B1"," \\u00B
Hi List,
I am unsuccessfully trying to beautify barplot outputs from ctree. For
example I would like to rotate x-axis lables and resize/change
font/type.
mtree <- ctree(ME ~ ., data = mammoexp)
plot(mtree,terminal_panel=node_barplot(mtree,col="black",fill=NULL,
beside=TRUE, ylines=NULL,
22 matches
Mail list logo