I am trying to create a cross tab table that is weighted. The counts appear like this 100000 and I would like them to appear like this 100,000. I also would like to export to a jpg. Any ideas on how to do that? While i'm using sjpot, i'm open to anything that will do the job and provides both counts and percentages.
Hi @dtlbyrd, it would help us a lot if you could produce a more complete reprex, or reproducible example, that includes a bit of sample data. The context helps us see which data is going into the crosstab so that we can pinpoint what's going wrong
Sorry about that. I'm a former SAS and Stata user, and have no experience with R. The reprex doesn't work with my version of R.
Goal: My goal is to create a table like this that has commas for thousands delimiters. This example doesn't have that.
Problem: I'm using sjplot (to create the above plot), and I have also tried xtable and crosstab. All of the results have been the same, no comma delimiters for numbers. I am working with weighted survey data.
Does anyone know how to modify sjplot to produce a chart where numbers have thousands delimiters or know another package that can accomplish this task
No worries, @dtlbyrd I'm mostly looking to understand what columns are in your data frame (KFF2017) and what some of the values look like.
I'm not super familiar with how the cross tab table works, but I'd suggest creating the pre-formatted values as separate columns and then using those in your table. The scales package, which is used by ggplot2, comes with a heap of really easy to use formatting functions for numbers, percentages, currencies, etc.. I'd recommend using those first, and then pass the formatted columns in. That way you don't need to modify sjPlot; you just need to prep the data yourself
General question - general answer No reprex - no code
But we can try to solve it anyway.
Conceptually, you have a cross-tab, and you need the values in the rows and columns to be formatted the way you want (with a coma), right?
I'd take a few steps: Wrange the data to get all values of the same type into one column (dplyr::gather()), then style it the way I want it (scales package), and then spread() back. Conceptually, that's what I'd try to do if this was my task.
Without a reprex I'm not sure if anyone can help you any further than providing some general ideas.
Hope this helps.