Closed SixiangHu closed 8 years ago
rateComp <- function(df,fac,peril,reorder=FALSE){ df_sub <- filter(df,(KEY==fac) & (Peril == peril)) if(reorder){ suppressWarnings(min_x <- min(as.numeric(df_sub$Level1),na.rm = TRUE)) suppressWarnings(max_x <- max(as.numeric(df_sub$Level1),na.rm = TRUE)) suppressWarnings(oth_lvl <- as.character(df_sub$Level1[is.na(as.numeric(df_sub$Level1))])) df_sub$Level1 <- ordered(factor(df_sub$Level1,levels=c(paste(min_x:max_x),oth_lvl))) } df_sub <- df_sub[order(df_sub$Level1),] plot_ly(df_sub,x=Level1,y=Value.x, xaxis = "x1", yaxis = "y1",name="Model1") %>% add_trace(df,x=Level1,y=Value.y, xaxis = "x1", yaxis = "y1",name="Model2") %>% layout(xaxis=list(title=fac),yaxis=list(title=peril)) }
Closed as put everything together in #38