Something along these lines might do the trick:

     orig <- rep(sapply(seq(from=11111111, to=44444444, by=11111111),
as.character), times=c(1, 2, 3, 4))

I've shortened the number of repetitions, so you can test it out and see if
it's what you're looking for (just change the values in the vector assigned
to the "times" argument). It might be helpful to know a bit more about the
specific problem you're trying to solve though.


Kyle H. Ambert
Fellow, National Library of Medicine
Department of Medical Informatics & Clinical Epidemiology
Oregon Health & Science University

On Mon, Jan 25, 2010 at 10:46 AM, Chuck White <chuckwhite8@charter.net>wrote:

> Hello -- I would like to know of a more efficient way of writing the
> following piece of code. Thanks.
>
> options(stringsAsFactors=FALSE)
> orig <-
> c(rep('11111111',100000),rep('22222222',200000),rep('33333333',300000),rep('44444444',400000))
> orig.unique <- unique(orig)
> system.time(df <- as.data.frame(sapply(orig.unique, function(x)
> ifelse(orig==x, 1, 0))))
>
> ______________________________________________
> 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]]

