I\'ve got a data frame that\'s got the following form
pages count
[page 1, page 2, page 3] 23
[page 2, page 4] 4
[p
My "splitstackshape" package has a function that addresses this kind of problem. The relevant function in this case is concat.split and works as follows (using "myDat" from Ricardo's answer):
# Get rid of "[" and "]" from your "pages" variable
myDat$pages <- gsub("\\[|\\]", "", myDat$pages)
# Specify the source data.frame, the variable that needs to be split up
# and whether to drop the original variable or not
library(splitstackshape)
concat.split(myDat, "pages", ",", drop = TRUE)
# count pages_1 pages_2 pages_3
# 1 23 page 1 page 2 page 3
# 2 4 page 2 page 4
# 3 12 page 1 page 3 page 4