HI, Try this: dat1<-data.frame(slope=c("slope (60/25/15)","slope (90/10)","slope (40/35/15/10)","slope (40/25/25/10)" )) dat1$slope<-gsub("slope\\s+.*(\\(.*\\))","\\1",dat1$slope) dat1$slope<-gsub("\\((.*)\\)","\\1",dat1$slope) dat2<-strsplit(dat1$slope,"/") dat2[[1]][4]<-0 dat2[[2]][3:4]<-0 data.frame(do.call(rbind,dat2)) # X1 X2 X3 X4 #1 60 25 15 0 #2 90 10 0 0 #3 40 35 15 10 #4 40 25 25 10
----- Original Message ----- From: Sapana Lohani <lohani.sap...@ymail.com> To: "r-help@r-project.org" <r-help@r-project.org> Cc: Sent: Friday, August 17, 2012 1:05 AM Subject: [R] Unequal splits from a column Hi I am new to R so am struggling with the commands here I have one column in a table that looks like slope (60/25/15) slope (90/10) slope (40/35/15/10) slope (40/25/25/10) I want to have 4 columns with just the number inside the parenthesis. when there is no number that cell can have 0. I want the output like this 60 25 15 0 90 10 0 0 40 35 15 10 40 25 25 10 Can somebody help me?? 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. ______________________________________________ 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.