Claudio Zanettini wrote on 08/24/2011 03:04:39 PM: > This should be easy but it does not work > I have 3 vectors*(activeT,inactT, activeR)*, > the idea is that if the last value in inactT is higher than the last in > activeT > this value has to be append in active T
When you say "this value" which one do you mean, the last value in inactT or the last value in activeT? > and the last value in another vector call activeR has to be repeated. > (at the bottom you can find the vectors) > I have done this: > > activeT=round(as.numeric(activeT)) > inactT= round(as.numeric(inactT)) > lastV<-round(as.numeric(tail(lat,1))) When I submit this line of your code, I get this error: Error in tail(lat, 1) : object 'lat' not found You didn't provide any information on the vector "lat". Jean > lastA<-round(as.numeric(tail(activeT,1))) > lastI<-round(as.numeric(tail(inactT,1))) > > if (lastV!=lastA){ > append(lastV, activeT) > lastR=tail(activeR,1) > append(activeR,lastR) > } > > lastR has been appended to activeR > but not lastV to activeV > > I guess that this is related to the attributes of the vectors this is why I > applied as.numeric at all the vectors. > > Thank you for you time and your patience > :) > Claudio > > *this are the vectors:* > > activeT > [1] 26.11 341.11 376.11 459.11 466.21 532.11 935.11 1163.11 > > [9] 1721.11 6167.11 6513.11 7114.21 7225.11 7254.11 7728.11 7964.11 > > [17] 8630.11 8803.11 9186.11 9453.11 10132.11 10669.21 11326.11 11486.11 > > [25] 11508.11 11711.11 11726.11 13450.11 13465.11 15965.11 15979.11 16324.11 > > [33] 16827.11 16959.11 17809.11 19048.21 22673.11 23268.11 32596.11 33148.11 > > [41] 46717.11 > > > inactT > [1] "316.13" "656.13" "6378.13" "8098.13" "8099.13" "10755.13" > [7] "11440.13" "15463.13" "22474.13" "22600.13" "27936.13" "27944.13" > [13] "30757.13" "32503.13" "32506.13" "32522.13" "33082.13" "51436.13" > > > > activeR > [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 > 25 > [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.