Oh thanks, yes now I understand. I did not realized that I did not save it.
:) 2011/8/24 Jean V Adams <jvad...@usgs.gov> > > Claudio Zanettini <claudio.zanett...@gmail.com> wrote on 08/24/2011 > 04:33:50 PM: > > > > > Thank you, this work fine, > > and is not contorted like mine:) > > In this case lastV=LastI but depending on the data that I obtain > > lastV can be = LastA. > > > > Any way it works very good:) > > > > Thank you > > very much :) > > > > > > PS: but I still do not understand what was wrong in the script that I > used, > > It was not very appropriate but it is strange that was not working, > > > The main thing you missed with your code was that you didn't "save" the > changes you made to activeT and activeR. > > In other words, instead of > > if (lastV > lastA){ > append(activeT, lastV) > lastR <- tail(activeR, 1) > append(activeR, lastR) > } > > You should have used > > if (lastV > lastA){ > activeT <- append(activeT, lastV) > lastR <- tail(activeR, 1) > activeR <- append(activeR, lastR) > } > > Jean > > > 2011/8/24 Jean V Adams <jvad...@usgs.gov> > > > > I'm still a little confused about lastV and lastI. The code you > > provide uses lastV, but your description seems to refer to lastI. > > Test out this code and see if it is doing what you want it to do. > > > > lastI > > lastA > > activeT > > activeR > > if(lastI > lastA) { > > activeT <- c(activeT, lastI) > > activeR <- c(activeR, tail(activeR,1)) > > } > > activeT > > activeR > > > > By the way, it's helpful to others if you cc r-help@r-project.org in > > any replies to keep the thread going. > > > > Jean > > > > Claudio Zanettini <claudio.zanett...@gmail.com> wrote on 08/24/2011 > > 04:05:10 PM: > > > > > > > > Sure, sorry for that I was not very clear > > > I did not mention that there was another the vector! > > > The vector lat is a vector containing both the values of activeT > > > and of inactT. > > > activeT and inactT have been created subsetting the vector lat' > > > The values are labeled such as that the decimal points indicate the > > > kind of information > > > #.11 = active responses= activeT > > > #.13 = inactive responses= inacT > > > All the values are sorted in crescent way so > > > the lastV is the last values in the vector lat (composed by the > 2vectors), > > > and so it is also the max value of all the values of activeT and > inactiveT > > > > > > this is the vector lat: > > > > lat > > > [1] "26.11" "316.13" "341.11" "376.11" "459.11" "466.21" > > > [7] "516.61" "532.11" "656.13" "935.11" "1163.11" "1721.11" > > > [13] "6167.11" "6378.13" "6513.11" "7114.21" "7165.61" "7225.11" > > > [19] "7254.11" "7728.11" "7964.11" "8098.13" "8099.13" "8630.11" > > > [25] "8803.11" "9186.11" "9453.11" "10132.11" "10669.21" "10720.61" > > > [31] "10755.13" "11326.11" "11440.13" "11486.11" "11508.11" "11711.11" > > > [37] "11726.11" "13450.11" "13465.11" "15463.13" "15965.11" "15979.11" > > > [43] "16324.11" "16827.11" "16959.11" "17809.11" "19048.21" "19098.61" > > > [49] "22474.13" "22600.13" "22673.11" "23268.11" "27936.13" "27944.13" > > > [55] "30757.13" "32503.13" "32506.13" "32522.13" "32596.11" "33082.13" > > > [61] "33148.11" "46717.11" "51436.13" > > > > > > > > > thanks for you reply :) > > > Claudio > > > > > 2011/8/24 Jean V Adams <jvad...@usgs.gov> > > > > > > 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.