Hi there,
Thanks for the help. Here is the reprex:
visit
#> Error in eval(expr, envir, enclos): object 'visit' not found
library(stringr)
get_seconds <- function(x) {
res <- as.numeric(str_match(x, "(\\d+).(\\d{1,2}\\.?\\d{0,2}).")[2:3])
res[1]*60+res[2]
}
modifiedtimes <- visit %>%
mutate(format_duration=map(avg_duration,get_seconds))
#> Error in eval(lhs, parent, parent): object 'visit' not found
modifiedtimes %>%
unnest()
#> Error in eval(lhs, parent, parent): object 'modifiedtimes' not found
Created on 2019-12-01 by the reprex package (v0.3.0)
Here is a datapasta of the dataframe:
data.frame(
total_sessions = c(4L, 5L, 14L, 1L, 1L, 1L),
total_bounce_rate = c(0.25, 0.4, 0.35714, 1, 0, 0),
total_carts = c(0L, 1L, 4L, 0L, 0L, 0L),
total_checkouts = c(0L, 1L, 3L, 0L, 0L, 0L),
total_conversion = c(0, 0, 0, 0, 0, 0),
total_orders_placed = c(0L, 0L, 0L, 0L, 0L, 0L),
total_pageviews = c(19L, 24L, 87L, 1L, 3L, 14L),
format_duration = c(542.75, 528, 294.92, NA, 67, 244),
day = as.factor(c("1/1/18", "1/1/18", "1/1/18", "1/1/18",
"1/1/18", "1/1/18")),
ua_form_factor = as.factor(c("Desktop", "Desktop", "Desktop",
"Desktop", "Desktop", "Desktop")),
location_region = as.factor(c("Maryland", "Victoria", "Illinois",
"Ar Riyad", "Canterbury",
"Stockholms Lan")),
avg_duration = as.factor(c("9m2.75s", "8m48s", "4m54.928571428s",
"0s", "1m7s", "4m4s"))
)
While values are showing up here, for the format_duration column, when I print the df, they appear as <dbl[1]> and can't be passed into my linear model.
Thanks for your help!