In gtsummary, is there a way to change the text used for a value (the category value, not the label for the category)? - gtsummary

I am using the excellent gtsummary R package.
As an example, my gtsummary table has columns for multiple characteristics of people in a clinical trial and a column for treatment A and treatment B.
For each group I have various characteristics such as gender. In my dataframe gender is listed as "m" or "f" and I want the table to list these as "Male" and "Female".
I know how to change labels e.g label = list( gender ~ "Gender"), but how do I change the values?
(I know I can go into the dataframe and change them there, but can I do this in gtsummary)

Related

Order a grouped column

Is it possible to change the order of a column that's used for row grouping?
e.g.
Country, Account , total
Group rows by Country but display like this:
Account, Total, Country
This can be done manually after the grid is rendered but cannot find a way to render it with this ordering.
I couldn't find an option to order this column to the end of the grid since this column is auto generated by AG-Grid
many thanks
Rob

How to filter one source by clicking and filtering a bar chart from another source in Tableau?

I used an Apriori algorithm to view the frequent relationships in the dataset and I want to do a dashboard to better visualize this data but I don't know how to do this filter.
This is the bar chart that I created to show the support (amount of times something happend) and the confidence (probability of B happening given A) of these associations:
Apriori Chart
Next to it on the dashboard, I'll have a table with the full dataset used in this Apriori analysis where I have more information such as ID, Income, Hours Worked, etc:
Table from different data source
How can I create this relationship? The two data sources don't have a column in common that I can use for that.
I would need some way to:
Split the values in the antecedents columns by comma and filter only those columns with value equal to 1 in the other dataset
**Dataset A**
'Age Range <=30, Joblevel 1, Maritalstatus Single'
->
'Age Range <=30'
'Joblevel 1'
'Maritalstatus Single'
**Dataset B**
'Age Range <=30' == 1
'Joblevel 1' == 1
'Maritalstatus Single' == 1
Clicking this would filter the table next to it
Is there any way I can do this in Tableau?
You can download the tbwx i used in this example here https://community.tableau.com/servlet/JiveServlet/download/1083124-384949/Apriori.twbx
Thanks in advance for the help!
I am not able to check your twbx on the machine I'm using but I think you should be able to do this. The fields in the 2 data sources need to match so manipulate the data sources the make this happen.
For data source 1 there's a function SPLIT which will mean you are able to split the comma separated string to 3 fields.
Putting those 3 fields to the Detail shelf of your bar chart (or even Rows and hiding the header) will mean you can use them in an action filter.
Your second data source is a cross tab - post pivot. You should be able to pivot this data source. Highlight the measures and pivot them. This will give you the field Pivot Field Names and Pivot Field Values.
You only want to keep those with a value of 1 so create a calculated field
[Lookup1]: IF [Pivot Field Values] = 1 THEN [Pivot Field Names] END
Duplicate this field twice so you have Lookup1, Lookup2 and Lookup 3.
Then you should be able to action filter the table.
In the action filter set it up so SplitField1 = Lookup1, SplitField2 = Lookup2, etc.
Fingers crossed this works, I haven't been able to test so I am pulling it out of my head.

Dynamically render multiple columns based on a drop-down list

I have a table in tableau with say 4 columns (Say Employee ID, Name, Address, Email).
I want to provide the users an option to select single/multiple columns from a drop down list (assume in the drop down list we have columns headers, Customfield1, Customfield2.....,Customfield10) which would be added to the table as a separate columns.
Say for Instance if the user selects CustomField1, CustomField2, CustomField3 from the drop-down list then the table should have in total of 7 columns (4 Emp fields + 3 Custom Fields)
Though I stated a simple requirement, my idea was to extrapolate that to something complex.
I think some version of this could be done, albeit in a hacky way. What you're looking for is 'Dynamic Parameters.' They don't technically officially exist in the product, but can be created with the combination of parameter and calculated field.
Here is a link to a method on such creation.
The idea here would be to re-order columns in a custom manner. Each calculated field would have to have its own logic for which dimension it was to display when a user selected a parameter. (ie: With parameter selection A Column 1 goes to [Name] and Column 2 goes to [Address], and with parameter selection B Column 1 goes to [Address] and Column 2 goes to [Name].) The caveat here is that each potential layout would need to have the same number of columns - there is not a way to add columns dynamically. Consider that each column is represented here with a calculated field.
Good luck on it.

Tableau context parameter

I have 3 dimensions in the following hierarchy:
BigC
L SmallC
L Brand
(Having 200 combinations)
I am also creating a calculation using a parameter and multiple case statements.
For eg: CASE WHEN parameter=Brand1 THEN Brand1_field - Impact% END
Now I want my parameter to have only the relevant brand values populated for Big C and Small C rather than all the values. Is it possible?
If this is not possible then can I create a calculated field with a column selection?
If i have understood your question properly, I was able to achieve this using Context filter and Filter by Relevant Values.
Drop both Big Company and Small Company dimensions into Filter Card.
Apply Context Filter for Big Company and "Use only relevant values" for Small Company filter.
So as when you select values for Big Company only the related values of small company will be displayed and so the brands.
Find the workbook here : https://www.dropbox.com/s/txam3wfhz8qirqg/StackOverflowSolution.twbx?dl=0

In the crystal report how to make percentages in the basis of various contents

I want to make a crystal report,in where I create a group in the basis of district.Now I want to insert some of data from the database like as a parentage dependent on various content.How I can make this query in crystal report.
For example -- the percentage of 'sum of age' in the basis of male learners in one text box and the percentage of 'sum of age' in the basis of female learners in another text box.
First create a group for the Age
Create a summary fields (One for Male, One for female) that counts age (Attach a formula for summary that check say gender = 'M' for male)
Create two formula that computed the % from the summary fields (Male, female)
Place this formula on your relevant text box