[R] Combining Differnt columns in one single column

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Mon Jun 13 23:12:53 CEST 2022


Are you looking for this?

ID_names <- sprintf("id%05d", 1:50000)
#> [1] "id00001" "id00002" "id00003" "id00004" "id00005" "id00006"
#> [1] "id49995" "id49996" "id49997" "id49998" "id49999" "id50000"

sprintf with the format %05d pads the integers with zeros to length 5.
And you won't need to combine the 5 vectors, it already is only one.

Hope this helps,

Rui Barradas

Às 20:48 de 13/06/2022, anteneh asmare escreveu:
> Dear All, I have the following column name in different data frame and
> different size
> ID_names1 <- paste0("id0000",1:9)
> ID_names2 <- paste0("id000",10:99)
> ID_names3 <- paste0("id00",100:999)
> ID_names4 <- paste0("id0",1000:9999)
> ID_names5 <- paste0("id",10000:50000)
> Dose it possible to combine in to a single column in r?
> Best,
> Hana
> ______________________________________________
> R-help using 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.

More information about the R-help mailing list