Hi,

 

I'm trying to collapse a character vector to strings, but I am getting
unexpected behaviors in list context:

 

A <- "a"

B <- c("b","c")

xx <- list(A=A, B=B)

 lapply(xx, paste, collaplse=".")

$A

[1] "a ."

 

$B

[1] "b ." "c ."

 

paste(B, collapse=".")

[1] "b.c"  # this is what I want

paste(A, collapse=".")

[1] "a" # this is what I want

 

Why does the list context give me back vectors? Am I missing something?

 

Thanks,

 

Xiao-Jun

 



-----------------------------------------------------------------------------
AVIS : Ce courrier et ses pieces jointes sont destines a leur seul destinataire 
et peuvent contenir des informations confidentielles appartenant a 
Biotheranostics. Si vous n'etes pas destinataire, vous etes informe que toute 
lecture, divulgation, ou reproduction de ce message et des pieces jointes est 
strictement interdite. Si vous avez recu ce message par erreur merci d'en 
prevenir l'expediteur et de le detruire, ainsi que ses pieces jointes.

NOTICE: This message and attachments are intended only for the use of their 
addressee and may contain confidential information belonging to 
Biotheranostics. If you are not the intended recipient, you are hereby notified 
that any reading, dissemination, distribution, or copying of this message, or 
any attachment, is strictly prohibited. If you have received this message in 
error, please notify the original sender immediately and delete this message, 
along with any attachments. 

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to