How to combine multiple character columns into a single column in an R data frame

前端 未结 6 819
挽巷
挽巷 2020-12-03 01:10

I am working with Census data and I need to combine four character columns into a single column.

Example:

LOGRECNO STATE COUNTY  TRACT BLOCK
    60           


        
6条回答
  •  天命终不由人
    2020-12-03 01:54

    Try this:

    AL_Blocks$BLOCK_ID<- with(AL_Blocks, paste0(STATE, COUNTY, TRACT, BLOCK))
    

    there was a typo in County... it should've been COUNTY. Also, you don't need the collapse parameter.

    I hope that helps.

提交回复
热议问题