Skip to content

Commit

Permalink
removed all 1:length(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabutler-usbr committed Oct 27, 2023
1 parent 0ac0483 commit eca601e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions R/get_prism_annual.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ get_prism_annual <- function(type, years, keepZip = TRUE,
### Handle post 1980 data
if(length(uris_post81) > 0){

for(i in 1:length(uris_post81)){
for(i in seq_along(uris_post81)) {
prism_webservice(uris_post81[i],keepZip)
setTxtProgressBar(download_pb, i)
}
Expand All @@ -112,7 +112,7 @@ get_prism_annual <- function(type, years, keepZip = TRUE,
if (length(uris_pre81) > 0) {

pre_files <-c()
for(j in 1:length(uris_pre81)){
for(j in seq_along(uris_pre81)){
tmp <- prism_webservice(
uris_pre81[j],
keepZip,
Expand All @@ -133,7 +133,7 @@ get_prism_annual <- function(type, years, keepZip = TRUE,
pre_files <- unlist(strsplit(pre_files,"\\."))
pre_files <- pre_files[seq(1,length(pre_files),by =2)]

for (k in 1:length(pre_files)) {
for (k in seq_along(pre_files)) {
if (keep_pre81_months) {
# keep the annual data
to_split <- gsub(pattern = "_all", replacement = "", x = pre_files[k])
Expand Down
2 changes: 1 addition & 1 deletion R/get_prism_dailys.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ get_prism_dailys <- function(type, minDate = NULL, maxDate = NULL,
download_pb <- txtProgressBar(min = 0, max = max(length(uris), 1), style = 3)

if(length(uris) > 0){
for(i in 1:length(uris)){
for(i in seq_along(uris)){
prism_webservice(uri = uris[i],keepZip)
setTxtProgressBar(download_pb, i)
}
Expand Down
6 changes: 3 additions & 3 deletions R/get_prism_monthlys.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ get_prism_monthlys <- function(type, years, mon = 1:12, keepZip = TRUE,

### Handle post 1981 data
if(length(uris_post81) > 0){
for(i in 1:length(uris_post81)){
for(i in seq_along(uris_post81)){
prism_webservice(uris_post81[i],keepZip)
setTxtProgressBar(download_pb, i)
}
Expand All @@ -84,7 +84,7 @@ get_prism_monthlys <- function(type, years, mon = 1:12, keepZip = TRUE,
if (length(uris_pre81) > 0) {

pre_files <- c()
for (j in 1:length(uris_pre81)) {
for (j in seq_along(uris_pre81)) {
tmp <- prism_webservice(
uris_pre81[j],
keepZip,
Expand All @@ -103,7 +103,7 @@ get_prism_monthlys <- function(type, years, mon = 1:12, keepZip = TRUE,
pre_files <- unlist(strsplit(pre_files,"\\."))
pre_files <- pre_files[seq(1, length(pre_files), by = 2)]

for (k in 1:length(pre_files)) {
for (k in seq_along(pre_files)) {
yr <- regmatches(pre_files[k], regexpr('[0-9]{4}', pre_files[k]))

if (keep_pre81_months) {
Expand Down
2 changes: 1 addition & 1 deletion R/get_prism_normals.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ get_prism_normals <- function(type, resolution, mon = NULL, annual = FALSE,

mpb <- txtProgressBar(min = 0, max =length(uris), style = 3)

for(i in 1:length(uris)){
for(i in seq_along(uris)){
prism_webservice(uris[i],keepZip)
setTxtProgressBar(mpb, i)

Expand Down
2 changes: 1 addition & 1 deletion R/pd_get_md.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pd_get_md <- function(pd) {
if (length(final_txt_full) == 0) {
stop("No files exist to obtain metadata from.")
}
out <- lapply(1:length(final_txt_full), function(i) {
out <- lapply(seq_along(final_txt_full), function(i) {
readin <- tryCatch(
utils::read.delim(
final_txt_full[i],
Expand Down
4 changes: 2 additions & 2 deletions R/utility_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
mon_to_string <- function(month)
{
out <- vector()
for(i in 1:length(month)){
for(i in seq_along(month)){
if(month[i] < 1 || month[i] > 12) {
stop("Please enter a valid numeric month")
}
Expand Down Expand Up @@ -156,7 +156,7 @@ process_zip <- function(pfile, name)
fstrip <- unlist(lapply(fstrip, function(x) return(x[1])))
unames <- unique(fstrip)
unames <- unames[unames %in% name]
for(j in 1:length(unames)){
for(j in seq_along(unames)){
newdir <- file.path(prism_get_dl_dir(), unames[j])
tryCatch(
dir.create(newdir),
Expand Down

0 comments on commit eca601e

Please sign in to comment.