California-Data-Collaborative / RateComparison

Easily compare the revenue, equity, and demand implications of different water rate structures.
GNU Affero General Public License v3.0
13 stars 4 forks source link

Account growth inputs are static - should change dynamically #47

Closed christophertull closed 7 years ago

christophertull commented 7 years ago

@monobina ran across an error that arises here

#for generating customer class
class_proportions <- as.data.frame(prop.table(table(df$cust_class)), stringsAsFactors = FALSE)

class_proportions$Freq <- c(input$Commercial,input$Institutional, input$Irrigation,input$Other,input$ResidentialMulti, input$ResidentialSingle)

Note how the class_proportions are generated dynamically from the dataframe, but the inputs are hardcoded. This throws an error if there are more (or fewer?) classes in the dataframe than there are inputs. To get around this we should probably generate the account growth inputs in a loop.

The error for reference:

Stack trace (innermost first):
    84: $<-.data.frame
    83: $<- [C:\Users\mmukherjee\Desktop\MNWD\RateRP3.2.9/server.R#62]
    82: <reactive:planneddf> [C:\Users\mmukherjee\Desktop\MNWD\RateRP3.2.9/server.R#62]
    71: planneddf
    70: <reactive:DF> [C:\Users\mmukherjee\Desktop\MNWD\RateRP3.2.9/server.R#511]
    59: df_original
    58: dropNulls
    57: updateSliderInput
    56: observerFunc [R/class_graphs.R#223]
     1: runApp
Warning: Error in $<-.data.frame: replacement has 6 rows, data has 7
monobina commented 7 years ago

@christophertull yes I fixed this in my local code by adding the Recycled input. Is this originally written by @anudeepvanjavakam1 ? one of us can create the loop

christophertull commented 7 years ago

Just a note that this will also need to affect the calls to req(input$ResidentialSingle) etc.

christophertull commented 7 years ago

Closed by #44