rmd_file <- “presentation.Rmd” html_file <- “presentation.html” # will be overwritten by render

1) Presentation content (5 slides, ioslides)

rmd_contents <- c( “—”, “title: "MPG Predictor — Pitch"”, “author: "ATHANG DHARASKAR"”, “output:”, ” ioslides_presentation:“,” widescreen: true”, “—”, ““,”# MPG Predictor”, ““,”A quick pitch for the Shiny application.”, ““,”—“,”“,”# Problem & Audience”, ““,”- Problem: People want a quick, intuitive estimate of a car’s fuel efficiency given horsepower and weight.”, “- Audience: Intro stats students, car enthusiasts, instructors demonstrating reactive apps.”, ““,”—“,”“,”# App Features”, ““,”- Numeric inputs for horsepower and weight.”, “- Choice of baseline or refit model.”, “- Prediction with 95% prediction interval.”, “- Downloadable CSV and informative plot.”, ““,”—“,”“,”# Live demo (embedded R code)“,”“,”{r echo=TRUE, results='asis'}", "data(mtcars)", "model_demo <- lm(mpg ~ hp + wt, data = mtcars)", "newd <- data.frame(hp = 110, wt = 2.8)", "pred <- predict(model_demo, newd, interval = \"prediction\")", "cat(\"Example: hp=110, wt=2.8 -> predicted mpg =\", round(pred[,\"fit\"],3),", " \" (95% PI:\", round(pred[,\"lwr\"],3), \",\", round(pred[,\"upr\"],3), \")\")", "“,”“,”—“,”“,”# How to access & publish”, ““,”- Files (ui.R, server.R, presentation.Rmd) are ready to push to GitHub.”, “- Publish this .Rmd to RPubs via the RStudio Publish button or via the script (this will upload the generated HTML).”, “” )

2) Write the Rmd to disk

writeLines(rmd_contents, con = rmd_file) message(“Wrote R Markdown to:”, normalizePath(rmd_file))

3) Ensure required packages are installed

required <- c(“rmarkdown”, “rsconnect”, “knitr”) to_install <- setdiff(required, rownames(installed.packages())) if (length(to_install)) { message(“Installing required packages:”, paste(to_install, collapse = “,”)) install.packages(to_install, repos = “https://cloud.r-project.org”) }

library(rmarkdown) library(rsconnect)

4) Render the Rmd to ioslides HTML

message(“Rendering”, rmd_file, ” to ioslides HTML…“) render_result <- tryCatch({ rmarkdown::render(rmd_file, output_file = html_file, quiet = TRUE) }, error = function(e) { stop(”Error rendering Rmd: “, conditionMessage(e)) })

message(“Rendered HTML:”, normalizePath(html_file))

5) Ask user for a title for RPubs (interactive)

default_title <- paste(“MPG Predictor Pitch -”, Sys.Date()) if (interactive()) { title_input <- readline(prompt = sprintf(“RPubs post title (press Enter for default: ‘%s’):”, default_title)) if (!nzchar(trimws(title_input))) title_input <- default_title } else { title_input <- default_title }

6) Upload HTML to RPubs

. message(“Uploading to RPubs…”) upload_result <- tryCatch({ # rsconnect::rpubsUpload(title, contentFile, originalDoc) rsconnect::rpubsUpload(title = title_input, contentFile = normalizePath(html_file), originalDoc = normalizePath(rmd_file)) }, error = function(e) { message(“Error during rpubsUpload():”, conditionMessage(e)) NULL })