title: “Final Question 7” author: “Bridgett” date: “2025-12-08” output: html_document # Load libraries if (!requireNamespace(“DiagrammeR”, quietly = TRUE)) install.packages(“DiagrammeR”) if (!requireNamespace(“DiagrammeRsvg”, quietly = TRUE)) install.packages(“DiagrammeRsvg”) if (!requireNamespace(“rsvg”, quietly = TRUE)) install.packages(“rsvg”) if (!requireNamespace(“magick”, quietly = TRUE)) install.packages(“magick”)

library(DiagrammeR) library(DiagrammeRsvg) library(rsvg) library(magick)

================================================================

BUILD FLOW DIAGRAM (VERTICAL)

================================================================

diagram_code <- ’ digraph maricopa_flow {

graph [ rankdir = “TB” bgcolor = “white” ]

# Default node style: light border, rounded, soft fill node [ fontname = “Arial” fontsize = 10 shape = “rectangle” style = “filled,rounded” color = “#4A4A4A” penwidth = 0.9 ]

edge [ color = “#7F7F7F” arrowsize = 0.7 ]

# ———– NODES ———–

Start [ label = “Start” shape = “ellipse” fillcolor = “#D9EAD3” # soft green color = “#38761D” ]

LoadLib [ label = “Load dplyr library” fillcolor = “#C9DAF8” # soft blue ]

SetWD [ label = “Set working directory(Maricopa folder)” fillcolor = “#FCE5CD” # soft beige ]

ListFiles [ label = “List station .txt files(list.files)” shape = “parallelogram” # I/O symbol fillcolor = “#FCE5CD” ]

DefineCols [ label = “Define column names(Year, Day, Hour, AirT_Max, …)” fillcolor = “#C9DAF8” ]

ReadFiles [ label = “Read all .txt filesdata_list” fillcolor = “#C9DAF8” ]

DefineYears [ label = “Define years 2002–2022name list elements” fillcolor = “#C9DAF8” ]

InitStats [ label = “Initialize vectors formean and SD” fillcolor = “#C9DAF8” ]

LoopStats [ label = “Loop over years:AirT_Max andmean & SD” fillcolor = “#FFF2CC” # soft yellow for loop block ]

CreateResults [ label = “Create summary table(Year, Avg_Daily_High_Temp,_Daily_High_Temp)” fillcolor = “#C9DAF8” ]

PrintResults [ label = “Print summary results” shape = “parallelogram” fillcolor = “#FCE5CD” ]

WriteCSV [ label = “Export CSV file_2002_2022_TempSummary.csv” shape = “parallelogram” fillcolor = “#FCE5CD” ]

End [ label = “End” shape = “ellipse” fillcolor = “#D9EAD3” color = “#38761D” ]

# ———– FLOW ORDER ———–

Start -> LoadLib -> SetWD -> ListFiles -> DefineCols -> ReadFiles -> DefineYears -> InitStats -> LoopStats -> CreateResults -> PrintResults -> WriteCSV -> End } ’

Show in Viewer

flow_graph <- grViz(diagram_code)

================================================================

EXPORT FLOW DIAGRAM

================================================================

OUTPUT_PATH <- “D:/Delta State/2025 - Fall/GIS-461/FInal/” FILENAME <- “GIS461-Final-Q7-Flow”

svg_obj <- export_svg(flow_graph) img_obj <- image_read_svg(svg_obj)

image_write( img_obj, path = paste0(OUTPUT_PATH, FILENAME, “.png”), format = “png” )