Re: [R] Stuck with levels while reassigning dataframe colnames?

2012-02-02 Thread jjap
Thanks for the advice, df-read.table(infile, sep=, skip = 1, header=TRUE) is indeed much cleaner from the outset (and was my usual way to it). I was unaware that readLines(infile, n=1) could get me the first line without reading the whole file again. But I do need to get my head around

[R] Stuck with levels while reassigning dataframe colnames?

2012-02-01 Thread jjap
Dear users, I am importing a csv file whose first row is a single value that I need to capture in a variable. infile-file.choose() in-read.csv( infile, header=FALSE) single.value-as.character(in[1,1]) # fine Now I need to take rows 3 and on as the data df-in[3:dim(in)[1],] But row 2

[R] ddply - how to transform df column in place

2011-08-23 Thread jjap
Dear R-users, I am trying to get the plyr syntax right, without much success. Given: d- data.frame(cbind(x=1,y=seq(20100801,20100830,1))) names(d)-c(first, daterep) d2-d # I can convert the daterep column in place the classic way: d$daterep-as.Date(strptime(d$daterep, format=%Y%m%d)) # How to

[R] lattice panel.abline use

2011-08-12 Thread jjap
Dear R-users, I am unsuccessful in trying to add an horizontal line to all graphs in the example below: library(lattice) val-runif(15) x-rep(seq(1:5),3) type-c(rep(a,5), rep(b,5), rep(c,5)) xyplot(val ~ x | type, panel.abline(h=.6)) Any hints are appreciated. Best regards, ---Jean -- View

Re: [R] Plotting a quadratic line on top of an xy scatterplot

2011-04-11 Thread jjap
Hi, Is it just me or it appears the temperature and probability should be reversed? Anyhow it should help you to assign your model to a variable (as Joshua did with his own suggestion) yourmodel -lm(x[,2] ~ x[,1] + I(x[,1]^2)) # again, taking literally the way you formulated it... And

[R] Simple but elusive - expand back from counts

2011-03-29 Thread jjap
Dear R-users, This should be simple but still eludes me: Given the following tmp-as.data.frame(matrix(c(44, 10, abc, 1, 44, 10, def, 1, 44, 12, abc, 2), 3, 4, byrow=T)) I want to expand the data to the following form: V1 V2 V3 V4 1 44 10 abc 1 2 44 10 def 1 3 44 12 abc 1 4 44 12 abc 1

Re: [R] Simple but elusive - expand back from counts

2011-03-29 Thread jjap
Many thanks to all, the first 3 solutions worked nicely but I did not get around to tweaking properly the others. It's really nice to get thing going in a one liner or about... Again greatly appreciated. Cheers! -- View this message in context: