Dear all, I have a data.frame with a column like the x shown below myDF<-data.frame(cbind(x=c("[[1, 0, 0], [0, 1]]", "[[1, 1, 0], [0, 1]]","[[1, 0, 0], [1, 1]]", "[[0, 0, 1], [0, 1]]"))) > myDF x 1 [[1, 0, 0], [0, 1]] 2 [[1, 1, 0], [0, 1]] 3 [[1, 0, 0], [1, 1]] 4 [[0, 0, 1], [0, 1]]
As you can see my x column is composed of some strings between [[]], and using colon to separate some "fields". I need to identify the numbers of groups inside the main [ ] and call each group with different sequential string. On the example above I would like to have: A B 1 [1, 0, 0] [0, 1] 2 [1, 1, 0] [0, 1] 3 [1, 0, 0] [1, 1] 4 [0, 0, 1] [0, 1] Although here I have only two groups, my real dataset will have much more (~30). After identify the groups I would like to idenfity the subgroups: A1 A2 A3 B1 B2 1 1 0 0 0 1 2 1 1 0 0 1 3 1 0 0 1 1 4 0 0 1 0 1 Any hint are welcome. milton ribeiro [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.