I have a small question about apply functions.
For example I have:
l <- list(a = data.frame(A1=rep(10,5),B1=c(1,1,1,2,2),C1=c(5,10,20,7,30)),
b = data.frame(A1=rep(20,5),B1=c(3,3,4,4,4),C1=c(3,5,10,20,30)))
I want to find a minimum C1 for each B1. The result should be
$a
A1 B1 C1
10 1 5
10 2 7
$b
A1 B1 C1
20 3 3
20 4 10
I know how to do it with ‘for’, but it have to be a easier way with ‘lapply’, but I couldn’t make it works.
Please help
Here’s another approach that matches your desired output: