举个简单例子,导入的数据框叫X,plot(X$字段名,X$字段名)这样才可以画个散点图。
我平常就是用R做数据分析,
你可以把你的详细操作代码发上来,还有导入的数据是什么样的。
cor.test(x, ...)## Default S3 method:
cor.test(x, y,
alternative = c("two.sided", "less", "greater"),
method = c("pearson", "kendall", "spearman"),
exact = NULL, conf.level = 0.95, continuity = FALSE, ...)
## S3 method for class 'formula'
cor.test(formula, data, subset, na.action, ...)
根本没有
cor.test(first,second,data= weightBJ_data)
这种调用方式,所以不识别对象first,second
你可以用
attach(weightBJ_data)
cor.test(first,second)
#或者
cor.test(weightBJ_data$first,weightBJ_data$second)
#或者
cor.test(weightBJ_data[,1],weightBJ_data[,2])
你用过attach(weightBJ_data)之后
first才能识别,但应该是没有逗号的。
first[2]
希望对你有所帮助!