How to mutate a new column by modifying another column?

后端 未结 1 1021
挽巷
挽巷 2021-01-26 19:06

I have very simple question. I have a df like,

df1 <- data.frame(id=c(1,2,3))

I want to add a new column by adding \'z000\' to existing id

相关标签:
1条回答
  • 2021-01-26 19:31

    You just need paste0

    df1 %>% 
    mutate(new_id = paste0("z000", id))
    
      id new_id
    1  1 z0001
    2  2 z0002
    3  3 z0003
    
    0 讨论(0)
提交回复
热议问题