Splitting is easy: strsplit(as.character(x$ID), "/")
That produces a list with four elements, each of which is a character vector. R does not have a representation for "sub-columns" so you will have to be clearer about how you want to represent the data and what you are planning to do with it. ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Sapana Lohani > Sent: Monday, August 27, 2012 1:41 PM > To: R help > Subject: [R] ?nchar ?strsplit > > Hi, my data frame is > > x<-data.frame(ID=c("abc/def","abc/def/ghi","abc","mno/pqr/st/ab")) > > I want to split my column ID using "/" as the place to split. How can I > do that without telling the code how many sub-columns. I could use > nchar(gsub("[^/]","",x$ID)) to get how many "/" are in each row of the > column, but could not use it to split ID in. > > Thanks > > [[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.