### In the summary of recent years, let’s share some drawing operations, basic knowledge and learn more

### Today, we share the R package ggstatsplot, a very perfect mapping R package. Let’s take a look at the mapping capabilities of this package.

# 1. installation and loading of R package

```
install.packages("ggstatsplot")
install. Packages ("rstantools") \
install. Packages ("AFEX") \\
Library (ggstatsplot) \
```

R package get! Next, we will introduce several main functions contained in it one by one.

# 2. ggbetweenstats(): mean comparison among multiple groups

### First, take the mean comparison between multiple groups as an example to verify whether it is really possible to draw a line of code. Next, we will use the iris data set in R.

```
ggbetweenstats(data = iris, x = Species, y = Sepal.Length)
```

#### How awesome! Only one line of code, but you gave me so much! It’s unfair! You can do more things like this in the future!

#### however! There is too much information in the above picture. What do they mean? See the following figure:

#### In a word, the upper part of the picture represents some statistical values of traditional statistical methods (frequentist), and the lower part represents some statistical values of Bayesian.**At the end of the article, we will introduce how to simplify the output information of pictures**For example, remove the content of Bayes. Now move on to the other functions.

# 3. ggwithinstats(): repeat measurement

### If a group is collected at multiple time points, this situation belongs to**Repeated measurement design**, the above-mentioned mean comparison among multiple groups cannot be used because the principle of independence has been violated. In this case, the diagram can be drawn as follows:

```
ggwithinstats(data = iris, x = Species, y = Sepal.Length)
```

#### It should be noted that,**For demonstration, the Xiaobian still uses the iris data set. In the repeated measurement data, the x-axis usually refers to different times**。 The red line in the above figure is to indicate that they are paired.

# 4. ggscatterstats(): scatter diagram

#### When studying two continuous variables, the scatter diagram can show the relationship between them. The following is one line:

```
ggscatterstats(data = iris, x = Sepal.Length, y = Sepal.Width)
```

#### In addition to displaying the scatter diagram, the histograms of the two variables are also drawn, so that their distribution can be observed. It is very practical!

# 5. gghistostats(): histogram

#### If**I have a continuous variable, and I want to observe its distribution**, and whether it is different from a specific value through a single sample t-test, you can do this:

```
gghistostats(data = iris, x = Sepal.Length, test.value = 6)
```

# 6. ggcorrmat(): correlation diagram of multiple variables

#### For a while**Presents the relationship of multiple continuous variables**, you can select the correlation matrix. The iris dataset is also used below. First, the variable “specifications” needs to be eliminated, and then the diagram is drawn:

```
ggcorrmat(data = iris[, -5])
```

#### It is also very practical, especially in the exploratory analysis stage. By default, Pesrson correlation analysis (parametric test) is used. The above contains**X**The box of indicates that there is no statistical significance.

# 7. ggpiestats(): pie chart

#### If any**Two categorical variables, which want to compare the rates by chi square test**, it can be drawn in the form of pie chart. Use to mtcars dataset:

```
ggpiestats(data = mtcars, x = am, y = vs)
```

# 8. ggbarstats(): a histogram showing categorical variables

#### In addition to using the pie chart above, you can also use the histogram:

```
ggbarstats(data = mtcars, x = am, y = vs)
```

# 9. ggcoefstats(): plot the regression coefficient

#### For example, a**Linear regression model, now you want to plot the regression coefficients of independent variables**, you can do this:

```
mymodel <- lm(mpg ~ cyl + disp + hp, data = mtcars)
Ggcoefstats (mymodel) \
```

#### It’s very fresh and refined. Do you have any

# 10. one line of code to get everything done? Nothing is so easy in the world!

Although it is said that dream is one line of code to get everything done, it is impossible in reality!

Here is an example of how to further adjust the output image to meet your needs. Take the scatter diagram in part 4 as an example:

For example, Bayes is not used in the research, so we want to**Delete a list of statistical values at the bottom of the picture**, and feel**Sepal. The variable length does not conform to the normal distribution**, so**Select Spearman**Correlation (Pearson correlation by default), you can do this:

```
ggscatterstats(data = iris, x = Sepal.Length, y = Sepal.Width,
bf. Message = false, \\
Type = "nonparametric") \\
```

### Here is just a small example. This package can also modify many parameters. Due to the limited space, it is impossible to introduce them one by one. Interested partners can check the following two documents for in-depth understanding.

### Well, that’s all for today. If it helps, remember to share it with those who need it!

**Life is good, it’s better to have you**