zoukankan      html  css  js  c++  java
  • R 语言

    ps 帮人学习R语言
    代码:

    定义变量

    alldata<-c(32.56,1.4072,28.94,0.231,11.005,2.48713,
    40.33,1.5334,34.79,0.288,18.235,1.50838,
    41.50,1.5275,34.53,0.297,20.971,1.4819,
    44,1.5524,35.58,0.305,23.239,2.80099,
    46.33,1.6671,40.02,0.335,30.785,1.38399,
    48.23,1.7316,42.25,0.339,16.538,3.0191)

    data4<-matrix(data=alldata,nrow=6,ncol=6,byrow=TRUE,
    dimnames=list(c("1","2","3","4","5","6"),c("AR","HR","CL","a","1/b","k")))

    7-9第一种图
    library(corrplot)

    mf_cor<-cor(data4)

    col3 <- colorRampPalette(c("blue", "white", "red"))
    cor.plot <- corrplot(corr = mf_cor,col=col3(5),type="upper",tl.pos="d",tl.cex = 0.75)
    cor.plot <- corrplot(corr = mf_cor,add=TRUE, type="lower",col=col3(10),method="color",addCoef.col="black",diag=FALSE,tl.pos="n", cl.pos="n",number.cex = 0.7)

    7-21第二图
    install.packages("PerformanceAnalytics")

    library(PerformanceAnalytics)

    chart.Correlation(data4, histogram=TRUE, pch=19)


    7-21 corr
    library(psych)

    corr.test(data4, use = "complete", method = "pearson", adjust = "none")

    res <- corr.test(data4, use = "complete", method = "pearson", adjust = "none")

    res$r

    res$ci

    7-21全部代码(参考)
    states <- state.x77[,1:6]

    cor(x = states[,"Population"], y = states[,"Income"], use = "everything", method = "pearson")

    cor(states)

    cor(x = states[,"Population"], y = states[,"Illiteracy"], method = "spearman")

    cor.test(x = states[,"Population"], y = states[,"Income"])

    res <- cor.test(x = states[,"Population"], y = states[,"Income"])

    res$p.value

    res$conf.int

    install.packages("psych")

    library(psych)

    corr.test(states, use = "complete", method = "pearson", adjust = "none")

    res <- corr.test(states, use = "complete", method = "pearson", adjust = "none")

    res$r

    res$ci

    ps:参考链接

    https://blog.csdn.net/arlene_mzt/article/details/81318213
    http://www.bioinfo-scrounger.com/archives/603
    http://yangl.net/2017/06/15/r_cor/

  • 相关阅读:
    Swift如何判断上午还是下午
    Qt Creator编译app到iPhone
    用swift判断string是否包含字母
    QToolTip显示富文本问题
    mac如何发起屏幕共享?
    Redis持久化
    bean 实例化原理解析
    WebSocket和SocketIO总结
    netty入门
    redis 工具类
  • 原文地址:https://www.cnblogs.com/yuwen1995/p/11226061.html
Copyright © 2011-2022 走看看