UM-R-for-EnvSci-Registered-Student / General-Discussion

Public repo for general discussion about the course and assignments
1 stars 0 forks source link

Data frames not equal sized error. #10

Open 7661320 opened 3 years ago

7661320 commented 3 years ago

I made my two individual plots, but when I tried to combine them using patchwork I had the following error:

Error in Ops.data.frame(chla_data_clean, phosprof_data_clean) : ‘+’ only defined for equally-sized data frames

Upon review, the shapes generated for my figure "B" lake 2, lake 3, and muir have values significantly higher than the approximately 0.3 as seen on the example mg/L on the example figure. Is incorrect filtering (as seen in the values higher than 0.3 mg/L) the root of the problem or is there something else I am missing?

peperg commented 3 years ago

Hey Zac!

Sorry it took me a while to get to this. I just took a look at your code. The problem is that you had not saved the plots into the environment, so, what you are trying to "sum" is the datasets, that's why it tells you that they are different sizes.

remember to assign your new plot to an object. for example:

plot_1 <- phosprof_data_clean %>%
  ggplot() +
  geom_violin(aes(x = lake_name, y = concentration)) +
  geom_jitter(aes(x = lake_name, y = concentration), width = 0.1, alpha = 0.3) +
  labs(x = " ", y = expression(Total~phosphorus~(mg~.~L^{-1}))) +

  theme_zeekfriedefrog()   # whole colour palette does not seem to be working in custom theme

print(plot_1)