[R] finding an observation with similar characteristics

2009-11-04 Thread slurpy
Hi. I have a data frame with 2 variables (x & y). For each row(i) I need to find an alternate row(j) with similar x & y by sub-setting such that 0.5x[i] <= x(j) <= 1.5x[i], and then choosing the minimum y[i]-y[j] from that subset. I am currently implementing this using a for loop: test<-data.fram

[R] order of interaction coeff in lm

2009-10-18 Thread slurpy
Hi. I haven't found this question asked elsewhere, so I hope I am not missing something trivial. y<-rnorm(1:10) x1<-rnorm(1:10) x2<-rnorm(1:10) x3<-rnorm(1:10) x4<-rnorm(1:10) reg<-lm(y~x1*x2+x3+x4) summary(reg) The output of this puts x1:x2 after x3 and x4. In my case this is very cumbersome b

[R] paste command with new line separator

2008-11-17 Thread slurpy
Win xp sp2, R v2.7.1 Hi. If I have two numeric columns in a data frame, I can use the paste command to combine them into a new column separated by a comma. c3=paste(c1,c2,sep=',') gives: 1 1 -> "1,1" Is there any way I can use a new line (\n) as a separator? i.e. 1 1 -> 1 1 I tried paste

[R] r2html output gives "NULL"

2008-11-15 Thread slurpy
Win xp sp2, R v2.7.1, R2HTML v1.59 Hi. I have tried searching this extensively but to no avail. While using the R2HTML package, everytime I use HTMLStart() followed by HTML.title or HTML functions, I get a "NULL" in the output. For instance, > HTMLStart(outdir='dir name',filename="file",exten