R geom内部条件(ggplot)
我有以下数据:R geom内部条件(ggplot),r,ggplot2,conditional-statements,R,Ggplot2,Conditional Statements,我有以下数据: df我们可以使用ifelse library(dplyr) library(ggplot2) df %>% ggplot() + geom_point(aes(x = ID, y = ifelse(heat.s == 0, value, heat), color = 'red3')) 或者我们可以先做些改变 df %>% mutate(value = case_when(heat.s == 0~ value, TRUE ~ heat))
df我们可以使用ifelse
library(dplyr)
library(ggplot2)
df %>%
ggplot() +
geom_point(aes(x = ID, y = ifelse(heat.s == 0, value, heat), color = 'red3'))
或者我们可以先做些改变
df %>%
mutate(value = case_when(heat.s == 0~ value, TRUE ~ heat)) %>%
ggplot() +
geom_point(aes(x = ID, y = value, color = 'red3'))
我们可以使用ifelse
library(dplyr)
library(ggplot2)
df %>%
ggplot() +
geom_point(aes(x = ID, y = ifelse(heat.s == 0, value, heat), color = 'red3'))
或者我们可以先做些改变
df %>%
mutate(value = case_when(heat.s == 0~ value, TRUE ~ heat)) %>%
ggplot() +
geom_point(aes(x = ID, y = value, color = 'red3'))
没有heat.s
列没有heat.s
列