1
我的問題是關於$運算符來訪問我的數據框的特定部分。
這下面是我的數據幀
structure(list(Treatment = structure(c(11L, 11L, 11L, 11L, 11L,
11L), .Label = c("Chlora", "Gen", "Lin", "Metro", "Metro+Pen",
"Metro+Rif", "Metro+Rif+Pen", "Pen", "Pen+Rif", "Rif", "Untreated"
), class = "factor"), CDW = c(0.833, 0.867, 0.833, 2.7, 3.3,
3.133), Chlorophyll = c(1.098, 1.376, 1.64, 34.714, 37.773, 40.54
), EPS = c(0.092, 0.067, 0.092, 0.571, 0.591, 0.597), Day = c(0L,
0L, 0L, 10L, 10L, 10L), TreatmentDay = structure(c(21L, 21L,
21L, 22L, 22L, 22L), .Label = c("Chlora0", "Chlora10", "Gen0",
"Gen10", "Lin0", "Lin10", "Metro+Pen0", "Metro+Pen10", "Metro+Rif+Pen0",
"Metro+Rif+Pen10", "Metro+Rif0", "Metro+Rif10", "Metro0", "Metro10",
"Pen+Rif0", "Pen+Rif10", "Pen0", "Pen10", "Rif0", "Rif10", "Untreated0",
"Untreated10"), class = "factor"), richness = c(36L, 37L, 39L,
31L, 31L, 24L), shannon = c(3.35867443756547, 3.37354007038303,
3.43640985397324, 3.16018680691703, 3.15718684762791, 2.85288614815093
)), .Names = c("Treatment", "CDW", "Chlorophyll", "EPS", "Day",
"TreatmentDay", "richness", "shannon"), row.names = c("Day0F1",
"Day0F2", "Day0F3", "Day10F1", "Day10F2", "Day10F3"), class = "data.frame")
我可以使用
Unt$richness
[1] 36 37 39 31 31 24
但是,如果我想要做的方差分析測試,我得到一個錯誤信息說我不能使用$與原子矢量
Unt_Richness_anova <- aov(Unt$richness, TreatmentDay)
所以,我覺得很困惑我可以在一個實例中使用原子向量中的$運算符,但不是另一個。 有人可以幫忙嗎?
這是什麼語言?你的問題需要更多的**標籤**。 「運營商」本身太泛泛。 –
data.frame是一種特殊類型的列表。你可以用'is.list(Unt)'來看這個。一個列表特別不是一個原子向量。你可以用'is.atomic(Unt)'來看這個。 'Unt $ richness',存儲在data.frame中的矢量是原子的,'is.atomic(Unt $ richness)'。 – lmo