[R] Combining Differnt columns in one single column

Ebert,Timothy Aaron tebert @end|ng |rom u||@edu
Tue Jun 14 02:43:26 CEST 2022


Sorry, the last post had a small mistake. I got name and val switched. Here they are in the correct order.

ID_names1 <- paste0("id0000",1:9)
ID_names2 <- paste0("id000",10:99)
ID5 <-as.data.frame(ID_names1)
ID5$name<-colnames(ID5)
colnames(ID5)<-c("val","name")
ID6 <-as.data.frame(ID_names2)
ID6$name<-colnames(ID6)
colnames(ID6)<-c("val","name")
IDall<-rbind(ID5,ID6)


Tim
-----Original Message-----
From: anteneh asmare <hanatezera using gmail.com> 
Sent: Monday, June 13, 2022 4:49 PM
To: Ebert,Timothy Aaron <tebert using ufl.edu>
Cc: r-help using r-project.org
Subject: Re: [R] Combining Differnt columns in one single column

[External Email]

Dear Tim it works, But i want to treat them as a column name. Is it possible to treat as a column name ?

Best,
Hana
On 6/13/22, Ebert,Timothy Aaron <tebert using ufl.edu> wrote:
> ID5 <- as.data.frame(ID_names1)
> colnames(ID5)<-"val" #rename the columns so they have the same name.
> ID6 <- as.data.frame(ID_names2)
> colnames(ID6)<-"val"
> rbind(ID5, ID6)
>
> This works for the first two, just keep doing the same thing for the 
> others.
> Tim
>
> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of anteneh 
> asmare
> Sent: Monday, June 13, 2022 3:48 PM
> To: r-help using r-project.org
> Subject: [R] Combining Differnt columns in one single column
>
> [External Email]
>
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mail
> man_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAs
> Rzsn7AkP-g&m=cjCY0UmRewiKkMVVxNu2riO8k4tZHD7s7R3R6SC-bwEM5u77LyExCSIzw
> I-q7Xu_&s=xrZArAFWnJf7ja13EEgxwBj-pMBEXBYSQgc6BhtNPAA&e=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> g_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeA
> sRzsn7AkP-g&m=cjCY0UmRewiKkMVVxNu2riO8k4tZHD7s7R3R6SC-bwEM5u77LyExCSIz
> wI-q7Xu_&s=oUlYLeH_EF5rwea10resAheSjjvJ6nhUl8wT84OVXZM&e=
> and provide commented, minimal, self-contained, reproducible code.
>


More information about the R-help mailing list