Skip to content

Converting a list to a data frame or columns at the least

2 messages · Farrel Buchinsky, Glen A Sargeant

#
Farrel Buchinsky-3 wrote:
Farrel,

You cannot create a matrix or data frame
by combining row vectors that are not of
the same length.  Replace the missing 
values before calling rbind() and things
should work fine.
[[1]]
[1] "(01/02/70" "00:00:00)"

[[2]]
[1] "(01/03/70"

[[3]]
[1] "(01/04/70" "08:00:00)"
+   if(length(v)<2)v[2] <- NA
+   v})
[,1]        [,2]       
[1,] "(01/02/70" "00:00:00)"
[2,] "(01/03/70" NA         
[3,] "(01/04/70" "08:00:00)"
You probably will wish to clean up
dangling parentheses and the like,
but I'll leave that to you.

Glen