Error in FUN(X[[i]], ...) : object 'variable' not found

Hello everyone. I am very much new to R. I am trying to learn with a project.
But I am continuously getting this error Error in FUN(X[[i]], ...) : object 'variable' not found.
Please help me to solve this. Thanks in ADVANCE.

PM<- testing%>% %>%

  • select('Date','PM2.5')%>%
  • mutate(date_ymd=as.Date(Date,format="%Y-%m-%d"))%>%
  • group_by(date_ymd)%>%
  • summarise('PM2.5' = max('PM2.5',na.rm=TRUE))

PM_max <-'PM')
PM_max2 <- melt('PM_max2', id.vars='date_ymd', measure.vars=c('PM2.5'))
daily_max<-ggplot(PM_max2,aes(x=variable, y=value, color=variable)) +

  • geom_boxplot()+ coord_flip()+
  • scale_colour_manual(values=c("magenta3"))+
  • theme(legend.position="none")+scale_y_continuous(breaks = seq(0, 700, by = 50))+
  • labs(title="Distribution of pollutants on Monthly Average values",x='Pollutants',y='ug/m3')

hist_daily_max<-ggplot(PM_max2,aes(x = value,fill=variable)) +

  • facet_wrap(~variable, nrow = 1) +
  • geom_histogram(binwidth=20)+
  • scale_fill_manual(values=c("magenta3"))+
  • theme(legend.position="none")+
  • labs(x='ug/m3',y='Count')

Error in FUN(X[[i]], ...) : object 'variable' not found

The error message suggests there is no column called variable in your PM_max2 data frame, double-check on that and have in mind that R is case sensitive.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.