Why doesn't the code you posted work for you? "number" appears to be a constant, so R will fill automatically the correct length. (Note that calling your data frame df leads to confusion.)
> mydf <- data.frame(a=letters[1:5], b=runif(5)) > mydf a b 1 a 0.52880425 2 b 0.02422788 3 c 0.56089766 4 d 0.99007900 5 e 0.45031033 > mydf$newcolumn <- 10 > mydf a b newcolumn 1 a 0.52880425 10 2 b 0.02422788 10 3 c 0.56089766 10 4 d 0.99007900 10 5 e 0.45031033 10 If that isn't what you want the output to look like, please provide more information. Sarah On Thu, May 10, 2018 at 9:04 AM, Marcelo Mariano Silva <marcelomarianosi...@gmail.com> wrote: > Hi, > > I am a begginer in R programming. > > I am traying to create a a column in my data frame filled down with a > number. > >> df$newcolumn <- number > > How can I do it? I am considering use rep() but in this case it is > necessary know the number of rows in each data base that I have and I would > like to do it in a faster ( and more elegant) way. > > > TKs > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ 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.