GeoDataRead reads a data-frame and processes it for GeoLift.
The function will clean the data, generate a time variable that
increases by 1 for each time period (day/week/month), and aggregate
the data by time and location. It is important to have data for each
location and time-period and avoid special characters in the names of
the geographical units.
Usage
GeoDataRead(
data,
date_id = "date",
location_id = "location",
Y_id = "units",
format = "mm/dd/yyyy",
X = c(),
summary = FALSE,
keep_unix_time = FALSE
)Arguments
- data
A data.frame containing the historical conversions by geographic unit. It requires a "locations" column with the geo name, a "Y" column with the outcome data (units), a time column with the date, and covariates. Valid date formats are: "mm/dd/yyyy", "mm-dd-yyyy", "mm.dd.yyyy", "mmddyyyy", "dd/mm/yyyy", "dd-mm-yyyy", "dd.mm.yyyy", "ddmmyyyy", "yyyy/mm/dd", "yyyy-mm-dd", "yyyy.mm.dd", "yyyymmdd", "ww/yyyy", "ww-yyyy", "ww.yyyy", "wwyyyy", "yyyy/ww", "yyyy-ww", "yyyy.ww", "yyyyww", "mm/yyyy", "mm-yyyy", "mm.yyyy", "mmyyyy", "yyyy/mm", "yyyy-mm", "yyyy.mm", "yyyymm"
- date_id
Name of the date variable (String).
- location_id
Name of the location variable (String).
- Y_id
Name of the outcome variable (String).
- format
Format of the dates in the data frame.
- X
Vector with covariates names.
- summary
Display a summary of the data-reading process. FALSE by default.
- keep_unix_time
A logic flag indicating whether to keep a column with each event's unix time.
Examples
geo_test <- GeoDataRead(GeoLift_Test, date_id = "date", location_id = "location",
Y_id = "Y", format = "yyyy-mm-dd")
head(geo_test)
#> location time Y
#> 1 atlanta 1 3384
#> 2 atlanta 2 3904
#> 3 atlanta 3 5734
#> 4 atlanta 4 4311
#> 5 atlanta 5 3686
#> 6 atlanta 6 3374