Last active
May 6, 2025 08:21
-
-
Save dikiprawisuda/50f1eb082af706f741f9ab07563bed09 to your computer and use it in GitHub Desktop.
rmd template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "<title>" | |
author: "<name>" | |
date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' | |
editor_options: | |
chunk_output_type: console | |
output: | |
html_document: | |
keep_md: true | |
engine: knitr | |
--- | |
```{r setup, include=FALSE} | |
# Set global R options for efficient output | |
options( | |
max.print = 500, # Reduced limit for printing | |
scipen = 10 # Moderate scientific notation suppression | |
) | |
# Set knitr chunk options for compact output | |
knitr::opts_chunk$set( | |
echo = TRUE, # Show code | |
message = FALSE, # Suppress package messages | |
warning = FALSE, # Suppress warnings | |
collapse = TRUE, # Combine code and output | |
comment = "#>", # Standard comment for output | |
dpi = 300, # Balanced resolution for web | |
out.width = "100%" # Full-width plots | |
) | |
# Set seed for reproducibility | |
set.seed(123) | |
``` | |
```{r load-libraries, message=TRUE, warning=TRUE} | |
library(here) # File path management | |
library(this.path) # Retrieve its own path without the explicit need to write it elsewhere | |
library(tinytable) # For saving tables as images | |
library(tidyverse) # Data manipulation, CSV reading, and plotting (includes dplyr, tidyr, readr, ggplot2) | |
library(ggrepel) # Non-overlapping labels | |
library(scales) # Label formatting | |
library(patchwork) # Combine multiple plots | |
``` | |
```{r configuration} | |
# File Paths | |
# Define the output directory for results | |
output_dir <- here("analysis_results", gsub( | |
"\\.([^\\.]+)$", # change .<ext> | |
"_\\1", # to _<ext> | |
basename(this.path()) | |
)) | |
# Define the path to the directory containing the processed Excel files | |
data_dir <- here("raw_data") | |
# Visualization (optimized for google slides) | |
plot_width <- 8.2 # Inches | |
plot_height <- 4.8 # Inches | |
plot_units <- "in" | |
plot_res <- 300 # dpi | |
padj_threshold <- 0.05 # Significance threshold | |
``` | |
# --- Start working --- | |
```{r} | |
``` | |
```{r} | |
plot_file <- file.path(output_dir, "plot_ggplot.png") | |
# <ggplot2 script> | |
# ggsave( | |
# plot_file, | |
# plot = plot_gg, | |
# width = plot_width, | |
# height = plot_height, | |
# units = plot_units, | |
# dpi = plot_res, | |
# bg = 'white' | |
# ) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment