[R] extraction of last observation date from many observations in each row/column
Marna Wagley
m@rn@@w@g|ey @end|ng |rom gm@||@com
Fri Apr 2 16:14:40 CEST 2021
Dear R-Users,
I have a dataset containing more than two observation dates in some of the
columns and sites but I wanted to extract only the last date of the
observation.
Is there any easiest way to get that last observation in each column/row?
Here is the example data:
daT<-structure(list(ID = c("M3", "M5", "M1"), Site1 =
c("12/20/2018,12/28/2018",
"12/17/18", ""), Site2 = c("", "", "1/19/2019"), Site3 = c("9/25/2019", "",
"1/10/2019, 1/11/2019, 1/17/2019")), class = "data.frame", row.names =
c(NA,-3L))
#I wanted to make the table like this:
output<-structure(list(ID = c("M3", "M5", "M1"), Site1 = c("12/28/2018",
"12/7/2018", ""), Site2 = c("", "", "1/19/2019"), Site3 = c("9/25/2019",
"", "1/17/2019")), class = "data.frame", row.names = c(NA, -3L))
Thank you for your help.
Sincerely,
MW
[[alternative HTML version deleted]]
More information about the R-help
mailing list