Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R Hmisc::描述不使用数据帧_R - Fatal编程技术网

R Hmisc::描述不使用数据帧

R Hmisc::描述不使用数据帧,r,R,我需要一个“descripe”函数来报告小数点后两位以上的值,因此我想我会使用Hmisc descripe函数,但即使使用中的示例代码,我也会得到一个错误: > dfr <- data.frame(x=rnorm(400),y=sample(c('male','female'),400,TRUE)) > Hmisc::describe(dfr) Error in UseMethod("describe") : no applicable method for 'descr

我需要一个“descripe”函数来报告小数点后两位以上的值,因此我想我会使用Hmisc descripe函数,但即使使用中的示例代码,我也会得到一个错误:

> dfr <- data.frame(x=rnorm(400),y=sample(c('male','female'),400,TRUE))
> Hmisc::describe(dfr)
Error in UseMethod("describe") : 
  no applicable method for 'describe' applied to an object of class "data.frame"
> psych::describe(dfr)
   vars   n mean   sd median trimmed  mad   min  max range  skew kurtosis   se
x     1 400 0.07 0.96   0.07    0.07 0.94 -2.41 2.76  5.17  0.02     -0.3 0.05
y*    2 400 1.50 0.50   2.00    1.50 0.00  1.00 2.00  1.00 -0.01     -2.0 0.03
dfr Hmisc::描述(dfr) UseMethod(“描述”)中的错误: 没有适用于“data.frame”类对象的“Descripte”方法 >心理学:描述(dfr) 变量n平均sd中值修剪mad最小最大范围偏斜峰度se x1400 0.07 0.96 0.07 0.07 0.94-2.41 2.76 5.17 0.02-0.30.05 y*24001.50 0.50 2.00 1.50 0.00 1.00 2.00 1.00-0.01-2.0 0 0.03
关于为什么要这样做有什么建议吗?

您试图以不受支持的方式使用
描述
。只需使用:

require(Hmisc)   # or library(Hmisc)
describe(mydataframe)
要获得更好的输出,请安装LaTeX并运行

latex(describe(mydataframe), file='')
# file='' to put LaTeX code inline as for knitr

如果尝试
方法(descripe)
,是否会看到descripe.data.frame?当我运行你发布的代码时,它工作正常。我建议清除您的环境/工作区,重新安装Hmisc,然后重试。我得到:>方法(描述)[1]描述。通过警告消息:在方法中(描述):函数“描述”似乎不是泛型>方法(Hmisc::描述)方法中的错误(Hmisc::描述):没有可访问的函数“Hmisc::descripe”在运行
安装程序包(“Hmisc”)
后是否会发生相同的情况?-如果是这样,您可能希望尝试使用
devtools
包直接下载源代码,如下所示:
install\u url('http://cran.r-project.org/bin/macosx/contrib/3.1/Hmisc_3.14-5.tgz“)
如果您不在mac上,显然要更改url。您可以使用
Hmisc:::descripe.data.frame(dfr)
,但是也没有看到print方法,所以它只是作为一个列表进行打印。+1尽管我认为OP试图避免函数名与
psych
包之间的冲突。这可以解释为什么他们要用这种方式来使用它。尝试了重启RStudio、重新加载等常规操作,现在它似乎“如广告所示”正常工作。不确定是什么错了,也许我不是R的超级粉丝意味着我错过了一些东西。不幸的是,我原来的问题还没有解决(统计数据的小数点太少),所以我用一个循环来代替,用单用途函数来计算它们