Hello,
I've been trying to run some code that had worked previously but now I'm receiving an error.
I'm importing a large data set that includes columns of dates along with NA values. R doesn't recognize the dates as such and imports the data as factors. As part of the initial data clean up, I'm converting the factors to dates and then creating additional columns to turn the presence of a date into a 1 and the absence a 0 with dplyr::mutate. Here's the code I run:
library(dplyr)
library(chron)
library(lubridate)
#Convert Inquiry, Prospect, Final Decision Date, Started, Submitted, Marked Complete, Moved to ERP, Admitted, Denied, Confirmed, Withdrawn, Enrolled columns from Factors to Dates
adm$Inquiry <- as.Date(adm$Inquiry, "%m/%d/%Y")
adm$Prospect <- as.Date(adm$Prospect, "%m/%d/%Y")
adm$Final.Decision.Date <- as.Date(adm$Final.Decision.Date, "%m/%d/%Y")
adm$Started <- as.Date(adm$Started, "%m/%d/%Y")
adm$Submitted <- as.Date(adm$Submitted, "%m/%d/%Y")
adm$Marked.Complete <- as.Date(adm$Marked.Complete, "%m/%d/%Y")
adm$Moved.to.ERP <- as.Date(adm$Moved.to.ERP, "%m/%d/%Y")
adm$Admitted <- as.Date(adm$Admitted, "%m/%d/%Y")
adm$Denied <- as.Date(adm$Denied, "%m/%d/%Y")
adm$Confirmed <- as.Date(adm$Confirmed, "%m/%d/%Y")
adm$Withdrawn <- as.Date(adm$Withdrawn, "%m/%d/%Y")
adm$Enrolled <- as.Date(adm$Enrolled, "%m/%d/%Y")
#Creating a new column that will convert the date in the Inquriy column into a 1 if the date value is on or before today's date.
adm$InquiryCount <- dplyr::mutate(adm$InquiryCount <- ifelse(adm$Inquiry <= today(tzone=""), 1, 0))
adm$ProspectCount <- dplyr::mutate(adm$ProspectCount <- ifelse(adm$Prospect <= today(tzone=""), 1, 0))
adm$FinalDecCount <- dplyr::mutate(adm$FinalDecCount <- ifelse(adm$Final.Decision.Date <= today(tzone=""), 1, 0))
adm$StartCount <- dplyr::mutate(adm$StartCount <- ifelse(adm$Started <= today(tzone=""), 1, 0))
adm$SubmitCount <- dplyr::mutate(adm$SubmitCount <- ifelse(adm$Submitted <= today(tzone=""), 1, 0))
adm$CompleteCount <- dplyr::mutate(adm$CompleteCount <- ifelse(adm$Marked.Complete <= today(tzone=""), 1, 0))
adm$MoveERPCount <- dplyr::mutate(adm$MoveERPCount <- ifelse(adm$Moved.to.ERP <= today(tzone=""), 1, 0))
adm$AdmitCount <- dplyr::mutate(adm$AdmitCount <- ifelse(adm$Admitted <= today(tzone=""), 1, 0))
adm$DenyCount <- dplyr::mutate(adm$DenyCount <- ifelse(adm$Denied <= today(tzone=""), 1, 0))
adm$ConfirmCount <- dplyr::mutate(adm$ConfirmCount <- ifelse(adm$Confirmed <= today(tzone=""), 1, 0))
adm$WithdrawCount <- dplyr::mutate(adm$WithdrawCount <- ifelse(adm$Withdrawn <= today(tzone=""), 1, 0))
adm$EnrollCount <- dplyr::mutate(adm$EnrollCount <- ifelse(adm$Enrolled <= today(tzone=""), 1, 0))
When I run the code I receive the following error:
Error in UseMethod("mutate_") :
no applicable method for 'mutate_' applied to an object of class "c('double', 'numeric')"
The new columns are created properly in the data frame and I can move forward, but when I attempt to run a shiny app locally or publish to shinapps.io, the error blocks the deployment of the app.
Any thoughts?