[R] generate levels with different number of replications with gl() function

David Barron dnbarron at gmail.com
Wed Feb 10 11:42:50 CET 2016


Why not use rep instead of gl:

levels <- c('BR', 'CNS', 'CO', 'LE', 'ME', 'LC', 'OV', 'PR', 'RE')
reps <- c(4, 6, 7, 6, 10, 9, 7, 2, 8)
rep(levels, reps)

David

On 10 February 2016 at 05:02, hehsham alpukhity via R-help <
r-help at r-project.org> wrote:

> I am trying to use the function gl (generate levels with different number
> of replications), generate different number of replications in each
> level.examplei have factor with this levels (BR,CNS ,CO,LE,ME,LC,OV,PR,RE),
>  and the replications is not the same , i want (4 replication for BR),( 6
> replications for
> CNS,7 replications for CO,6 for LE,10 for ME,9 for LC,7 for OV, 2 for PR
> ,and 8 for RE).thank you v much . Hisham AL-bukhaiti  Ph.D
> Student (Information system )  China, changsha,Hunan university.  Mobile:
> 0068-15 111 4246 91.
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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]]



More information about the R-help mailing list