geometric_mean <- function(x) { n <- length(x) prod <- prod(x) geometric_mean <- prod^(1/n) return(geometric_mean) } ``` 其中,x代表输入的数据向量,length函数用于计算数据向量的长度,prod函数用于计算数据向量所有数值的乘积,geometric_mean函数用于计算几何均数。通过上述函数,我们可以得到一组数...
geometry.mean<-exp(mean(log(x)))geo_mean<-function(data){log_data<-log(data)gm<-exp(mean(log_data[is.finite(log_data)]))return(gm)} 1. 2. 3. 4. 5. 6. 参考:http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in 也可以用psych 包里的 geometric.mean http...
pexp – Return corresponding value of exponential cumulative distribution function. pf – Return corresponding value of F CDF. pgamma – Return corresponding value of gamma cumulative distribution function. pgeom – Return corresponding value of geometric CDF. phyper – Return corresponding value of hyp...
ggplot2 基本绘图模板: ggplot(data=<DATA>,mapping=aes(<MAPPINGS>))+<GEOM_FUNCTION>(mapping=aes(<MAPPINGS>),stat=<STAT>,position=<POSITION>)+<SCALE_FUNCTION>+<COORDINATE_FUNCTION>+<FACET_FUNCTION>+<THEME_FUNCTION> 3.1.2 数据、映射、几何对象 数据(data) 数据:用于绘图的数据,需要是整洁的数据框。
qbinom(p, size, prob),quantile function 分位数函数。 分位数: 若概率0<p<1,随机变量X或它的概率分布的分位数Za。是指满足条件p(X>Za)=α的实数。如t分布的分位数表,自由度f=20和α=0.05时的分位数为1.7247。 --这个定义指的是上侧α分位数 ...
结合ddply和transform函数,降序输出并,输出编号:ddply(dfx,.(group,sex),.fun=function(x){transform(x[order(x$age,decreasing=TRUE),c(1:3)],ind=1:length(group))}) rank()——秩排序,有重复数字的时候就用这个,根据数值之间的远近输出序号 rev()——依据下标从后往前倒排数据 unique(<dataframe>)——...
Mean function in R - mean() calculates arithmetic mean. syntax and Example of R mean function. Mean of the column by group, row wise mean. mean of vector
(x = mean), data = hvf.info[not.const, ], span = loess.span ) # 2.使用模型计算的值 hvf.info$variance.expected[not.const] <- 10 ^ fit$fitted # use c function to get variance after feature standardization # 3.使用 c 函数计算feature标准化( (counts - mean)/sd )后的方差,注意sd=...
> x<-y<-seq(-2*pi,2*pi,pi/15) > f<-function(x,y) sin(x)*sin(y) > z<-outer(x,y,f) > contour(x,y,z,col = "blue") > persp(x,y,z,theta = 30,phi = 30,expand = 0.7,col = "lightblue") 1. 2. 3. 4. 5.调和...
Geometric Objects Statistical Transformations Position Adjustments Coordinate Systems 4) 图形学的分层语法 4 目标管理 1)理解ggplot2包画图的基本逻辑和原理。 2)掌握常用的5种图形,散点图、条形图、盒箱图、直方图、点线图。 3)学会用图形化思维对数据做探索、理解和表达。