Based on the code and data (obtained from rayshader
tutorial website) provided in the post, I am getting the error shown below.
What might be causing it and how can it be fixed?
Error:
Error in hillshade[, , 1] * scales::rescale(shadowmap, c(max_darken, 1)) :
non-conformable arrays
Code:
library(tidyverse)
library(reshape2)
library(viridis)
library(rayshader)
measles = read_csv("https://tylermw.com/data/measles_country_2011_2019.csv")
melt_measles = reshape2::melt(measles, id.vars = c("Year", "Country", "Region", "ISO3"))
melt_measles$Month = melt_measles$variable
melt_measles$cases = melt_measles$value
# Plot
melt_measles %>%
group_by(Year, Month) %>%
summarize(totalcases = sum(cases,na.rm = TRUE)) %>%
mutate(totalcases = ifelse(Year == 2019 & !(Month %in% c("January","February","March")), NA, totalcases)) %>%
ggplot()
geom_tile(aes(x=Year, y=Month, fill=totalcases,color=totalcases),size=1,color="black")
scale_x_continuous("Year", expand=c(0,0), breaks = seq(2011,2019,1))
scale_y_discrete("Month", expand=c(0,0))
scale_fill_viridis("Total\nCases")
ggtitle("Reported Worldwide Measles Cases")
labs(caption = "Data Source: WHO")
theme(axis.text = element_text(size = 12),
title = element_text(size = 12,face="bold"),
panel.border= element_rect(size=2,color="black",fill=NA)) ->
measles_gg
plot_gg(measles_gg, multicore = TRUE, width = 6, height = 5.5, scale = 300,
background = "#afceff",shadowcolor = "#3a4f70")
CodePudding user response:
This is a known issue <github.com/tylermorganwall/rayshader/issues/176>
I tested with remotes::install_github("tylermorganwall/rayshader")