再次與矩陣/ dataframes和一切相同的問題... 這次我嘗試做散點圖。我非常肯定,我將能夠做到這一點,但不幸的是,我們總是看到同樣的問題。散點圖的data.frame或矩陣
這是我的數據:
id cond S1.pre S2.pre S1.post S2.post V1.pre V2.pre V1.post V2.post
1 aer 21 31 25 35 7 1 19 4
2 aer 15 26 21 29 13 11 16 14
3 aer 18 27 23 31 8 2 3 3
4 aer 17 31 18 39 13 11 15 14
5 aer 15 26 16 29 26 15 32 20
使用的函數讀取TXT文件:
data <- read.table("Stats1.13.HW.03.txt", header=T)
> class("data")
[1] "character"
^奇怪嗎?
試圖繪製它:
plot(data2$S1.pre~data2$S2.pre~data2$V1.pre~data2$V2.pre, col="green")
Error in (function (formula, data = NULL, subset = NULL, na.action = na.fail, :
object is not a matrix
歐凱,這不是問題。讓我製作一個矩陣!
data <- as.matrix(data)
驚喜?
圖(數據$ S1.pre〜數據$ S2.pre〜數據$ V1.pre〜數據$ V2.pre,山坳= 「綠色」)
Error in data$V2.pre : $ operator is invalid for atomic vectors
如何解決我的問題與矩陣/原子向量/數字等...
歐凱,所以現在我明白如果我處理加載的數據集(不是特定的coulmns),我應該使用「」。這data2是我的錯誤,因爲我試圖以不同的方式加載數據,並將其命名爲data2。無論如何,情節公式看起來應該如何。我從網上課程中獲得了這個代碼... Thx for -2反正。:0 –
我不確定你想要在代碼中實現什麼,但是我猜你應該使用'pairs'。你可以查看我的答案瞭解詳情。 – zero323
你的幫助非常有用。感謝那。 –