79306358

Date: 2024-12-24 19:25:57
Score: 1
Natty:
Report link

If your only concern is that your function returns a matrix then regardless of what your preceding data types/structures are you could always just finalize the output as a matrix unless you need the preceding data processing to work with a matrix structure, which doesn't sound the like problem at all.

see fundamental example below:

x <- c(1:5)
y <- c(6:10)

foo <- function(x, y){
  z <- cbind(x,y)
   return(as.matrix(z))
}

z <-foo(x,y)
z
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user28876813