Merge a column with an integer and a double together in r -


i trying merge 2 columns 1 of integer, , other double. however, coalesce not work. have tried use ifelse , not work: converts double integer inaccurate.

fd$t9_2_ext_dv <- (sample.int(101,size=100,replace=true)-1)/100 fd$t9_2_mod_dv <- (sample.int(101,size=100,replace=true)-1)

    workings_h2_t9 <- fd %>%     select(c(t9_2_ext_dv, t9_2_mod_dv)) %>%     mutate(dv1 = coalesce(t9_2_ext_dv, t9_2_mod_dv),            con = ifelse(is.na(t9_2_mod_dv), 0, 1))  %>%     select(c(dv1, con)) %>%      na.omit  error in mutate_impl(.data, dots) :    vector 1 has type 'double' not 'integer'  tibble: 6 × 2   t9_2_ext_dv t9_2_mod_dv         <int>       <dbl> 1          na          na 2          na          na 3          na          na 4          na          na 5          na          na 6          na          na 

convert integer column double as.numeric(), coalesce

workings_h2_t9 <- fd %>% select(c(t9_2_ext_dv, t9_2_mod_dv)) %>% mutate(dv1 = coalesce(as.numeric(t9_2_ext_dv), t9_2_mod_dv))  %>% select(dv1) %>%  na.omit 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -