Re: [R] Sum two Vectors of different length

2012-08-03 Thread arun
Hi, Please check this link: (http://r.789695.n4.nabble.com/calculations-with-vectors-of-unequal-length-td3477848.html) A.K. - Original Message - From: Alaios To: R help Cc: Sent: Friday, August 3, 2012 9:13 AM Subject: [R] Sum two Vectors of different length Dear all, in one part

Re: [R] Sum two Vectors of different length

2012-08-03 Thread Jessica Streicher
Actually this might be shorter for working with indices: v1[names(v1)%in%names(v2)]+v2[names(v2)%in%names(v1)] On 03.08.2012, at 15:41, Petr PIKAL wrote: > Hi > > Your description is quite long but almost uninformative about what you > really want. > > You do not say which values you want to

Re: [R] Sum two Vectors of different length

2012-08-03 Thread Jessica Streicher
Is the Index of what you cut off or add unimportant or do you have indices on which to compare them? If you just want to have the same length, not depending on any indices: v1<-1:9 v2<-1:10 minlength<-min(length(v1),length(v2)) v1[1:minlength]+v2[1:minlength] If indices are important: names(v

Re: [R] Sum two Vectors of different length

2012-08-03 Thread Petr PIKAL
Hi Your description is quite long but almost uninformative about what you really want. You do not say which values you want to sum but you say it is completely equal which value you want to add to what and what shall be the final vector length Based on this I would just use simple "+" x<-1:

[R] Sum two Vectors of different length

2012-08-03 Thread Alaios
Dear all, in one part of my code I want to sum two vectors element-wise the problem is that either the 1st vector or the 2nd vector always have one or two less elements example of my problem In TotalVector + (datalist2[[1]]$dataset$Results[[j]]$Results[[time]]$Sweep) :   Länge des längeren Objek