我需要在R中创建一个将矩阵作为输入并返回列表的函数

时间:2019-02-26 14:35:53

标签: r

这是我尝试用来解决问题的代码,但是我的结果不准确。任何建议将不胜感激。谢谢

> fun1 <- function(x,y){
   ##input of the function
   x<- matrix(data = x, nrow=20,ncol =0 )
  ##get mean of rows and columns
   mean_row<- rowMeans(x)
   mean_col<- colMeans(x)
   ##create the return value y as a list
   y<- list(x, mean_row, mean_col)
   return(y)
 }

0 个答案:

没有答案