You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chk_row_items<- as.vector(unlist(lapply(descr_proc, function(x) (length(x) %%2) ==0))) # check that I have an even number of columns (normally 8 but can be fewer too) then concatenate the columns by pairs of consecutive items
849
-
850
-
if (!all(chk_row_items)) {
851
-
idx_not<- which(!chk_row_items)
852
-
853
-
for (idx_iinidx_not) {
854
-
item_i<-descr_proc[[idx_i]]
855
-
if (length(item_i) == (len_desc_even-1)) { # we expect that only the time is missing
856
-
857
-
# This is the current exception:
858
-
# RGT 1264 15-Dec-2020 DOY 350 Cycle 9 # midnight time is missing, i.e. "00:00:00" (time)
859
-
# RGT 1264 16-Dec-2020 00:01:00 DOY 351 Cycle 9 # after midnight case (as expected)
860
-
861
-
item_i<- append(x=item_i, values="00:00:00", after=3) # add the time after the date
862
-
descr_proc[[idx_i]] <-item_i
863
-
} else { # throw an error in any other case
864
-
len_dif<-len_desc_even- length(item_i)
865
-
stop(glue::glue("We expect a difference of maximum one and received a difference of length {len_dif}, which means {len_dif} attributes are missing from the character string!"))
835
+
# ---- PREVIOUS CODE (commented out) ----
836
+
# descr_proc <- strsplit(x = sf_objs$Description, split = " ") # in case that I have a 'Description' column, split by empty space
837
+
# # ........................................................................... "start" error case with missing 'time' for midnight on Windows
# chk_row_items <- as.vector(unlist(lapply(descr_proc, function(x) (length(x) %% 2) == 0))) # check that I have an even number of columns (normally 8 but can be fewer too) then concatenate the columns by pairs of consecutive items
848
+
# if (!all(chk_row_items)) {
849
+
# idx_not <- which(!chk_row_items)
850
+
# for (idx_i in idx_not) {
851
+
# item_i <- descr_proc[[idx_i]]
852
+
# if (length(item_i) == (len_desc_even - 1)) { # we expect that only the time is missing
853
+
# # This is the current exception:
854
+
# # RGT 1264 15-Dec-2020 DOY 350 Cycle 9 # midnight time is missing, i.e. "00:00:00" (time)
855
+
# # RGT 1264 16-Dec-2020 00:01:00 DOY 351 Cycle 9 # after midnight case (as expected)
856
+
# item_i <- append(x = item_i, values = "00:00:00", after = 3) # add the time after the date
857
+
# descr_proc[[idx_i]] <- item_i
858
+
# } else { # throw an error in any other case
859
+
# len_dif <- len_desc_even - length(item_i)
860
+
# stop(glue::glue("We expect a difference of maximum one and received a difference of length {len_dif}, which means {len_dif} attributes are missing from the character string!"))
chk_row_items<- as.vector(unlist(lapply(descr_proc, function(x) (length(x) %%2) ==0))) # check that I have an even number of columns (normally 8 but can be fewer too) then concatenate the columns by pairs of consecutive items
901
+
if (!all(chk_row_items)) {
902
+
idx_not<- which(!chk_row_items)
903
+
for (idx_iinidx_not) {
904
+
item_i<-descr_proc[[idx_i]]
905
+
if (length(item_i) == (len_desc_even-1)) { # we expect that only the time is missing
906
+
# This is the current exception:
907
+
# RGT 1264 15-Dec-2020 DOY 350 Cycle 9 # midnight time is missing, i.e. "00:00:00" (time)
908
+
# RGT 1264 16-Dec-2020 00:01:00 DOY 351 Cycle 9 # after midnight case (as expected)
909
+
item_i<- append(x=item_i, values="00:00:00", after=3) # add the time after the date
910
+
descr_proc[[idx_i]] <-item_i
911
+
} else { # throw an error in any other case
912
+
len_dif<-len_desc_even- length(item_i)
913
+
stop(glue::glue("We expect a difference of maximum one and received a difference of length {len_dif}, which means {len_dif} attributes are missing from the character string!"))
descr_proc<- strsplit(x=x$Description, split="") # in case that I have a 'Description' column, split by empty space
1573
-
chk_row_items<- as.vector(unlist(lapply(descr_proc, function(x) (length(x) %%2) ==0))) # check that I have an even number of columns (normally 8 but can be fewer too) then concatenate the columns by pairs of consecutive items
1574
-
if (!all(chk_row_items)) stop("It seems that after splitting the observations by empty space the number of columns (per row) are not an even number (vsi function)!", call.=F)
# descr_proc <- strsplit(x = x$Description, split = " ") # in case that I have a 'Description' column, split by empty space
1621
+
# chk_row_items <- as.vector(unlist(lapply(descr_proc, function(x) (length(x) %% 2) == 0))) # check that I have an even number of columns (normally 8 but can be fewer too) then concatenate the columns by pairs of consecutive items
1622
+
# if (!all(chk_row_items)) stop("It seems that after splitting the observations by empty space the number of columns (per row) are not an even number (vsi function)!", call. = F)
1623
+
# descr_proc <- lapply(descr_proc, function(x) {
1624
+
# seq_item <- seq(from = 1, to = length(x), by = 2)
descr_proc<- strsplit(x=x$Description, split="") # in case that I have a 'Description' column, split by empty space
1636
+
chk_row_items<- as.vector(unlist(lapply(descr_proc, function(x) (length(x) %%2) ==0))) # check that I have an even number of columns (normally 8 but can be fewer too) then concatenate the columns by pairs of consecutive items
1637
+
if (!all(chk_row_items)) stop("It seems that after splitting the observations by empty space the number of columns (per row) are not an even number (vsi function)!", call.=F)
0 commit comments