I am building a simple plot with ggplot2. I usually have no issue with ggplot. But I'm running into the error mentioned in the title: "Error: Only elements of the same class can be merged"
Below is an example using a subset of the txhousing dataset in R, which looks a lot like the dataset that I'm using with a chr column (city in the txhousing example) and then several num columns (sales, volume, median, etc in the txhousing example). It pulls the same error:
txsamp <- subset(txhousing, city %in%
c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
txs_plt <- ggplot(txsamp, aes(x = sales, y = median))+
geom_point(aes(color = city), size = 4)+
xlab("Sales")+
ylab("Median")+
theme_classic()+
theme(
axis.title = element_text(size = 30),
axis.ticks = element_text(size = 25))+
scale_x_continuous(trans = "log10", labels = scientific)+
scale_y_continuous(trans = "log10", labels = scientific)+
scale_colour_viridis_d(name = "City", option = "plasma")
txs_plt
I've isolated the problem to the theme() function. If you comment out the theme() function, it works just fine. I use the theme() function all the time in a similar manner, so I'm uncertain of what is happening. The question here was not useful and I'm having trouble finding mention of the error elsewhere.
I have ensured that my R version and ggplot2 package are up to date.
Any suggestions? Thank you.