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