调试功能翻译

我试图将matrix函数参数“翻译”成葡萄牙语:

portuguese.matrix <- function(dados = NA,nlin = 1,ncol = 1,porlin = FALSE,dimnomes = NULL) {
    matrix(data,nrow,ncol,byrow,dimnames)
}

所以,我试图获得以下输出:

matrix(data = rnorm(9),nrow = 3,ncol = 3,dimnames = list(c("a","b","c"),c("d","e","f")))

            d          e         f
a  0.01874617 -0.5991677 -1.208076
b -0.18425254  0.2945451 -0.363676
c -1.37133055  0.3897943 -1.626673

这就是我得到的:

portuguese.matrix(dados = rnorm(9),nlin = 3,dimnomes = list(c("a","f")))
Error in as.vector(x,mode) : 
  cannot coerce type 'closure' to vector of type 'any'
Called from: as.vector(data)
Browse[1]> 

R studio打开一个显示以下内容的窗口:

调试功能翻译

有关如何解决此问题的任何提示?

kxkxkxkx 回答:调试功能翻译

您是否正在寻找类似的东西?

portuguese.matrix <- function(dados = NA,nlin = 1,ncol = 1,porlin = FALSE,dimnomes = NULL) {
  matrix(data = dados,nrow = nlin,ncol = ncol,byrow = porlin,dimnames = dimnomes)
 }

 set.seed(123) 
 portuguese.matrix(dados = rnorm(9),nlin = 3,ncol = 3,dimnomes =  list(c("a","b","c"),c("d","e","f")))

使用随机数函数固定输出时,可以使用set.seed(number)

我得到以下输出:

structure(c(-0.560475646552213,-0.23017748948328,1.55870831414912,0.070508391424576,0.129287735160946,1.71506498688328,0.460916205989202,-1.26506123460653,-0.686852851893526),.Dim = c(3L,3L),.Dimnames = list(
    c("a","f")))
本文链接:https://www.f2er.com/3130960.html

大家都在问