I need to transpose a df in R and the aggregtion function has to be min.
Example:
library(reshape2)
N <- 20
df <- data.frame(rutcli=sample(101:103, N, replace=T),
mes_atras=sample(1:4, N, replace=T), pay_day=sample(1:30, N, replace=T))
s<-dcast(df, rutcli ~ mes_atras, fun.aggregate = min, value.var = 'pay_day')
View(s)
But I get a warning:
Warning message: In .fun(.value[0], ...) : no non-missing arguments to min; returning Inf
And the results are not the desired:
rutcli 1 2 3 4
101 1 1 Inf 1
102 Inf 2 14 8
103 3 6 2 25
How can I solve this?
Thanks
dput) or set a random seed, to make your desired results reproducible. - Matthew Lundberg