[R] Reshaping columns

R. Michael Weylandt michael.weylandt at gmail.com
Sat Jun 9 16:06:49 CEST 2012


Perhaps something like this:

x <- c("110000", "001100", "001001") # Test data

strsplit(x,"") # See what strsplit does

do.call(rbind, strsplit(x,"")) # Now combine the list elements nicely.

Incidentally, your question was grossly malformed, involving both
incomplete data and that in a non-reproducible form. If you would be
so kind as to use dput() [as suggested by the posting guide] to make a
useful test data set next time, that'd be much appreciated. [And you
could get help that is more tailed to your problem instead of my
general-ish solution here]

Michael

On Sat, Jun 9, 2012 at 5:21 AM, efulas <ef_ulas at hotmail.com> wrote:
> Dear all,
>
>
> I have a data frame with 2 columns and 102500 rows. The data looks like
> below
>
>
> V1        V2
> 8098 110000.......
> 9099 001100.......
> 0023    110011.......
> 6545    111111.......
> .             .
> .             .
> .             .
> .             .
> .             .
>
>
> I want to split the colums like this ;
>
> V1      V2     V3  V4  V5  V6  v7
> 8098    1      1      0   0     0    0 ......
> 9099    0      0      1   1     0    0 .......
> 0023    1      1      0   0     1    1 .......
> 6545    1      1      1   1     1    1 .......
> .             .      .       .       .     .      .
> .             .
> .             .
> .             .
> .             .
>
>
> Is there anyway to do this in R.
>
>
>
> Many Thanks
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Reshaping-columns-tp4632875.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.



More information about the R-help mailing list