search for: rhelpforum

Displaying 4 results from an estimated 4 matches for "rhelpforum".

2012 Feb 15
2
function similar to ddply? + calculations based on previous row
...= 1 )) I want that for a certain row, the according value of test.starty (on the row with the same number (e.g. n) ) = 1 and the according value of the row below row n of test.f ==1. How can I do this without having to loop (which I want to learn to avoid as much as possible). I tried to search on Rhelpforum already and found: http://r.789695.n4.nabble.com/How-to-calc-ratios-base-on-current-and-previous-row-td2341407.html My n+1 is based on the original value so there is should be a solution without looping but I don?t understand how I should index? I?ll illustrate what I mean with a loop to solve th...
2011 Apr 05
1
Value between which elements of a vector?
Dear R-useRs, I am looking for a why to perform the following: specialweeks<-c(0,2,5,12,18,19,20) weeks<-c(1:30) Now I would like that for every week it is even between which elements of vector special weeks it is. For weeks after 20, the value NA or 20, or even 20-30is fine. Thus for week 1: 0-2 week 2: 2-5 week 3: 2-5 week 4: 2-5 week 5: 5-12 ect.... It is not relevant if those
2011 Mar 10
2
sum of variables in function
Dear R users, Probably, this is quite a simpe question, but I do not find the proper way to obtain want I need. To explain the problem, I constructed a simple example. Suppose I have the following function: try1<-function(x){ y<-x[1:2] z<-x[3:4] y[1]*(z[1]+z[2])+y[2]*(z[1]+z[2]) } This function will be part of a for loop. This is what I like to obtain for every k: if k=2
2010 Dec 15
1
lmList and lapply(... lm) different std. errors
Am I trying to perform multiple linear regressions on each 'VARIABLE2'. I figured out that there are different ways, using the following code: (data is given at the end of this message) reg <- lapply(split(TRY, VARIABLE2), function(X){lm(X2 ~ X3, data=X)}) lapply(reg, summary) Which produces the following: $`1` Call: lm(formula = X2 ~ X3, data = X) Residuals: Min