Hi,
I am using the following to calculate mean and SD at the same time:
mean_sd <- function(msd)
return(c(mean(msd), sd(msd)))
mean_sd(mtcars$mpg)
[1] 20.090625 6.026948
The result is enough for me, but I am still curious why the following is not working. I am just trying to print 'mean=' and 'SD=' before the corresponding values.
mean_sd <- function(msd)
return(print(paste0(mean= c(mean(msd)), paste0(SD=sd(msd)))))
I am a new user of the paste function, so I am not sure if the code is wrong or if using paste is not permitted in this context.
Please let me know if you have any idea.
Thank you.