I am sure there are many good ways to do the task including taking the
data.frame out into a list of data.frames and making the change to each by
taking the nth row that matches nrow(it) and changing it and then recombining.
What follows are several attempts leading up to one at the end I find i
Sorry, that should be
> id <- c(1,2,2,2,3,4,5,5)
> last.index <- cumsum(rle(id)$lengths)
> last.index
[1] 1 4 5 6 8
of course.
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom Count
Many ways to do this, of course, but if I understand correctly ?rle
may be the simplest, because you already have the data sorted by ID.
The following little example should give you the idea. It gets the
index of the last row in each id,, which you can then use to assign
NA's or whatever:
> id <-
Hello List,
Please look at the sample data frame below:
ID date1 date2 date3
1 2015-10-08 2015-12-17 2015-07-23
2 2016-01-16 NA 2015-10-08
3 2016-08-01 NA 2017-01-10
3 2017-01-10 NA 2016-01
On 09/09/2021 11:55 a.m., mario.corr...@croalliance.com wrote:
Dear all
Our IT has installed R on a Windows PC following the manual instruction.
The installation was validated as in manual §3.3. "Testing an installation", by
using the commands
Sys.setenv(LC_COLLATE = "C", LANGUAGE = "en")
libr
Dear all
Our IT has installed R on a Windows PC following the manual instruction.
The installation was validated as in manual §3.3. "Testing an installation", by
using the commands
Sys.setenv(LC_COLLATE = "C", LANGUAGE = "en")
library("tools")
testInstalledBasic("both")
testInstalledPackages(sco
6 matches
Mail list logo