Does this do what you want.
> x <- "a,b,c|1,2,3|4,5,6|7,8,8"
> x.1 <- strsplit(x, "[|]")
> x.1
[[1]]
[1] "a,b,c" "1,2,3" "4,5,6" "7,8,8"
> x.2 <- lapply(x.1, strsplit, ',')
> x.2
[[1]]
[[1]][[1]]
[1] "a" "b" "c"
[[1]][[2]]
[1] "1" "2" "3"
[[1]][[3]]
[1] "4" "5" "6"
[[1]][[4]]
[1] "7" "8" "8"
> do.call(rbind, x.2[[1]])
[,1] [,2] [,3]
[1,] "a" "b" "c"
[2,] "1" "2" "3"
[3,] "4" "5" "6"
[4,] "7" "8" "8"
>
On Thu, Dec 17, 2009 at 9:11 AM, venkata kirankumar
<[email protected]>wrote:
> Hi all,
> Hi this is kiran
> I am facing a problem to split a dataframe
>
> that is..
> i have a string like: "a,b,c|1,2,3|4,5,6|7,8,8"
> first I have to split with respect to "|"
> I did it with command
>
> unlist(strsplit("a,b,c|1,2,3|4,5,6|7,8,8", "\\,"))
>
>
> after getting that set i made it as a dataframe and it comes like
>
> a,b,c
> 1,2,3
> 4,5,6
> 7,8,8
>
> now i have to split this dataframe with respect to "," and i have to get
> it
> like
>
>
> a b c
> 1 2 3
> 4 5 6
> 7 8 8
>
>
> this one i am not able to findout
> can any one help me to get it done
>
> thanks in advance
> kiran
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.