3 ms·
Or just avoid using factors in the first place. Character vectors are usually more appropriate and a modern ingest pipeline won't produce factors in the first p
by hadley 11y ago
Or just avoid using factors in the first place. Character vectors are usually more appropriate and a modern ingest pipeline won't produce factors in the first place.
- minimaxir 11y agoThanks to readr's stringsAsFactors=F default, I've fortunately been avoiding unexpected issues due to factoring. However, the default R functions still load data as factors and I have bad memories of that catching me by surprise, particularly when performing mathematical operations on vectors which are secretly factors and silently getting wrong results. I still need to use factors with ggplot2 though for discrete orders. (E.g bar chart sorting)
- hadley 11y agoYeah I've been thinking about making a new class based on top of character vectors that allows custom ordering
- rabboRubble 11y agoAfter much frustration with a project I'm working on, yesterday I stumbled across using data.frame instead of cbind. Are you maybe Hadley Wickham? If yes, you probably already know this :-) My brother bought me "Advanced R" for Christmas. edit: data.frame, not read.table
- washedup 11y agoSo glad that stringsAsFactors exists. Saves me a lot of time.
- washedup 11y agoCouldn't agree more. New users I help often get stuck when they run into factors. Skip the whole class! Strings are the way to go.
- baldfat 11y agoreadr - Doesn't place factors in the first place. R reader written by Hadley Wickham https://cran.r-project.org/web/packages/readr/README.html https://cran.r-project.org/web/packages/readr/README.html