From 8d0f481d2c9cf336a436ec17befe8301f7c7ca17 Mon Sep 17 00:00:00 2001 From: CarissaGervasi-NOAA Date: Thu, 17 Oct 2024 10:21:50 -0400 Subject: [PATCH] updating tourism data --- Report_book_files/Performance_indicators.qmd | 2 +- ...ruise_visitors.R => cruise_air_visitors.R} | 46 +++++++++++++++++-- .../non_automated/oceanNAICS.R | 4 +- 3 files changed, 44 insertions(+), 8 deletions(-) rename indicator_processing/automated_download/{cruise_visitors.R => cruise_air_visitors.R} (74%) diff --git a/Report_book_files/Performance_indicators.qmd b/Report_book_files/Performance_indicators.qmd index 2132eef..705ec69 100644 --- a/Report_book_files/Performance_indicators.qmd +++ b/Report_book_files/Performance_indicators.qmd @@ -110,7 +110,7 @@ Indicator 30 ![diving trips](/indicator_plots/prop_diving_trips_plot_final.png){fig-alt="a plot" fig-align="center"} -![Non-selective gears](/indicator_plots/Proportion of trips using non-selective gears.png){fig-alt="a plot" fig-align="center"} +![Non-selective gears](/indicator_plots/Proportion%20of%20trips%20using%20non-selective%20gears.png){fig-alt="a plot" fig-align="center"} ## 5.5 Governance diff --git a/indicator_processing/automated_download/cruise_visitors.R b/indicator_processing/automated_download/cruise_air_visitors.R similarity index 74% rename from indicator_processing/automated_download/cruise_visitors.R rename to indicator_processing/automated_download/cruise_air_visitors.R index 5be4ef5..c115c2c 100644 --- a/indicator_processing/automated_download/cruise_visitors.R +++ b/indicator_processing/automated_download/cruise_air_visitors.R @@ -1,11 +1,13 @@ -# Code to plot number of cruise ship visitors Puerto Rico & USVI +# Code to plot number of cruise ship visitors and air passengers Puerto Rico & USVI -# Last updated 6/19/2024 by Carissa Gervasi +# Last updated 10/17/2024 by Carissa Gervasi rm(list = ls()) dev.off() +# Puerto Rico - cruise passengers + url1<-'https://www.bde.pr.gov/BDE/PREDDOCS/I_CRUISE.XLS' library(readxl) @@ -31,6 +33,34 @@ cruise_PR = as.numeric(df2t$V2) PR_cruise <- data.frame(Year = yrs_PR, Cruise_passengers = cruise_PR) + +# Puerto Rico - air passengers (source = PR ports authority) + +url1<-'https://www.bde.pr.gov/BDE/PREDDOCS/I_CARGO.XLS' + +library(readxl) +library(httr) +packageVersion("readxl") + +GET(url1, write_disk(tf <- tempfile(fileext = ".xls"))) +df <- read_excel(tf, 2L) +str(df) + + +df2 = df[c(52,63),] + +df2t = as.data.frame(t(df2)) + +df2t = df2t[-c(1,2,12),] + + +yrs_PR = as.integer(df2t$V1) +air_PR = as.numeric(df2t$V2) + +# Create a data frame +PR_air <- data.frame(Year = yrs_PR, Air_passengers = air_PR) + + ############################ #USVI @@ -78,14 +108,20 @@ table_data <- strsplit(table_text, " +")[[1]] years <- c(2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022) # Extract and clean the total visitors data by removing commas -passengers <- gsub(",", "", table_data[87:101]) -passengers <- as.numeric(passengers) +cruise_passengers <- gsub(",", "", table_data[87:101]) +cruise_passengers <- as.numeric(cruise_passengers) + +# Extract and clean the total visitors data by removing commas +air_passengers <- gsub(",", "", table_data[66:80]) +air_passengers <- as.numeric(air_passengers) # Create a data frame -USVI_cruise <- data.frame(Year = years, Cruise_passengers = passengers) +USVI_cruise <- data.frame(Year = years, Cruise_passengers = cruise_passengers) +USVI_air <- data.frame(Year = years, Air_passengers = air_passengers) # Print the data frame print(USVI_cruise) +print(USVI_air) diff --git a/indicator_processing/non_automated/oceanNAICS.R b/indicator_processing/non_automated/oceanNAICS.R index 7fd9d8b..90ed67f 100644 --- a/indicator_processing/non_automated/oceanNAICS.R +++ b/indicator_processing/non_automated/oceanNAICS.R @@ -73,7 +73,7 @@ save(ind, file = "indicator_objects/oceanNAICS.RData") ######################################################################################## -#### ************ As of 7/5/24, can't get the API for this working. For now, will just plot the data Seann uploaded to Github. At the end of this script is some code to work with the API but it isn't yet working. +#### ************ As of 7/5/24, can't get the API for this working. For now, will just plot the data downloaded from the data portal. At the end of this script is some code to work with the API but it isn't yet working. rm(list = ls()) dev.off() @@ -199,7 +199,7 @@ print(naics_df) ## Access the API library(devtools) -#install_github('mikeasilva/blsAPI') +install_github('mikeasilva/blsAPI') library(blsAPI) library(jsonlite)