Create separate object and assign its values to rows

Welcome to the community!

You can create a object of length 1000 with first 500 as male and n
last 500 as female easily as follows:

object_name <- rep(x = c("male", "female"), each = 500)

Hope this helps.


Usually, a reproducible example is expected so that people here can visualise what do you have, what is the objective and what have you already tried. Though it is not a necessity for many questions, but it is a good practice and it is better to follow it. Please go through this guide for your next questions:

1 Like