Question

I need to make sentences from a list of vectors of POS's. So I use paste with sep=' ' But this seems to have no affect on my result. Why?

listPOS <- list(c("/NN", "/PDAT", "/VVFIN", "/VVPP", "./$."), 
                c("/PPER",  "/VVFIN", "/APPR", "./$."))

# See the arrow                                           V
vecPOS <- unlist(lapply(listPOS, function(x) paste(x,sep=" ",collapse="")))

# Need vector like:
vecPOS
[1] "/NN /PDAT /VVFIN /VVPP ./$." "/PPER /VVFIN /APPR ./$."

# Get instead an vector like:
vecPOS
[1] "/NN/PDAT/VVFIN/VVPP./$." "/PPER/VVFIN/APPR./$." 
Was it helpful?

Solution

You need collapse = " " instead of sep = " ":

sapply(listPOS, function(x) paste(x, collapse = " "))
# [1] "/NN /PDAT /VVFIN /VVPP ./$." "/PPER /VVFIN /APPR ./$."
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top