0

I want to add facets by using qplot function in r. I imitated the parameter structure provided in R help, but it returned that the value cannot be found.

that the result i want to get by using qplot funcion

ggplot(otter, aes(time, body.temp, color = animal)) + 
  geom_line() + 
  facet_wrap(~ animal + day) + 
  ylab('Body temporature') +
  theme_bw()

the facets parameter cannot work even i tried: facets = day ~ animal, facets = ~ day + animal

data is already attached

qplot(time, body.temp, geom = 'line', 
      color = animal, facets = ~ animal,
      xlab = 'time', ylab = "Body temporature")
  • 1
    Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Oct 26 '19 at 15:45
  • did you make animal a vector? like animal <- otter$animal – StupidWolf Oct 26 '19 at 16:39
  • No, and I tried it just now, it works!! Thank you Wolf :D!!! – yongtong yin Oct 26 '19 at 16:51

0 Answers0