Not able to plot side by side plotly bar plots in R Shiny flexdashboard -
i have design shiny flexdashboard , want plot 2 bar plots in plotly "single" tab.
what trying following:
--- title: "my dashboard" output: flexdashboard::flex_dashboard: orientation: column vertical_layout: fill --- ```{r setup, include=false} library(flexdashboard) library(ggplot2) library(plotly) library(plyr) ``` page ===================================== column {data-width=260 .tabset} ----------------------------------------------------------------------- ### tab 1 ```{r} ``` ### tab 2 ```{r} ``` ### tab 3 ```{r} ``` column {.tabset} ----------------------------------------------------------------------- ### region 1 ```{r} # make noisily increasing data set.seed(955) dat <- data.frame(cond = rep(c("a", "b"), each=10), xvar = 1:20 + rnorm(20,sd=3), yvar = 1:20 + rnorm(20,sd=3)) p1 <- ggplot(dat, aes(x=xvar, y=yvar)) + geom_point(shape=1) # use hollow circles ggplotly(p1) p2 <- ggplot(dat, aes(x=xvar, y=yvar)) + geom_point(shape=1) + # use hollow circles geom_smooth(method=lm) # add linear regression line ggplotly(p2) ``` ### region 2 ```{r} ``` i not getting plots side side (1 x 2 i.e. vertically side side).
using above code, should able 2 plots in single tab, getting one. also, expecting 2 plots next each other. looks have terrible mistake here.
where wrong??
we can use subplot
subplot(ggplotly(p1), ggplotly(p2)) -full code
title: "my dashboard" output: flexdashboard::flex_dashboard: orientation: column vertical_layout: fill --- ```{r setup, include=false} library(flexdashboard) library(ggplot2) library(plotly) library(plyr) ``` page ===================================== column {data-width=260 .tabset} ----------------------------------------------------------------------- ### tab 1 ```{r} ``` ### tab 2 ```{r} ``` ### tab 3 ```{r} ``` column {.tabset} ----------------------------------------------------------------------- ### region 1 ```{r} # make noisily increasing data set.seed(955) dat <- data.frame(cond = rep(c("a", "b"), each=10), xvar = 1:20 + rnorm(20,sd=3), yvar = 1:20 + rnorm(20,sd=3)) p1 <- ggplot(dat, aes(x=xvar, y=yvar)) + geom_point(shape=1) # use hollow circles p2 <- ggplot(dat, aes(x=xvar, y=yvar)) + geom_point(shape=1) + # use hollow circles geom_smooth(method=lm) # add linear regression line subplot(ggplotly(p1), ggplotly(p2)) ``` ### region 2 ```{r} ``` -output

Comments
Post a Comment