私は R プログラムを使い始めたばかりで、自分のプログラムの何が問題なのかを理解するのに苦労していました。ファイルを R プログラムにインポートしましたが、'corn' と 'cotton' の平均と標準偏差を求めようとすると、'object 'corn' not found' と 'object 'cotton' not found' というエラーが表示され続けます。以下は、私のプログラムの冒頭と、インポートした .txt ファイルです。
rm(list=ls(all=T))
# data
detach(data)
data<-read.table("D:/stalkeyedflies.txt", header=T)
attach(data)
data
names(data)
summary(data)
# mean and standard deviation of corn
mean(corn)
sd(corn)
# mean and standard deviation of cotton
mean(cotton)
sd(cotton)
.txt ファイルは次のようになります。
Treatment eye.span
corn 2.15
corn 2.14
corn 2.13
cotton 2.12
cotton 2.07
cotton 2.01
よろしくお願いします!