0

I have a dataframe where I read a csv like so to convert characters to factors

sim_df <- read.csv("test.csv", stringsAsFactors=T) 

How can I do this without the stringsAsFactors argument and use dplyr syntax?

For example it would look something like so..

sim_df <- read.csv("text.csv") %>% mutate(<something to convert all string columns to factors>)

Thanks!

Eisen
  • 1,697
  • 9
  • 27
  • 3
    `%>%mutate(across(where(is.character), factor))` – Onyambu Oct 25 '21 at 15:30
  • 1
    Does this answer your question? [Convert all data frame character columns to factors](https://stackoverflow.com/questions/20637360/convert-all-data-frame-character-columns-to-factors) – Nad Pat Oct 25 '21 at 15:31
  • Can you do a mutate state with multiple across statements? – Eisen Oct 25 '21 at 15:31

0 Answers0