How do you paste list of items in R

前端 未结 1 1281
花落未央
花落未央 2020-12-04 00:59

How do you paste list of items and get the result as shown below?

 mylist<- list(c(\"PDLIM5\", \"CBG\"), c(\"PDLIM5\", \"GTA\"), \"DDX60\")
相关标签:
1条回答
  • 2020-12-04 01:08

    you can try:

    sapply(mylist, paste, collapse=":")
    #[1] "PDLIM5:CBG" "PDLIM5:GTA" "DDX60"   
    

    The result is a vector.

    If you want to further paste the result, you can do:

    paste(sapply(mylist, paste, collapse=":"), collapse=" ")
    #[1] "PDLIM5:CBG PDLIM5:GTA DDX60"
    
    0 讨论(0)
提交回复
热议问题