0

I was have a problem when I want to join / combine like this

df_pros <- dbGetQuery(con, "SELECT * FROM pros
                          order by nama_cmo ASC")
    df_pros <- df_pros %>%mutate(status = ifelse(
      as.Date(scheduled_followup) > as.Date(Sys.Date()), "Terjadwal",
      ifelse(as.Date(scheduled_followup) < as.Date(Sys.Date()), " Terlewati",
             " Today")))
  df_prosfu <- dbGetQuery(con, "SELECT distinct *
  FROM pros_fu f
 
where (f.hasil_fu ='Survey' AND f.tgl_nextfollowup::date  <= current_date)
")
totaldariprospek <- observe({
start = input$drange[1]
end = input$drange[2]
date_numb <- as.Date(end) - as.Date(start)
numdays = as.numeric((date_numb)+1)

after i write observe then i want to make a query like this :

df_summ <- df_pros %>%  dplyr::select(-prospek_id,hasil_fu) %>% 
 group_by(nama_cmo) %>% filter(as.Date(create_at) >= start & as.Date(create_at) <= end) %>% 
 count() %>% rename(`Total Prospek` = n)%>%
 rename(`Nama CMO` = nama_cmo)%>% 
 mutate(`Target Prospek` = 5*numdays)%>%
 mutate(`Achievment` = percent(`Total Prospek` /`Target Prospek`))

the i want to combine / join with this query too :

 fu_summ <- df_prosfu %>% dplyr::select(-prospek_id) %>% group_by(nama_cmofu) %>% filter(as.Date(tgl_followup) >= start & as.Date(tgl_followup) <= end) %>% 
     count() %>% rename(`Terlaksana` = n) %>%rename(`CMO FollowUp` = nama_cmofu )%>%
     mutate(`Terjadwal & Terlewati` = 10)%>%
     mutate(`Achievment FollowUp` = percent(`Terlaksana` /`Terjadwal & Terlewati`))

but error is : Warning: Error in setkeyv: some columns are not in the data.table: prospek_id ,

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Where is `df_prosfufu` defined? What is the exact error message you get? – MrFlick May 21 '21 at 06:32
  • 1
    Is this in `shiny` context? – Sinh Nguyen May 21 '21 at 06:33
  • i will edit full of my code please help me –  May 22 '21 at 00:45

0 Answers0