Current location - Education and Training Encyclopedia - Graduation thesis - How to draw the table 1 (three-line table of basic characteristics) of the paper quickly? You deserve the tableone package.
How to draw the table 1 (three-line table of basic characteristics) of the paper quickly? You deserve the tableone package.
Let's look at the table 1 without any data processing.

As can be seen from the table, numerical variables are described in the form of mean standard deviation, some classified variables are described in the form of frequency percentage, but some classified variables such as stage are described in numerical variables, so we still need to deal with them a little bit to let R know which are numerical variables and which are classified variables.

See which variables the pbc dataset contains.

Select the variables to display.

At this time, we can see that the classified variables can be displayed normally.

Another problem that may be overlooked is that although some variables are numerical variables, they are non-normal, so they cannot be described in the form of mean and standard deviation.

You can see that Billie and CHOL variables have been displayed in the median and quartile.

In a given p value, the classification variables use chi-square test by default; For continuous variables, one-way ANOVA is used by default, and when two groups are used, ANOVA is used for t-test.

However, as I said just now, some numerical variables are not normally distributed, so we can't compare between groups by analysis of variance or t-test. At this time, nonparametric test is needed, and fisher exact test is needed for those who do not meet the chi-square test conditions. For example:

Output the results to excel and put them on disk F:

You can arrange it yourself according to the requirements of the magazine.

Attached:

Numerical variables include: number of missing values, proportion, average standard deviation, interquartile distance and skewness peak.

Factor variables include: number of missing values, proportion, horizontal number, frequency and cumulative frequency.