我正在学习在r中运行线性回归。我有一个使用read.xl函数读取的简单数据集。我得到的列名很好,但是它们没有被标识为对象,因此我无法对其进行任何操作。我的列标题是Cooper_score和VO2max。
library(readxl)
library(ggplot2)
Cooper <- read_xlsx("R_Learning/Cooper.xlsx", sheet=1)
View(Cooper)
colnames(Cooper)
此位工作正常,但是当我尝试以下任何一个操作时,我都会出错
plot(Cooper_score,VO2max,xlab="Cooper Score", ylab="VO2(max)(ml/kg/min)")
cor(Cooper_score,VO2max)
simple_reg_cooper <- lm(VO2max ~ Cooper_score)
summary(simple_reg_cooper)
例如
情节中的错误(Cooper_score,VO2max,xlab =“ Cooper得分”,ylab =“ VO2(max)(ml / kg / min)”):找不到对象'Cooper_score'
和相关和线性回归函数相同
要访问数据框中的列,请使用$
符号,例如Cooper$score
将访问名为score
的列(区分大小写)。