我要求的功能只是爲了編程時的方便。 使用「+」運算符在ggplot2中添加圖層非常棒。特別是在中間添加圖層只是添加另一行代碼。但是,如果我想在最後一行之後添加一個圖層,則必須在最後一行附加一個「+」,如果我想再次刪除此圖層,則還必須再次刪除「+」: ggplot(df, aes(x,y,...)) +
geom_X(...) + # after this line, I can eas
這可能是一個簡單的問題,但我無法弄清楚答案。考慮一個簡單的數據幀 library(dplyr)
library(purrr)
library(magrittr)
dataframe <- data_frame(id = c(1,2,3,4),
text = c("this is a this", "this is another",'hello','what???'))
與此相關的問題裏面: Adding prefixes to some variables without touching others? 我嘗試這個解決辦法,但因爲我不知道發生了什麼事沒有分享: 數據: df1 <- data.frame("hea_income"=c(45000,23465,89522),"gea_property"=c(1,1,2) ,"win_state"=c("AB","