0

I'm very new to R and have looked at the following to try and find a solution:

  1. ggplot2 Error in eval(expr, envir, enclos) : object not found

  2. ggplot2 Error in eval(expr, envir, enclos) : object 'd' not found

  3. ggplot call inside a function: Error in eval(expr, envir, enclos) : object '...' not found

I have tried changing aes to aes_string as suggested here: http://tolstoy.newcastle.edu.au/R/e3/help/07/12/6372.html. This did not solve the error.

These don't appear to have answered my questions as I'm not using it within a function, or matrix and this code worked previously when my friend was teaching me just two days ago.

Packages: Dplyr & ggplot2 are used and both active. Uses a CSV file holding temperature, rainfall and humidity data.

# load the data file, hit tab for selections
dar_baseline <- read.csv(file = "Dar_Baseline_Clean.csv",header = TRUE)

#load packages if you get error use install.packages
library(ggplot2)
library(dplyr)
library(tidyr)

#Calculating stats for Temperature
temp.stats.wide <- dar_baseline %>% group_by(Month) %>% summarise(meantemp=mean(AIR_TEMPERATURE,na.rm = TRUE),
                                                               sdtemp = sd(AIR_TEMPERATURE,na.rm = TRUE),
                                                               mintemp = min(AIR_TEMPERATURE,na.rm = TRUE),
                                                               maxtemp = max(AIR_TEMPERATURE,na.rm = TRUE),
                                                               sd4temp = sdtemp*4,
                                                               HighSD4temp = meantemp-sd4temp,
                                                               LowSD4temp = meantemp+sd4temp) %>% gather(Statisticstemp, Valuetemp, meantemp:LowSD4temp)

This section compiles without any issues and creates a correct table in the global environment with all values there.

#Plot data - Temperature
ggplot(data = temp.stats.wide,aes(Month, meantemp))+
geom_ribbon(aes(ymin = LowSD4temp, ymax = HighSD4temp), fill = "grey70")+
geom_line(size=1.5, col="blue")+
geom_point(data = dar_baseline,aes(Month,AIR_TEMPERATURE))

This section throws up the error - meantemp appears to be read fine, and so does HighSD4temp it's just LowSD4temp.

This worked previously on a different PC and provided a correct plot. I've checked and had other people check for typos, other friend coders (who are also unfamiliar with R) can't see any obvious reason why it's stopped working / wont work.

temp.stats.wide table looks like this: temp.stats.wide table

Any help would be great.

Community
  • 1
  • 1
R.Reynolds
  • 41
  • 1
  • 1
  • 5

0 Answers0