sorry, i let toto$Date in the function within lapply() instead of x$Date !
now, it works :
> toto
Num Date Place X Y
1 1 1/1/04 0:48x1 1 1
2 2 1/1/04 8:02x1 NA NA
3 4 1/1/04 1:55x4 3 7
4 3 1/1/04 2:14x3 2 9
5 4 1/1/04 1:19x4 3 7
6 4 1/1/0
Thank you very much for your help but I think there is an error for the
answer to the first problem I spent time on searching the solution but
I failed to find it. I tried to put "which.max" instead of "which.min"
but it doesn't work. I tried to do my best but i didn't have any idea to
solve t
OK ! so try this:
merge(toto[1:3], unique(na.omit(toto[3:5])),by="Place",all.x=T)
Florent Bonneu a écrit :
> Indeed,
> X <- c(1,Na,2,3,3,3,6,6)
> Y <- c(1,Na,9,7,7,7,8,8)
>
> I want to obtain one line for each Num. It's not a problem if there
> are several lines for the same place, because my i
Indeed,
X <- c(1,Na,2,3,3,3,6,6)
Y <- c(1,Na,9,7,7,7,8,8)
I want to obtain one line for each Num. It's not a problem if there are
several lines for the same place, because my identifier is Num. I just
want to get X and Y well-informed in an other line for the same place.
For example, "Num=2" is
something wrong in X and Y definitions... but this could work:
do.call("rbind", lapply(split(toto, toto$Num),
function(x) x[which.min(as.POSIXct(strptime(toto$Date, "%d/%m/%y
%H:%M"))),]))
i don't understand the second query; do you want to keep the first line
when there are several lines f
I have two problems for the data processing of my large data base (5 rows).
For example, a sample is as follows
Num <- c(1,2,3,4,4,4,5,5)
Date <- c("1/1/04 0:48","1/1/04 1:52", "1/1/04 1:55", "1/1/04 2:14", "1/1/04
3:09", "1/1/04 8:02", "1/1/04 9:05", "1/1/04 9:06")
Place <- c("x1","x1","x3"