rlads2021 / hw6

HW 6: ggplot2
https://rlads2021.github.io/hw6
0 stars 2 forks source link

有關資料的欄位名稱 #6

Open meowmeow62145 opened 3 years ago

meowmeow62145 commented 3 years ago

助教您好,想請問一下自己所抓取的資料,他的欄位只能是一個單詞嗎?像我所抓的資料他的欄位有超過 一個字的,就無法輸入。如下圖

截圖 2021-04-12 下午3 00 13
liao961120 commented 3 years ago

因為不符合命名規則,要將名稱 quote 起來:x = "Number Tested"

meowmeow62145 commented 3 years ago

因為不符合命名規則,要將名稱 quote 起來:x = "Number Tested"

我嘗試了這個方法,可是得出的結果好像是錯的

截圖 2021-04-12 下午3 08 50
liao961120 commented 3 years ago

這在 ggplot2 會比較複雜一點,要用 .data[["column name"]]

df <- tibble::tibble('x 1' = 1:10, 'y 1' = 1:10)
ggplot(data = df) + 
  geom_point(aes(x = .data[["x 1"]], y = .data[["y 1"]]))