Some clarification is required on some unintended output. I tried to execute a applyfunction pastewith an argument collapsein a data frame. I cannot find anything in the documentation to explicitly suggest that this should happen, although I might miss something.
Playable example:
data <- data.frame(a = 8:11, b = c('a', 'b', 'c', 'd'), stringsAsFactors = FALSE)
apply(data, 1, paste, collapse = ' ')
Required Conclusion:
'8 a', '9 b', '10 c', '11 d'
Actual output:
' 8 a', ' 9 b', '10 c', '11 d'
It seems that in this case R fills the digits of the numbered vectors with empty space. This will not happen if you try the same call pasteoutside apply:
paste(data[1, ], collapse = ' ')
Result:
'8 a'
source
share