A thread in which my students will post their first reprex's

I am teaching reprex today, inspired by Mara Averick's lecture to my class last week. I want to provide a safe, but real, environment for the students to practice their data science "superpowers." So, they will post in this thread.

If this is a bad idea, or a violation of your service, let me know and I will find another way.

Any advice about teaching reprex or about how to use reprex to post questions here would be appreciated!

UPDATE: Sorry! They don't need answers to these questions. I should have made that more clear. The purpose was to force them to ask a question at least once, as well as to ensure that they have signed up for R Community. Thanks to all those who answered anyway!

8 Likes

Here is an example:

x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)
#> Error in seq.default(min(x), max(x), length.out = input$bins + 1): object 'input' not found
      
      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
#> Error in hist.default(x, breaks = bins, col = "darkgray", border = "white"): object 'bins' not found

Created on 2019-04-16 by the reprex package (v0.2.1)

1 Like

Here is my question:

mtcars %>% 
  ggplot(aes(x = mpg, y = cyl)) +
  geom_histogram()
#> Error in mtcars %>% ggplot(aes(x = mpg, y = cyl)): could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

What am I doing wrong?

Question: Hoping to have a boxplot for every cyl, but only have one large boxplot.

library(tidyverse)

mtcars %>% 
  ggplot(aes(x = cyl, y = mpg)) +
    geom_boxplot()
#> Warning: Continuous x aesthetic -- did you forget aes(group=...)?

Created on 2019-04-16 by the reprex package (v0.2.1)

Unsure why I'm getting this error -- any help would be appreciated!

gapminder %>%
  glimpse()
#> Error in gapminder %>% glimpse(): could not find function "%>%"

I'd appreciate some help with this error:

data("mtcars")
mtcars %>%
  View()
#> Error in mtcars %>% View(): could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

mtcars %>% 
  summarise(min_mpg = min(mpg)) 
#> Error in mtcars %>% summarise(min_mpg = min(mpg)): could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

I don't know why I get this error. Would love help!

Here's my question on the warning I received:

library(tidyverse)
library(gapminder)

gapminder %>%
  filter(year == 2000) %>%
  group_by(continent) %>%
  summarise(count = n())
#> Warning: Factor `continent` contains implicit NA, consider using
#> `forcats::fct_explicit_na`
#> # A tibble: 1 x 2
#>   continent count
#>   <fct>     <int>
#> 1 <NA>          0

I am very confused. How do I get rid of this error?

faithful %>% 
  summarize(wait == max(waiting))
#> Error in faithful %>% summarize(wait == max(waiting)): could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

library(tidyverse)
library(gapminder)
library(reprex)

gapminder %>% 
  mutate(country_cont == paste(country,continent))
#> Error: object 'country_cont' not found

Created on 2019-04-16 by the reprex package (v0.2.1)

As seen above, why can I not mutate to create a new variable country_cont?

Hi,

So, I came across this error when working with data. Here is the code:

aggregate %>% mutate()
#> Error in aggregate %>% mutate(): could not find function "%>%"
``
I don't understand what is wrong.

<sup>Created on 2019-04-16 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)</sup>

Here is my question:

library(tidyverse)
library(gapminder)

gapminder %>% 
  ggplot(x = year, y = gdpPercap)+geom_point()
#> Error: geom_point requires the following missing aesthetics: x, y

Created on 2019-04-16 by the reprex package (v0.2.1)

data %>% 
  
    ggplot(aes(x = year, y = population, color = country, size = gdpPercap)) + 
  
    geom_point() +
  
    scale_y_continuous() +
  
    transition_states(year)
#> Error in data %>% ggplot(aes(x = year, y = population, color = country, : could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

data("mtcars")

mtcars %>% 
  View()
#> Error in mtcars %>% View(): could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

Help!

Rplot

Here is my question
image

Here is my question:

library(gapminder)
library(tidyverse)

gapminder %>% 
  filter(continent = c("Africa", "Asia"))
#> `continent` (`continent = c("Africa", "Asia")`) must not be named, do you
#> need `==`?

Created on 2019-04-16 by the reprex package (v0.2.1)

library(reprex)
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 3.5.2
#> Warning: package 'tibble' was built under R version 3.5.2
#> Warning: package 'tidyr' was built under R version 3.5.2
#> Warning: package 'purrr' was built under R version 3.5.2
#> Warning: package 'dplyr' was built under R version 3.5.2
#> Warning: package 'stringr' was built under R version 3.5.2
#> Warning: package 'forcats' was built under R version 3.5.2

cars %>% 
  filter(speed = 12)
#> `speed` (`speed = 12`) must not be named, do you need `==`?

Here is my question:

library(gapminder)

gapminder %>%
  filter(year == 1997) %>%
  group_by(continent) %>%
  summarise(avg_pop = mean(pop)) %>%
  gt()
#> Error in gapminder %>% filter(year == 1997) %>% group_by(continent) %>% : could not find function "%>%"

Created on 2019-04-16 by the reprex package (v0.2.1)

Whoops! Looks like you forgot to include your packages in this reprex. I think you'll need dplyr and gapminder)