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

Using the gtsummary package for publication-ready analysis #18

Open aseyingbo1 opened 3 years ago

aseyingbo1 commented 3 years ago

Hi,

I am trying to use the gtsummary package for descriptive analysis and it keeps returning a error - Error in [.tbl_df(MAACData, c(Gender, Race/Ethnicity, Age_cat, Age, : object 'Gender' not found.

MAACData %>% select(Age, Gender, Race/Ethnicity, Age_cat, Grade_cat, Current DFCS Region, Current Placement, Placement Quality, Regular Medical, Teeth Cleanings, Medical/Dental Follow-up, Trauma, Desire to Complete Telephone Interview,
Completed Telephone Interview,
LEADS Involvement (Yes/No))%>% tbl_summary()

Perhaps, there is something I am not doing right. I will appreciate any help.

jamisoncrawford commented 3 years ago

@aseyingbo1 without the data, no one can reproduce your issue and therefore it's much more difficult to diagnose.

However, since I recall working with you on these data yesterday, I can provide a bit of help from memory. Though my memory isn't eidetic!

So Gender isn't found, according to your error. That can mean a few things - since you didn't use data$Gender syntax, it might mean that dplyr wasn't loaded with library(). But then it would not recognize select(), either.

What might cause this, then, is some change to Gender in the previous code. Did you rename it? Did you remove it? Something upstream is affecting it, since it should work with the code you've provided.

jamisoncrawford commented 3 years ago

After looking at your .Rmd file, try removing install.packages("forcats") from your code.

Running install.packages() in a .Rmd file pretty much guarantees errors!