I have a very simple line of code I would like to run. I am creating this vector:
x1<- rep("T", 576)
However, I derived the number 576 from this line of code:
dim(x)
(x is a dataframe which is 576 rows long)
I need to create vectors similar to x1 for many other other data frames which are all of varying dimensions. I do not want to have to manually type the dimension value into the rep formula every time. Is there a way to combine these two formulas into one?
Try dim(x)[1]
or nrow(x)
to extract the dimension and feed into your call:
x1 <- rep("T", nrow(x1))