I am trying to create a function that is able to calculate this sum:
a<-c(2,3,5)
b<-(8,7)
with "a" meaning 235 and "b" 87. So the result of this sum would be 235 + 87
= 322.
a <- c(2,3,5)
b <- c(8,7)
vectorToScalar <- function(x) {
as.numeric(paste(x, collapse = ""))
}
vectorToScalar(a) + vectorToScalar(b)
______________________________________________
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.