diff --git a/src/main.Rmd b/src/main.Rmd index 0a58f22..63f1a44 100644 --- a/src/main.Rmd +++ b/src/main.Rmd @@ -9,6 +9,11 @@ date: "`r Sys.Date()`" ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) +# include `eval=isArtifact()` to check if pdf/html is being produced +isArtifact <- function(){ + isOutput <-knitr::is_html_output() || knitr::is_latex_output() + return(isOutput) +} ``` ```{r preamble, message=FALSE, include=FALSE} @@ -383,7 +388,7 @@ The full analysis is also available in the GUI-based Shiny application. The `getCredentials()` function retrieves API credentials from environment variables, ensuring secure credential management. -```{r} +```{r, purl=FALSE} creds <- getCredentials( client_id = Sys.getenv("OPENSKY_CLIENT_ID"), client_secret = Sys.getenv("OPENSKY_CLIENT_SECRET") @@ -394,7 +399,7 @@ creds <- getCredentials( Recent departures from Frankfurt Airport (ICAO: EDDF) are queried for a two-hour time window. This airport was selected due to its high traffic volume, ensuring sufficient data availability. -```{r demo-departures} +```{r demo-departures, purl=FALSE} time_now <- Sys.time() departures <- getAirportDepartures( airport = "EDDF", @@ -409,7 +414,7 @@ cat("Departures retrieved:", length(departures), "\n") The `getAircraftTrack()` function retrieves detailed waypoint data for individual aircraft. The function iterates through available departures until valid track data is obtained. -```{r demo-track} +```{r demo-track, purl=FALSE} route_df <- NULL icao <- "N/A" @@ -436,7 +441,7 @@ if (is.null(route_df)) { The geographic trajectory is visualized in a Cartesian coordinate system. Green and red markers indicate departure and current/final position, respectively. -```{r demo-route-plot, fig.width=7, fig.height=5} +```{r demo-route-plot, fig.width=7, fig.height=5, purl=FALSE} if (!is.null(route_df)) { plot(route_df$lon, route_df$lat, type = "o", pch = 20, col = "blue", main = paste("Flight Trajectory -", icao), @@ -454,7 +459,7 @@ if (!is.null(route_df)) { The altitude profile reveals distinct flight phases: climb, cruise, and descent. This temporal representation provides insight into vertical movement patterns. -```{r demo-altitude-plot, fig.width=7, fig.height=4} +```{r demo-altitude-plot, fig.width=7, fig.height=4, purl=FALSE} if (!is.null(route_df)) { time_minutes <- (route_df$time - route_df$time[1]) / 60 plot(time_minutes, route_df$alt, type = "l", col = "red", lwd = 2, @@ -470,7 +475,7 @@ if (!is.null(route_df)) { The `getTrajFromRoute()` function transforms geographic coordinates into a metric coordinate system and constructs a `trajr` trajectory object. This transformation is necessary for accurate distance calculations. -```{r demo-trajectory-plot, fig.width=7, fig.height=5} +```{r demo-trajectory-plot, fig.width=7, fig.height=5, purl=FALSE} if (!is.null(route_df)) { trj <- getTrajFromRoute(route_df) plot(trj, main = paste("Metric Trajectory -", icao)) @@ -484,7 +489,7 @@ if (!is.null(route_df)) { The `calculateTrajectoryStats()` function computes comprehensive trajectory metrics. The table format provides a clear overview of individual flight characteristics. -```{r demo-stats-table} +```{r demo-stats-table, purl=FALSE} if (!is.null(route_df)) { stats_table <- calculateTrajectoryStats(route_df, icao = icao, format = "table") knitr::kable(stats_table, caption = paste("Trajectory Metrics for Aircraft", icao)) @@ -497,7 +502,7 @@ if (!is.null(route_df)) { To enable statistical inference, trajectory data is collected for multiple flights. The algorithm attempts to retrieve valid track data for up to five departures in this example. -```{r demo-multiple-tracks} +```{r demo-multiple-tracks, purl=FALSE} flight_data <- list() successful_flights <- 0 @@ -542,7 +547,7 @@ if (length(departures) > 0) { The following table presents computed metrics for all successfully analyzed flights. -```{r demo-all-stats-table} +```{r demo-all-stats-table, purl=FALSE} if (!is.null(all_flights_stats)) { display_stats <- all_flights_stats display_stats$diffusion_distance_km <- round(display_stats$diffusion_distance_km, 2) @@ -564,7 +569,7 @@ if (!is.null(all_flights_stats)) { The `calculateStatsSummary()` function computes central tendency and dispersion measures for each trajectory parameter. -```{r demo-summary-stats} +```{r demo-summary-stats, purl=FALSE} if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 2) { summary_stats <- calculateStatsSummary(all_flights_stats) knitr::kable(summary_stats, caption = "Descriptive Statistics Summary") @@ -577,7 +582,7 @@ if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 2) { Boxplots provide a robust visualization of parameter distributions, displaying median, interquartile range, and potential outliers. The red diamond indicates the arithmetic mean. -```{r demo-boxplots, fig.width=10, fig.height=8} +```{r demo-boxplots, fig.width=10, fig.height=8, purl=FALSE} if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 2) { createBoxplots(all_flights_stats) } else { @@ -589,7 +594,7 @@ if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 2) { Density plots employ kernel density estimation to approximate the probability distribution of each parameter. Vertical lines indicate mean (red, dashed) and median (green, dotted). -```{r demo-density, fig.width=10, fig.height=8} +```{r demo-density, fig.width=10, fig.height=8, purl=FALSE} if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 3) { createDensityPlots(all_flights_stats) } else { @@ -601,7 +606,7 @@ if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 3) { Histograms with overlaid density curves provide an alternative visualization of parameter distributions. -```{r demo-histograms, fig.width=10, fig.height=8} +```{r demo-histograms, fig.width=10, fig.height=8, purl=FALSE} if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 3) { createHistograms(all_flights_stats) } else { @@ -613,7 +618,7 @@ if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 3) { The `generateInterpretation()` function provides contextual analysis of the computed trajectory metrics. -```{r demo-interpretation} +```{r demo-interpretation, purl=FALSE} if (!is.null(all_flights_stats) && nrow(all_flights_stats) >= 2) { interpretation <- generateInterpretation(all_flights_stats) cat(interpretation)