Re: [R] extraction of last observation date from many observations in each row/column

2021-04-02 Thread Sarah Goslee
Hi Marna, This very short function deletes everything before the last , if there is a comma. Some of your entries have comma-space and some just have comma, so it deletes the optional space as well. lastdate <- function(x) { sub("^.*, *", "", x) } data.frame(apply(daT, 2, lastdate)) Sarah O

[R] extraction of last observation date from many observations in each row/column

2021-04-02 Thread Marna Wagley
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(