From 2678cea93d700c228e15375bef21cfba768a315f Mon Sep 17 00:00:00 2001 From: kyle-messier Date: Sun, 21 Apr 2024 23:36:24 -0400 Subject: [PATCH] Rhistory 2 --- .Rhistory | 663 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 508 insertions(+), 155 deletions(-) diff --git a/.Rhistory b/.Rhistory index e97b463..0fbff4c 100755 --- a/.Rhistory +++ b/.Rhistory @@ -272,167 +272,520 @@ m1 <- tar_read(plot_covariate_maps_97adc691) m1 1259*24 1259*24/2 -getwd() -tar_meta(sf_pesticide_partition_cleaned) -tm <- tar_meta(sf_pesticide_partition_cleaned) -tm -tm$data -tm$size -tm$path -unlist(tm) -tm[[1]] -tm[[2]] -tm[[3]] -tm[[4]] -tm[[5]] -tm[[6]] -colnames(tm) -tm$time -tm$size -tm$format -tm$repository -tm$iteration -tl <- tar_load(sf_pesticide_partition_cleaned) -tl -tar_load(sf_pesticide_partition_cleaned) -tm <- tar_manifest(sf_pesticide_partition_cleaned) -tm -tm$name -tm$command -tm <- tar_meta_read(sf_pesticide_partition_cleaned) -tm -tm <- tar_meta(sf_pesticide_partition_cleaned) -tm -tm$size -typeof(tm) -tm -tm[[1]] -tm[[18]] -tm[[17]] -tm[[16]] -tn -tm -tm$bytes -tm$command -tm$iteration -to <- tar_outdated(sf_pesticide_partition_cleaned) -to -to <- tar_outdated() -to -tar_outdated() -getwD() -getwd() -tar_exist_objects(sf_pesticide_partition_cleaned) -tar_exist_objects("sf_pesticide_partition_cleaned") -tar_process(sf_pesticide_partition_cleaned) -tar_make() -?tar_file_read -if (identical(Sys.getenv("TAR_LONG_EXAMPLES"), "true")) { -targets::tar_dir({ # tar_dir() runs code from a temporary directory. -targets::tar_script({ -tar_file_read(data, get_path(), read_csv(file = !!.x, col_types = cols())) +======= +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ ifelse(.x$lft_cns == 0, .x$cncntrt, 1e-9))) |> +pull(data) +# 2) A list of LOD, each element is a vector of the limit of detection +# use dplyr to create a separate list by each ChmlNm and create an LOD. The +# LOD should be the cnctrnt +pesticide_lod <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x$cnctrnt)) |> +pull(data) +# 2) A list of LOD, each element is a vector of the limit of detection +# use dplyr to create a separate list by each ChmlNm and create an LOD. The +# LOD should be the cnctrnt +pesticide_lod <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x$cncntrt)) |> +pull(data) +pesticide_outcomes[[1]][1:10] +pesticide_lod[[1]][1:10] +#2a) Create a list of the of the lft_cns variable by ChmclNm +pesticide_lft_cns <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x$lft_cns)) |> +pull(data) +pesticide_lft_cns[[1]][1:10] +cbind(pesticide_lft_cns[[1]][1:10],pesticide_outcomes[[1]][1:10],pesticide_lod[[1]][1:10]) +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(-cncntrt, -lft_cns))) |> +pull(data) +pesticide_covariates[[1]] +pesticide_covariates[[2]] +pesticide_covariates[[3]] +pesticide_covariates[[4]] +ls +pesticide_covariates[[3]] +data_analysis +data_analysis[[1]][,1:20] +data_analysis[[1]][,1:10] +data_analysis[,1:10] +# 5) A list of locs, each element is a matrix of the locations +# For now, we will use the locations in the data_analysis - it includes x, y, and time +# Because the locations are from the sf geometry object we need to use the original data +# We get the geometry from the sf object and then add the time (column name is Year) +pesticide_locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ st_coordinates(.x |> select(geometry)))) |> +pull(data) +# 5) A list of locs, each element is a matrix of the locations +# For now, we will use the locations in the data_analysis - it includes x, y, and time +# Because the locations are from the sf geometry object we need to use the original data +# We get the geometry from the sf object and then add the time (column name is Year) +data_analysis <- splits |> +analysis() |> +group_by(ChmclNm) |> +nest() |> +mutate(geometry = st_as_text(geometry)) |> +sf::st_drop_geometry() +# 5) A list of locs, each element is a matrix of the locations +# For now, we will use the locations in the data_analysis - it includes x, y, and time +# Because the locations are from the sf geometry object we need to use the original data +# We get the geometry from the sf object and then add the time (column name is Year) +data_analysis <- splits |> +analysis() |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, st_coordinates())) |> +sf::st_drop_geometry() +data_analysis <- splits |> +analysis() |> +group_by(ChmclNm) +data_analysis <- splits |> +analysis() +data_analysis +# 5) A list of locs, each element is a matrix of the locations +# We need to get the locations from the original data which is an sf object +# Then we need to get the time variable - Year +# Then we need to group by chemical name and nest the data +# Then we need to create a list of the locations +pesticide_locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +pesticide_locs +# 5) A list of locs, each element is a matrix of the locations +# We need to get the locations from the original data which is an sf object +# Then we need to get the time variable - Year +# Then we need to group by chemical name and nest the data +# Then we need to create a list of the locations +# Then we need to conver the geometry to a matrix since PrestoGP doesn't take sf objects +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ st_coordinates(.x))) |> +pull(data) +locs +locs[[1]] +locs[[2]] +# 5) A list of locs, each element is a matrix of the locations +# We need to get the locations from the original data which is an sf object +# Then we need to get the time variable - Year +# Then we need to group by chemical name and nest the data +# Then we need to create a list of the locations +# Then we need to conver the geometry to a matrix since PrestoGP doesn't take sf objects +# Make sure the Time variable is included in the data +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs[[1]] +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs <- locs |> +map(~ st_coordinates(.x)) |> +map(~ as.matrix(.x)) |> +map(~ .x[,-1]) +locs[[1]] +length(locs) +head(locs[[1]]) +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +head(locs[[1]]) +locs <- locs |> +map(~ st_coordinates(.x)) +locs[[1]] +locs[[1]] |> head() +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs[[1]] +locs <- locs |> +map(~ st_coordinates(.x)) +locs[[1]] +locs[[1]] |> head() +locs <- locs |> +map(~ st_coordinates(.x) + Year) +locs <- locs |> # Retain Year +map(~ .x %>% +st_coordinates() |> +as.data.frame() |> +as.matrix()) +?map +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs +locs <- locs |> +map(~ st_coordinates(.x)) | +map(~ as.matrix(.x)) |> +map(~ .x[,-1]) +locs <- locs |> # Retain Year +map(~ st_coordinates(.x)) |> +map(~ as.matrix(.x)) |> +map(~ .x[,-1]) +locs[[1]] +locs[[1]] |> head() +locs <- locs |> # Retain Year +map(~ st_coordinates(.x)) |> +map(~ .x[,-1]) +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs <- locs |> # Retain Year +map(~ st_coordinates(.x)) |> +map(~ .x[,-1]) +locs[[1]] |> head() +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs <- locs |> # Retain Year +map(~ st_coordinates(.x)) +locs[[1]] +locs[[1]]|> head() +typeof(locs[[1]]) +locs[[1]]$X +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs[[1]] +locs <- locs |> # Retain Year +map(Year ~ st_coordinates(.x)) +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +# Update the locs list +locs <- locs |> +map(~ { +coords <- st_coordinates(.x) +data.frame( +X = coords[, "X"], +Y = coords[, "Y"], +Year = .x$Year +) }) -targets::tar_manifest() +locs[[1]] +locs[[1]] |> head() +# 5) A list of locs, each element is a matrix of the locations +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +# Update the locs list +locs <- locs |> +map(~ { +coords <- st_coordinates(.x) +data.frame( +X = coords[, "X"], +Y = coords[, "Y"], +Year = .x$Year +) }) -} -targets::tar_dir({ # tar_dir() runs code from a temporary directory. -+ targets::tar_script({ -+ tar_file_read(data, get_path(), read_csv(file = !!.x, col_types = cols())) -+ }) -?tar_read -tm -tm$error -tm$data -?tar_target -?tar_option_set -(1.1-1) -(1.1-1)/1 -(1.1-1)/1.1 -getwd() -tar_make +# 6) Apanasovich is TRUE +Apanasovich = TRUE +# 7) scaling = c(1,1,2) -> maybe needs to be list? could also do c(1,2,3) +scaling = c(1,1,2) +pesticide_mvm <- new("MultivariateVecchiaModel", n_neighbors = 10) +# 3) Impute.y = TRUE, impute the missing values in Y +Impute.y = TRUE +?prestogp_fit +soil.mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +locs[[1]] +is.matrix(locs[[1]]) +as.matrix(locs[[1]]) +is.matrix(as.matrix(locs[[1]])) +locs <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(id, Year))) |> +pull(data) +# Update the locs list +locs <- locs |> +map(~ { +coords <- st_coordinates(.x) +mat <- as.matrix(data.frame( +X = coords[, "X"], +Y = coords[, "Y"], +Year = .x$Year +)) +return(mat) +}) +locs[[1]] |> head() +soil.mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +pesticide_covariates[[1]] +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(-cncntrt, -lft_cns, -id, -Year))) |> +pull(data) +pesticide_covariates[[1]] +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ { +selected_data <- .x %>% select(-cncntrt, -lft_cns, -id, -Year) +as.matrix(selected_data) +})) |> +pull(data) +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +# Convert each list element to a matrix (i.e. is.matrix = TRUE) +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ as.matrix(.x %>% select(-cncntrt, -lft_cns)))) |> +pull(data) +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +# Convert each list element to a matrix (i.e. is.matrix = TRUE) +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(-cncntrt, -lft_cns, -id, -Year))) |> +pull(data) +pesticide_covariates +pesticide_covariates[[1]] +pesticide_covariates <- lapply(pesticide_covariates, as.matrix) +pesticide_covariates[[1]] +lapply(pesticide_covariates,length) +# convert to matrix, but retain dimensions +pesticide_covariates <- pesticide_covariates |> +map(~ as.matrix(.x, is.matrix = TRUE)) +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +# Convert each list element to a matrix (i.e. is.matrix = TRUE) +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(-cncntrt, -lft_cns, -id, -Year))) |> +pull(data) +# convert to matrix, but retain dimensions +pesticide_covariates <- pesticide_covariates |> +map(~ as.matrix(.x, is.matrix = TRUE)) +pesticide_covariates[[1]] |> head() +pesticide_covariates[[1]][,1:20] |> head() +# 4) A list of X's, each element is a matrix of the covariates +# For now, we will use the covariates in the data_analysis +# Convert each list element to a matrix (i.e. is.matrix = TRUE) +pesticide_covariates <- data_analysis |> +group_by(ChmclNm) |> +nest() |> +mutate(data = map(data, ~ .x %>% select(-cncntrt, -lft_cns, -id, -id.1, -Year))) |> +pull(data) +# convert to matrix, but retain dimensions +pesticide_covariates <- pesticide_covariates |> +map(~ as.matrix(.x, is.matrix = TRUE)) +soil.mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +pesticide_lod[[1]] +soil.mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +pesticide_lod[[1]] +pesticide_lod[[1]] |> dim() +pesticide_lod[[2]] +pesticide_lod[[3]] +pesticide_lod[[4]] +pesticide_lod[[5]] +pesticide_lod[[6]] +lapply(pesticide_lod,length) +lapply(pesticide_outcomes,length) +soil.mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +pesticide_mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +debug(prestogp_fit) +pesticide_mvm <- prestogp_fit(pesticide_mvm, Y = pesticide_outcomes, lod = pesticide_lod, +impute.y = Impute.y, X = pesticide_covariates, locs = locs, +apanasovich = Apanasovich, scaling = scaling) +undebug(prestogp_fit) +debug(check_input) +debug(PrestoGP::check_input) tar_make() -tar_visnetwork() -tar_visnetwork(targets_only = T) -p3 -p10 +tar_visnetwork(targets_only = T, exclude = c("kfolds_iter","kfolds_iter3", "set_path","readQS")) +sf_plot_outcome_maps <- tar_read(sf_plot_outcome_maps) +sf_plot_outcome_maps +plot_pesticide_maps <- tar_read(plot_pesticide_maps) +plot_pesticide_maps <- tar_read(plot_pesticide_maps, branches = 1) +plot_covariate_maps1 <- tar_read(plot_covariate_maps, branches = 1) +plot_covariate_maps1 +plot_pesticide_maps <- tar_read(plot_pesticide_maps, branches = 1) +plot_pesticide_maps +plot_pesticide_maps <- tar_read(plot_pesticide_maps, branches = 3) +plot_pesticide_maps +explore_skim +library(terra) +r <- terra::rast("/Volumes/set/OpenLandMapData/Bulk_Density/OpenLand_SoilBulkDensity_010cm.tif") +plot(r) +#clip to the US extent +r <- terra::rast("/Volumes/set/OpenLandMapData/OLM_Combined/OLM_US_Crop_Clay_Content.tif") +r +plot(r[[1]]) +plot(r[[6]]) +r <- terra::rast("/Volumes/set/OpenLandMapData/OLM_Combined/OLM_US_Crop_Soil_Order.tif") +plot(r[[1]]) +r +names(r) +plot(r[6]) +plot(r[[6]]) +colnames(sf_pesticide_partition_cleaned[[1]]) +# Create and plot using ggplot an example covariance matrix of 1000 variables +library(MASS) +library(ggplot2) +set.seed(123) +n <- 1000 +Sigma <- matrix(0, n, n) +for (i in 1:n) { +for (j in 1:n) { +Sigma[i, j] <- 0.5^abs(i - j) +} +} +Sigma <- Sigma + diag(n) * 0.1 +X <- mvrnorm(n = 1000, rep(0, n), Sigma) +ggplot(data = as.data.frame(Sigma), aes(x = Var1, y = Var2, fill = Freq)) + +geom_tile() + +theme_minimal() + +scale_fill_gradient(low = "white", high = "blue") + +theme(axis.text.x = element_blank(), +axis.text.y = element_blank(), +axis.ticks = element_blank(), +axis.title.x = element_blank(), +axis.title.y = element_blank()) +head(Sigma) +Sigma <- matrix(0, n, n) +for (i in 1:n) { +for (j in 1:n) { +Sigma[i, j] <- 0.5^abs(i - j) +} +} +Sigma <- Sigma + diag(n) * 0.1 +X <- mvrnorm(n = 1000, rep(0, n), Sigma) +Sigma <- cov(X) +Sigma <- as.data.frame(as.table(Sigma)) +names(Sigma) <- c("Var1", "Var2", "Freq") +ggplot(data = Sigma, aes(x = Var1, y = Var2, fill = Freq)) + +geom_tile() + +theme_minimal() + +scale_fill_gradient(low = "white", high = "blue") + +theme(axis.text.x = element_blank(), +axis.text.y = element_blank(), +axis.ticks = element_blank(), +axis.title.x = element_blank(), +axis.title.y = element_blank()) +n <- 100 +Sigma <- matrix(0, n, n) +for (i in 1:n) { +for (j in 1:n) { +Sigma[i, j] <- 0.5^abs(i - j) +} +} +Sigma <- Sigma + diag(n) * 0.1 +X <- mvrnorm(n = 1000, rep(0, n), Sigma) +Sigma <- cov(X) +Sigma <- as.data.frame(as.table(Sigma)) +names(Sigma) <- c("Var1", "Var2", "Freq") +ggplot(data = Sigma, aes(x = Var1, y = Var2, fill = Freq)) + +geom_tile() + +theme_minimal() + +scale_fill_gradient(low = "white", high = "blue") + +theme(axis.text.x = element_blank(), +axis.text.y = element_blank(), +axis.ticks = element_blank(), +axis.title.x = element_blank(), +axis.title.y = element_blank()) +colnames(sf_pesticide_partition_cleaned[[1]]) +View(sf_pesticide_partition_cleaned) +plot(r[6]) +plot_pesticide_maps <- tar_read(plot_pesticide_maps, branches = 6) +plot_pesticide_maps +data <- sf_pesticide_partition_cleaned[[1]] +states <- st_as_sf(maps::map("state", plot = FALSE, fill = TRUE)) +df_obs <- data |> filter(lft_cns == 0) +df_cens <- data |> filter(lft_cns == 1) +p <- ggplot() + +geom_sf(data = df_cens, size = 0.5) + +geom_sf(data = df_obs, aes(color = cncntrt)) + +# facet_wrap(~ Year) + +scale_color_viridis_c(option = "A", trans = scales::pseudo_log_trans(sigma = 0.005)) + +geom_sf(data = states, fill = NA, size=0.15) + +theme_minimal() + +theme(legend.position = "right") + +ggtitle(data$ChmclNm) +p getwd() -# install.packages("devtools") -devtools::install_github("NIEHS/PrestoGP") -library(PrestoGP) -tar_make() -library(targets) -tar_make() -tar_visnetwork() tar_visnetwork(targets_only = T) -data(soil) -soil <- soil[!is.na(soil[,5]),] # remove rows with NA's -y <- soil[,4] # predict moisture content -X <- as.matrix(soil[,5:9]) -locs <- as.matrix(soil[,1:2]) -# Vecchia model -soil.vm <- new("VecchiaModel", n_neighbors = 10) -soil.vm <- prestogp_fit(soil.vm, y, X, locs) -# Full model -soil.fm <- new("FullModel") -soil.fm <- prestogp_fit(soil.fm, y, X, locs) -# Multivariate model -ym <- list() -ym[[1]] <- soil[,5] # predict two nitrogen concentration levels -ym[[2]] <- soil[,7] -Xm <- list() -Xm[[1]] <- Xm[[2]] <- as.matrix(soil[,c(4,6,8,9)]) -locsm <- list() -locsm[[1]] <- locsm[[2]] <- locs -soil.mvm <- new("MultivariateVecchiaModel", n_neighbors = 10) -?new -soil.mvm <- prestogp_fit(soil.mvm, ym, Xm, locsm) -# Space/elevation model -data(soil250, package="geoR") -y2 <- soil250[,7] # predict pH level -X2 <- as.matrix(soil250[,c(4:6,8:22)]) -# columns 1+2 are location coordinates; column 3 is elevation -locs2 <- as.matrix(soil250[,1:3]) -soil.vm2 <- new("VecchiaModel", n_neighbors = 10) -# fit separate scale parameters for location and elevation -soil.vm2 <- prestogp_fit(soil.vm2, y2, X2, locs2, scaling = c(1, 1, 2)) -soil.mvm -ym -soil -View(soil) -ym -dim(ym) -length*ym -length(ym) -length(xm) -length(Xm) -dim(ym[[1]]) -length(ym[[1]]) -dim(ym[[2]]) -length(ym[[2]]) -dim(Xm[[1]]) -?prestogp_fit -ym[[1]] <- soil[1:100,5] # predict two nitrogen concentration levels -ym[[2]] <- soil[,7] -Xm <- list() -Xm[[1]] <- Xm[[2]] <- as.matrix(soil[,c(4,6,8,9)]) -Xm[[1]] <- Xm[[1]][1:100,] -locsm <- list() -locsm[[1]] <- locsm[[2]] <- locs -locsm[[1]] <- locsm[[1]][1:100,] -soil.mvm <- new("MultivariateVecchiaModel", n_neighbors = 10) -soil.mvm <- prestogp_fit(soil.mvm, ym, Xm, locsm) -soil.mvm -soil.mvm[[1]] -soil.mvm -coef(soil.mvm) -summary(soil.mvm) -sf_pesticide_for_fit <- tar_read(sf_pesticide_for_fit) -sf_pesticide_for_fit -View(sf_pesticide_for_fit) -sf_pesticide_partition_cleaned <- tar_read(sf_pesticide_partition_cleaned) -sf_pesticide_partition_cleaned -sf_pesticide_partition_cleaned[[1]] +tar_visnetwork(targets_only = T, exclude = c("kfolds_iter","kfolds_iter3")) +COMPUTE_MODE <- 1 +path_base <- +ifelse(COMPUTE_MODE == 1, +"/Volumes/SET/Projects/PrestoGP_Pesticides/input/", +ifelse(COMPUTE_MODE == 2, +"/ddn/gs1/group/set/Projects/PrestoGP_Pesticides/input/", +ifelse(COMPUTE_MODE == 3, +"/opt/", +ifelse(COMPUTE_MODE == 4, +"~/Downloads/", +stop("COMPUTE_MODE should be one of 1, 2, 3, or 4.\n") +) +) +) +) +path_base +## TWI +twi <- paste0(path_base, "TWI/CONUS_TWI_epsg5072_30m_unmasked.tif") +twi_ras <- terra::rast(twi) +twi_ras +plot(twi_ras) View(sf_pesticide_partition_cleaned) +<<<<<<< HEAD sf_pesticide_partition_cleaned[[1]] sf_pesticide_partition_cleaned[[2]] sf_pesticide_partition_cleaned <- tar_read(sf_pesticide_partition_cleaned)