0

I seem to have problems converting a list to a dataframe in R. i used the following code to calculate a cumsum:

kaka_final <- kaka_final %>% group_by(id) %>% 
        mutate(cumCost = order_by(month, cumsum(cost)))

Worked perfect but returns a list and not a dataframe as i need in the next method. So i used the as.data.frame function but that doesn't seem to work either it still returns a list:

kaka_final <- as.data.frame(kaka_final %>% group_by(id) %>% 
    mutate(cumCost = order_by(month, cumsum(cost)))) 
> 
> B <- as.data.frame(kaka_final)
> 
> typeof(kaka_final)
[1] "list"
> typeof(B)
[1] "list"

what am i doing wrong here?

0 Answers0