A Hadleyverse variant with some reasonable type conversion:
library(dplyr) library(tidyr) cukeDatatest %>%
Edit
Here's an equivalent version with a more typical tidyr approach. One of the problems with this approach here is the irregular number of terms in ObjectWidth , which makes it difficult to create column names, since separate annoyingly does not contain default values ββfor its into parameter.
A simple workaround here is to intentionally create more columns than you need (the rest will be filled with NA s, which will later be removed using gather ). Although the code is less efficient, the code still works instantly, so it is not enough to achieve performance. If it is, print the length of the longest string using max(sapply(strsplit(as.character(cukeDatatest$ObjectWidth), ','), length)) .
cukeDatatest %>%
If you have a fixed number of terms in each line of ObjectWidth , a simple old read.csv called by ObjectWidth inserted together is a good way. read.csv estimates the number of columns from the first five rows, which is great if the number is constant.
If this does not work (for example, for this data, where the longest line is the seventh), you come across the same name as above, which can be sorted by offering col.names set of names of the corresponding length, In this case, the same thing works workaround as above.
read.csv(text = paste(as.character(cukeDatatest$ObjectWidth), collapse = '\n'), header = FALSE, col.names = paste0('V', 1:2179)) %>% bind_cols(cukeDatatest[,-3]) %>% gather(var, ObjectWidth, starts_with('V'), na.rm = TRUE) %>% select(-var)
Both approaches return tbl_df, which is exactly equivalent to the original approach above.