Issues with ggplot2 in Preview Release

ggplot2

#1

I ran into an issue with RStudio's preview release v1.2.1047 (whose Python support is fantastic, btw! thanks!) that I wanted to get in as feedback. reprex doesn't seem to be working (I'll like @jennybryan know on GitHub), but here is what is needed to reproduce this behavior:

library(ggplot2)

# create data frame
popPlot <- data.frame(
  year = c(1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010, 2016),
  pop = c(575238, 687029, 772897, 821960, 816048, 856796, 750026, 622236, 452801, 396685,
          348189, 319294, 311404)
)

If I create my plot with no breaks in the scale_y_continuous or labs arguments like I have below, the plot builds just fine:

# plot data
ggplot(data = popPlot, aes(x = year, y = pop)) +
  geom_line(color = "#349E8B", size = 2) +
  scale_x_continuous(breaks = c(1900, 1920, 1940, 1960, 1980, 2000, 2016)) +
  scale_y_continuous(breaks = c(300000, 400000, 500000, 600000, 700000, 800000, 900000), labels = c(300, 400, 500, 600, 700, 800, 900), limits = c(300000, 900000)) +
  labs(title = "St. Louis's Population, 1900-2016", x = "Year", y = "Population (thousands)")

However, I like my ggplot calls to be a bit more readable, so I normally build them this way:

# plot data
ggplot(data = popPlot, aes(x = year, y = pop)) +
  geom_line(color = "#349E8B", size = 2) +
  scale_x_continuous(breaks = c(1900, 1920, 1940, 1960, 1980, 2000, 2016)) +
  scale_y_continuous(
    breaks = c(300000, 400000, 500000, 600000, 700000, 800000, 900000),
    labels = c(300, 400, 500, 600, 700, 800, 900),
    limits = c(300000, 900000)) +
  labs(
    title = "St. Louis's Population, 1900-2016",
    x = "Year",
    y = "Population (thousands)")

That code, however, results in a number of errors:

>     breaks = c(300000, 400000, 500000, 600000, 700000, 800000, 900000),
Error: unexpected ',' in "    breaks = c(300000, 400000, 500000, 600000, 700000, 800000, 900000),"
>     labels = c(300, 400, 500, 600, 700, 800, 900),
Error: unexpected ',' in "    labels = c(300, 400, 500, 600, 700, 800, 900),"
>     limits = c(300000, 900000)) +
Error: unexpected ')' in "    limits = c(300000, 900000))"
>   labs(
+

I checked this code in R outside of RStudio and it works just fine. It was also working in the last stable version of RStudio.


#2

Hmm…have you tried the daily? Here's the reprex for your code above in 1.2.1049

library(ggplot2)

# create data frame
popPlot <- data.frame(
  year = c(1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010, 2016),
  pop = c(575238, 687029, 772897, 821960, 816048, 856796, 750026, 622236, 452801, 396685,
          348189, 319294, 311404)
)

# plot data
ggplot(data = popPlot, aes(x = year, y = pop)) +
  geom_line(color = "#349E8B", size = 2) +
  scale_x_continuous(breaks = c(1900, 1920, 1940, 1960, 1980, 2000, 2016)) +
  scale_y_continuous(breaks = c(300000, 400000, 500000, 600000, 700000, 800000, 900000), labels = c(300, 400, 500, 600, 700, 800, 900), limits = c(300000, 900000)) +
  labs(title = "St. Louis's Population, 1900-2016", x = "Year", y = "Population (thousands)")


# plot data
ggplot(data = popPlot, aes(x = year, y = pop)) +
  geom_line(color = "#349E8B", size = 2) +
  scale_x_continuous(breaks = c(1900, 1920, 1940, 1960, 1980, 2000, 2016)) +
  scale_y_continuous(
    breaks = c(300000, 400000, 500000, 600000, 700000, 800000, 900000),
    labels = c(300, 400, 500, 600, 700, 800, 900),
    limits = c(300000, 900000)) +
  labs(
    title = "St. Louis's Population, 1900-2016",
    x = "Year",
    y = "Population (thousands)")

Created on 2018-10-12 by the reprex package (v0.2.1.9000)


#3

Thanks @mara - I was on the one from the preview release page. I'll switch to the daily build today, though. Also glad to see that reprex is working on the daily!