tidyverse

How can I add stars to broom package's tidy() function output?

喜夏-厌秋 提交于 2020-11-27 01:53:28
问题 I have been using the broom package's tidy() function in R to print my model summaries. However, the tidy() function returns p-values without stars, which makes it a bit weird for many people who are used to seeing stars in model summaries. Does anyone know a way to add stars to the output? 回答1: We can use a convenient function stars.pval from gtools to do this library(gtools) library(broom) library(dplyr) data(mtcars) mtcars %>% lm(mpg ~ wt + qsec, .) %>% tidy %>% mutate(signif = stars.pval

Convert all columns to characters in a data.frame

Deadly 提交于 2020-11-26 00:21:02
问题 Consider a data.frame with a mix of data types. For a weird purpose, a user needs to convert all columns to characters. How is it best done? A tidyverse attempt at solution is this: map(mtcars,as.character) %>% map_df(as.list) %>% View() c2<-map(mtcars,as.character) %>% map_df(as.list) when I call str(c2) it should say a tibble or data.frame with all characters. The other option would be some parameter settings for write.csv() or in write_csv() to achieve the same thing in the resulting file

Convert all columns to characters in a data.frame

Deadly 提交于 2020-11-26 00:05:29
问题 Consider a data.frame with a mix of data types. For a weird purpose, a user needs to convert all columns to characters. How is it best done? A tidyverse attempt at solution is this: map(mtcars,as.character) %>% map_df(as.list) %>% View() c2<-map(mtcars,as.character) %>% map_df(as.list) when I call str(c2) it should say a tibble or data.frame with all characters. The other option would be some parameter settings for write.csv() or in write_csv() to achieve the same thing in the resulting file