Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for AQCU-735 #357

Merged
merged 1 commit into from
Jun 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions R/correctionsataglance-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,29 @@ formatDataList <- function(dataIn, type, ...){
return()
}

if(type == 'APPROVALS' && length(dataIn)>0){
for (i in 1:length(dataIn$endTime)) {
if (as.Date(dataIn$endTime[i]) > "2050-12-31") {
endT <- format(as.Date(dataIn$endTime[i]), format="%m-%d")
endT <- paste0("2050-",endT,"T00:00:00.000-06:00")
dataIn$endTime[i] <- endT
if (!isEmptyOrBlank(type)) {
if(type == 'APPROVALS' && length(dataIn)>0){
for (i in 1:length(dataIn$endTime)) {
if (as.Date(dataIn$endTime[i]) > "2050-12-31") {
endT <- format(as.Date(dataIn$endTime[i]), format="%m-%d")
endT <- paste0("2050-",endT,"T00:00:00.000-06:00")
dataIn$endTime[i] <- endT
}
}
}
}

start <- which(names(dataIn) %in% c('startTime', 'startDate'))
end <- which(names(dataIn) %in% c('endTime', 'endDate'))


if(!type %in% c('APPROVALS', 'META')){
type_i <- which(dataIn$processingOrder == type)
i <- type_i[order(dataIn[[start]][type_i])] #order by start date
} else {
i <- order(dataIn[[start]]) #order by start date
}
}


typeData <- list(startDates = formatDates(dataIn[[start]][i]),
endDates = formatDates(dataIn[[end]][i]),
Expand Down Expand Up @@ -223,6 +227,11 @@ findOverlap <- function(dataList){
dataIn$line_num <- 1

#ordered by applied date for process order data
if (isEmptyOrBlank(dataIn$applyDates)) {
for (i in 1:length(dataIn)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to have the for loop. Just making dataIn$applyDates <- NA will work because data.frame will automatically fill in the other NAs. @mhines-usgs I'll go ahead and make a fix for this since you are traveling!

Example:

dataIn <- list(values = 1:10, dates = 1:10, applyDates = NULL)
as.data.frame(dataIn)

Error in data.frame(values = 1:10, dates = 1:10, applyDates = NULL, check.names = TRUE,  : 
  arguments imply differing number of rows: 10, 0

dataIn <- list(values = 1:10, dates = 1:10, applyDates = NA)
as.data.frame(dataIn)
   values dates applyDates
1       1     1         NA
2       2     2         NA
3       3     3         NA
4       4     4         NA
5       5     5         NA
6       6     6         NA
7       7     7         NA
8       8     8         NA
9       9     9         NA
10     10    10         NA

dataIn[i]$applyDates <- NA
}
}
dataIn_df <- as.data.frame(dataIn, stringsAsFactors = FALSE)
if(any(names(dataIn) %in% 'corrLabel')){
dates_df_ordered <- dataIn_df[order(dataIn_df$applyDates),]
Expand Down