cssearcy / AYS-R-Coding-SPR-2020

Coding in R for Policy Analytics
https://cssearcy.github.io/AYS-R-Coding-SPR-2020/
3 stars 3 forks source link

Dashboard: Trouble with Driver 1 & 2 Intoxication? #24

Open jamisoncrawford opened 3 years ago

jamisoncrawford commented 3 years ago

Greetings all - I noticed an issue with the dashboard project script that may give people trouble with the categorical variables: d1.substance and d2.substance.

One of the values has a linebreak, or \n, which makes it difficult to use without a bit of additional preprocessing.

At the very end of our first code chunk, include this code:

dat$d1.substance <- gsub("[\r\n]", "", x = dat$d1.substance)
dat$d1.substance <- gsub(" {1,}", " ", x = dat$d1.substance)

dat$d2.substance <- gsub("[\r\n]", "", x = dat$d2.substance)
dat$d2.substance <- gsub(" {1,}", " ", x = dat$d2.substance)

That should clean up the values and make this cool variable usable!