R Markdown Document Parameterizer

R Markdown Document Parameterizer

1. Report Metadata
2. Add / Edit Parameters
Name Type Default Value Action

Generated R Markdown YAML Header

Click "Generate YAML" to see your R Markdown header here.

Example Usage in R Chunk

The R code example will appear here once parameters are defined.

No parameters have been defined, so no specific R code example can be generated.

'; } rCodeOutput.textContent = code; } generateYamlBtn.addEventListener('click', generateYaml); // --- PDF Generation --- function downloadPDF() { const yamlText = yamlOutput.textContent; const rCodeText = rCodeOutput.textContent; if (yamlText.includes('Click "Generate YAML"')) { alert("Please generate the YAML first before downloading the PDF."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'pt', 'a4'); const pageWidth = doc.internal.pageSize.width; const margin = 30; let currentY = margin; doc.setFontSize(18); doc.setFont(undefined, 'bold'); doc.text("R Markdown Parameterization Guide", margin, currentY); currentY += 20; doc.setFontSize(14); doc.text("1. YAML Header", margin, currentY); currentY += 10; doc.setFontSize(10); doc.setFont('Courier', 'normal'); const yamlLines = doc.splitTextToSize(yamlText, pageWidth - margin * 2); doc.text(yamlLines, margin, currentY); currentY += (yamlLines.length * 7) + 20; doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.text("2. R Code Access Example", margin, currentY); currentY += 10; doc.setFontSize(10); doc.setFont('Courier', 'normal'); const rCodeLines = doc.splitTextToSize(rCodeText, pageWidth - margin * 2); doc.text(rCodeLines, margin, currentY); currentY += (rCodeLines.length * 7) + 20; doc.save('R_Markdown_Parameters.pdf'); } pdfDownloadBtn.addEventListener('click', downloadPDF); // --- Utility Functions --- function setInitialDate() { const today = new Date(); const yyyy = today.getFullYear(); const mm = String(today.getMonth() + 1).padStart(2, '0'); const dd = String(today.getDate()).padStart(2, '0'); // dateInput.value = `${yyyy}-${mm}-${dd}`; // Not using a date input here, using R code snippet instead } // --- Tab Navigation --- function switchTab(tabIndex) { tabs.forEach((tab, index) => { tab.classList.toggle('active', index === tabIndex); contents[index].classList.toggle('active', index === tabIndex); }); currentTab = tabIndex; updateNavButtons(); } function updateNavButtons() { prevBtn.disabled = currentTab === 0; nextBtn.disabled = currentTab === tabs.length - 1; } tabs.forEach((tab, index) => { tab.addEventListener('click', () => switchTab(index)); }); nextBtn.addEventListener('click', () => { if (currentTab < tabs.length - 1) switchTab(currentTab + 1); }); prevBtn.addEventListener('click', () => { if (currentTab > 0) switchTab(currentTab - 1); }); // --- Initial Setup --- setInitialDate(); initializeParameters(); updateNavButtons(); });
Scroll to Top