Re: [R] simple loop iteration

2010-03-30 Thread Peter Ehlers
Perhaps you're just looking for the diff() function? See ?diff. -Peter Ehlers On 2010-03-30 7:15, Niklaus Hurlimann wrote: Hi R mailing list, probably a very basic problem here, I try to do the following: Q<-c(1,2,3) P<-c(4,5,6) A<- data.frame(Q,P) A Q P 1 1 4 2 2 5 3 3 6 this is my si

Re: [R] simple loop iteration

2010-03-30 Thread Henrique Dallazuanna
Try this: Reduce("-", as.data.frame(embed(A$P, 2))) On Tue, Mar 30, 2010 at 10:15 AM, Niklaus Hurlimann wrote: > Hi R mailing list, > > probably a very basic problem here, I try to do the following: > >> Q<-c(1,2,3) >> P<-c(4,5,6) >> A<- data.frame(Q,P) >> A >  Q P > 1 1 4 > 2 2 5 > 3 3 6 > > th

[R] simple loop iteration

2010-03-30 Thread Niklaus Hurlimann
Hi R mailing list, probably a very basic problem here, I try to do the following: > Q<-c(1,2,3) > P<-c(4,5,6) > A<- data.frame(Q,P) > A Q P 1 1 4 2 2 5 3 3 6 this is my simplified data.frame (matrix) now I try to create following loop for subtraction of element within the data.frame: > for(i