I have a about 150 tables that I am hoping to make as many flexdashboards for, but don't want to knit each manually. I am using a for loop in a r script to hopefully render those rmd files as .html
setwd("/Volumes/G-DRIVE mobile USB/r/tables 7")
file_list <- list.files()
library(rmarkdown)
for (file in file_list){
render("template.Rmd",output_file = paste0('report.', file, '.html'))
}
The "template.Rmd" file is where my flexdashboard is created, but this is where I get stuck. What should I put as the maxtrix name for the dataframe (____$var1)? Or am I missing something else? I've tried a few things, but nothing's really worked. Some produce all the .html files and the dashboard layout is there, but nothing is plotted.
---
title: "Example Dasboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r setup, include=FALSE}
library(ggplot2)
library(plotly)
library(plyr)
library(flexdashboard)
library(RCurl)
library(ggthemes)
df<- data.frame(Name = (file),
Date = as.Date(file$date, format = "%m/%d/%Y"),
var1 = (file$var1),
var2 = (file$var2),
var3 = (file$var3),
var3a = (file$var3/((file$var4/2.204)^0.66)),
var4 = (file$var4),
var5 = (file$var5Total),
var6 = (file$var6))
```
Objective Measures
=======================================================================
Row
-----------------------------------------------------------------------
### Var3
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),],aes(Date,var3))+geom_point()+stat_smooth(color="red", fill="black")+
theme(axis.title.x = element_blank()) + ylab("")+xlab("")+
scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```
### var1
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),],aes(Date,var1))+geom_point()+stat_smooth(color="red", fill="black")+
theme(axis.title.x = element_blank()) + ylab("")+xlab("")+
scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Var4
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),],aes(Date,var4))+geom_point()+stat_smooth(color="red", fill="black")+
theme(axis.title.x = element_blank()) + ylab("")+xlab("")+ scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```
### Var2
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),],aes(Date,var2))+geom_point()+stat_smooth(color="red", fill="black")+
theme(axis.title.x = element_blank()) + ylab("")+xlab("")+
scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```
### Var3a
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),],aes(Date,var3a))+geom_point()+stat_smooth(color="red", fill="black")+
theme(axis.title.x = element_blank()) + ylab("")+xlab("")+
scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Var5
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),], aes(x=Date, y=var5)) +
geom_bar(stat="identity", fill = "orange") +xlab("") +ylab("") + scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```
Subjective Measures
=======================================================================
Row
-----------------------------------------------------------------------
### Var6
```{r}
p<-ggplot(df[which(df$Date>"2017-8-1"),], aes(x=Date, y=var6)) +
geom_bar(stat="identity", fill = "green")+ylim(0,10) +xlab("")+ylab("")+ scale_x_date(date_breaks = "months", date_labels = "%b%y")+theme_hc()
ggplotly(p)
```