R未将列标题标识为对象-从xlsx读取的数据

R未将列标题标识为对象-从xlsx读取的数据,r,excel,object,linear-regression,R,Excel,Object,Linear Regression,我正在学习在r中运行线性回归。 我有一个简单的数据集,我用read.xl函数读入。 我可以很好地获得列名,但是它们没有被标识为对象,所以我不能对它们做任何事情。 我的列标题是Cooper_分数和VO2max library(readxl) library(ggplot2) Cooper <- read_xlsx("R_Learning/Cooper.xlsx", sheet=1) View(Cooper) colnames(Cooper) 库(readxl) 图书馆(GG2) Coope

我正在学习在r中运行线性回归。 我有一个简单的数据集,我用read.xl函数读入。 我可以很好地获得列名,但是它们没有被标识为对象,所以我不能对它们做任何事情。 我的列标题是Cooper_分数和VO2max

library(readxl)
library(ggplot2)
Cooper <- read_xlsx("R_Learning/Cooper.xlsx", sheet=1)
View(Cooper)
colnames(Cooper)
库(readxl)
图书馆(GG2)

Cooper要访问数据框中的列,请使用
$
符号,例如
Cooper$score
将访问名为
score
的列(区分大小写)

要访问数据框中的列,请使用
$
符号,例如
Cooper$score
将访问名为
score
的列(区分大小写)

非常感谢。列名为
Cooper\u score
。所以,
Cooper$Cooper_score
做了一个恶作剧,谢谢。列名为
Cooper\u score
。所以
Cooper$Cooper\u score
成功了
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)