Watts-College / cpp-527-fall-2021

A course shell for CPP 527 Foundations of Data Science II
https://watts-college.github.io/cpp-527-fall-2021/
2 stars 6 forks source link

Final Project Batch Processing Header #80

Open millmeli42 opened 2 years ago

millmeli42 commented 2 years ago

Hello Professor -

I can get my batch file to run, and produce the appropriate files. However the header in my batch.R file which is below, seems to be overwritten by the values in my header in salary -report.rmd.

title: 'CPP 527 Final Project Instructions' output: html_document: theme: readable highlight: zenburn

Salary-report. rmd header: title: "Final Project Millican" author: "Melissa Millican" date: "10/4/2021" output: html_document

I can change the header information in the salary-report.rmd file manually, but I was wondering, how do I make it update automatically from running the batch.R file? Everything else in the reports that are created are correct, it is just that header information.

lecy commented 2 years ago

Drop the example title for sure:

title: 'CPP 527 Final Project Instructions'

What do you want the doc title to be? Maybe something like ASU Salary Report?

If you want unique titles for each report you would need to add another variable you can pass to the report. Otherwise go with something generic.

millmeli42 commented 2 years ago

Thank you!

lecy commented 2 years ago

If you wanted to customize it would be something like this.

YAML header:

---
title: "`r params$doc_title`"
params:
  doc_title: "ASU Salary Report"
---

Render stage:

## 2020 REPORT

url.2020 <- "https://docs.google.com/...gid=1335284952&format=csv"
rmarkdown::render( input='salary-report.rmd', 
                   output_file = "ASU-2020-Salary-Report.HTML",
                   params = list( url = url.2020, doc_title = "2020 Salary Report" ) )

If you include a params argument for doc_title then it will use it, and if not it would use the default value "ASU Salary Report".

sandralili commented 2 years ago

Doctor @lecy, this code is for the the salary-report file, correct? I placed it at the end, but not sure if it is the right place.


render( input='salary-report.rmd', 
                   output_file = "ASU-2020-Salary-Report.HTML",
                   params = # 2020 data url )
sandralili commented 2 years ago

Sorry, I found out where Dr. @lecy , thanks anyways, I already was using the code.

sandralili commented 2 years ago

This was an error I got in my Batch.R file:

title: "r params$doc_title" params:


Error in knit_params_get(input_lines, params) : render params not declared in YAML: doc_title