I wanna create 3 .tabsets, one per level of Species on the Iris Dataset (example). On each .tabset, a want 3 or more tabs. Each tab will have your own plot.
I wrote this code:
```{r echo=FALSE, results='asis'}
library(tidyverse)
for(especies in levels(iris$Species)){
cat('\n#', especies, '{.tabset}', '\n')
cat('\n##', 'Petal Lengh x Sepal Length', '\n')
iris %>%
filter(
Species == especies
) %>%
ggplot(
aes(
x = Sepal.Length,
y = Petal.Length
)
) +
geom_point() -> p
print(p)
cat('\n')
cat('\n##', 'Sepal Length', '\n')
iris %>%
filter(
Species == especies
) %>%
ggplot(
aes(
x = Sepal.Length
)
) +
geom_histogram() -> p
print(p)
cat('\n')
cat('\n##', 'Petal Length', '\n')
iris %>%
filter(
Species == especies
) %>%
ggplot(
aes(
x = Petal.Length
)
) +
geom_histogram() -> p
print(p)
}
```
I don't know why it isn't work. Any ideas?
Thanks in advance!
The stack keeps asking me for more details to post the question, so i have to write some more in order to be allowed to post.