Hi I have set of records seperated by a separator say "$$$" i want to get the values in a dataframe. eq qwer$$12$$qwre ewrtr$7789$ewwe I want the output as\ V1 V2 V3 qwer 12 qwre ewrtr 7789 ewwwe Please help me ----- Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-splitting-the-records-tp4650827.html Sent from the R help mailing list archive at Nabble.com.
Hi, You could do this: Lines<-"qwer$$12$$qwre ewrtr$7789$ewwe " res<-unlist(strsplit(Lines,split="\\$|\n")) ?as.data.frame(matrix(res[res!=""],nrow=2,byrow=TRUE),stringsAsFactors=FALSE) ? ? ?V1 ? V2 ? V3 #1 ?qwer ? 12 qwre #2 ewrtr 7789 ewwe A.K. ----- Original Message ----- From: arunkumar1111 <akpbond007 at gmail.com> To: r-help at r-project.org Cc: Sent: Monday, November 26, 2012 5:51 AM Subject: [R] Help in splitting the records Hi I have set of records seperated by a separator say "$$$" i want to get the values in a dataframe. eq qwer$$12$$qwre ewrtr$7789$ewwe I want the output as\ V1? ? ? V2? ? V3 qwer 12 qwre ewrtr? 7789 ewwwe Please help me ----- Thanks in Advance ? ? ? ? Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-splitting-the-records-tp4650827.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
In the example below, I don't see any "$$$" separators. Are you sure this is supposed to be the separate or just a single dollar sign? If this is the case, you don't specify what is to happen when multiple separators appear next to each other. From your example, it appears that two separators are to be treated as one? ________________________________ From: arunkumar1111 <akpbond007@gmail.com> To: r-help@r-project.org Sent: Monday, November 26, 2012 5:51 AM Subject: [R] Help in splitting the records Hi I have set of records seperated by a separator say "$$$" i want to get the values in a dataframe. eq qwer$$12$$qwre ewrtr$7789$ewwe I want the output as\ V1 V2 V3 qwer 12 qwre ewrtr 7789 ewwwe Please help me ----- Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-splitting-the-records-tp4650827.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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. [[alternative HTML version deleted]]
You state that you want "$$$" as the separator, but your example has "$$" and "$" so I'm assuming an indeterminate number of consecutive $. x <- c("qwer$$12$$qwre", "ewrtr$7789$ewwe") x <- strsplit(x, "\\$+") x <- do.call(rbind, x) x <- data.frame(x, stringsAsFactors = FALSE) x$X2 <- as.numeric(x$X2) I've also made some assumptions about what you want the output to be like, since you didn't specify, and broken it into as many steps as possible so that you can look at what functions I used and read the help files. Sarah On Mon, Nov 26, 2012 at 5:51 AM, arunkumar1111 <akpbond007 at gmail.com> wrote:> Hi > > I have set of records seperated by a separator say "$$$" i want to get the > values in a dataframe. > > eq > > qwer$$12$$qwre > ewrtr$7789$ewwe > > I want the output as\ > > V1 V2 V3 > qwer 12 qwre > ewrtr 7789 ewwwe > > > > Please help me > >-- Sarah Goslee http://www.functionaldiversity.org