I'm trying to convert a list to a vector so I can attach it to a dataframe but it's throwing an error. After unlisting the list, it became shorter and I'm not sure why.
Thanks, any help is greatly appreciated.
> mongo_jr$last_state <- unlist(last_state)
Error in `$<-.data.frame`(`*tmp*`, "last_state", value = c("created", :
replacement has 203819 rows, data has 203823
> str(last_state)
List of 203823
x <- unlist(last_state)
> str(x)
chr [1:203819] "created" "created" "created" "created" "created" "created" "created" "created" ...
It turns out some of the values were null
transition_duration[sapply(last_state, is.null)] <- NA
mongo_jr$last_state <- unlist(last_state)
worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With