简体   繁体   English

R cran中的hist与直方图函数

[英]hist vs histogram function in r cran

I was able to make a nice looking histogram by accidentally using a function "histogram" (eg, histogram(myvector)) in R. I closed out of R, opened the same script 5 minutes later on the same computer, and now R is telling me no function found. 通过不小心在R中使用函数“ histogram”(例如histogram(myvector)),我能够制作出美观的直方图。我关闭了R,5分钟后在同一台计算机上打开了相同的脚本,现在R为告诉我找不到功能。 The function hist(), which I usually use, gives a slightly different looking histogram in terms of placement of axis labels and using frequency rather than percent on the y axis. 我通常使用的函数hist()在轴标签的位置以及使用频率而不是y轴百分比方面给出了看起来略有不同的直方图。

Just curious! 只是好奇!

The hist function is part of base R: hist函数是基数R的一部分:

R> hist
function (x, ...) 
UseMethod("hist")
<bytecode: 0x28fd968>
<environment: namespace:graphics>

The histogram function is (more than likely) part of the lattice package 直方图函数是(很可能是)网格包的一部分

R> library(lattice)
R> histogram
function (x, data, ...) 
UseMethod("histogram")
<environment: namespace:lattice>

Did you load lattice package? 你有装格子包装吗? If not, what packages did you load? 如果没有,您加载了哪些软件包? Look at your .Rhistory file if you can't remember. 如果您不记得,请查看您的.Rhistory文件。 Alternatively, you can search all possible packages using ??histogram 或者,您可以使用??histogram搜索所有可能的软件包

The mystery histogram function was probably in package lattice (though there are literally hundreds out there). 神秘的histogram功能可能在包装lattice (尽管实际上有数百个包装lattice )。 Did you do library("lattice") in your earlier session? 您在先前的课程中是否做过library("lattice")

If you type 如果您输入

??histogram

at the R prompt it gives you a list of all the packages with a function named histogram. 在R提示符下,它会为您提供所有带有名为histogram的函数的软件包的列表。 The one you were using was probably from lattice. 您正在使用的那个可能来自格子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM