HI, Slightly different way to do this:
dat1<-readLines(textConnection("Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) ")) dat2<-data.frame(dat1) dat3<-data.frame(Name=dat2[2:5,],slope=dat2[2:5,],percentage=dat2[2:5,]) dat3$Name<-gsub("(.*Complex)\\s-\\s(.*slope).*(\\(.*\\))","\\1",dat3$Name) dat3$slope<-gsub("(.*Complex)\\s-\\s(.*slope).*(\\(.*\\))","\\2",dat3$slope) dat3$percentage<-gsub("(.*Complex)\\s-\\s(.*slope).*(\\(.*\\))","\\3",dat3$percentage) dat3 # Name slope percentage #1 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) #2 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) #3 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) #4 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) A.K. ________________________________ From: Sapana Lohani <lohani.sap...@ymail.com> To: arun <smartpink...@yahoo.com> Cc: R help <r-help@r-project.org> Sent: Thursday, August 16, 2012 7:08 PM Subject: Re: [R] How to extract from a column in a table? Thank you :) ________________________________ From: arun <smartpink...@yahoo.com> To: Sapana Lohani <lohani.sap...@ymail.com> Cc: R help <r-help@r-project.org> Sent: Thursday, August 16, 2012 1:06 PM Subject: Re: [R] How to extract from a column in a table? Hi, Forgot the last part. colnames(dat3New)<-c("name","slope","percentage") dat3New name slope percentage 1 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 2 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 3 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) 4 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) A.K. ----- Original Message ----- From: Sapana Lohani <lohani.sap...@ymail.com> To: "r-help@r-project.org" <r-help@r-project.org> Cc: Sent: Thursday, August 16, 2012 2:41 PM Subject: [R] How to extract from a column in a table? Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) 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.