The stringr package might beof interest to you (and I think magrittr makes it more readable).
> library(stringr) > library(magrittr) > '10110111' %>% str_split('') %>% unlist %>% str_flatten('.') [1] "1.0.1.1.0.1.1.1" Note that the unlist is there because we are only applying this to a single string. If you were to apply this to a character vector you could loose the unlist and sapply the flatten. On Sat, May 26, 2018 at 2:09 AM, Evan Cooch <evan.co...@gmail.com> wrote: > Numbers -- thanks. Another clever trick. > > On 5/25/2018 11:54 AM, Greg Minshall wrote: > > Evan, > > > > are you really looking at numbers, or just at character strings (that, > > in your case, happen to be numbers)? if just characters, this rather > > odd combination of strsplit() and Reduce() might do the trick: > > ---- > >> x <- '10110111' > >> print(x) > > [1] "10110111" > >> y <- Reduce(function (x,y) { paste(x, y, sep=".") }, unlist(strsplit(x, > "")), init="", right=TRUE) > >> print(y) > > [1] "1.0.1.1.0.1.1.1." > > ---- > > > > cheers. > > . > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.