@@ -493,7 +493,7 @@ You can learn which stat a geom uses, as well as what variables it computes by v
 | 
			
		||||
 | 
			
		||||
Stats are the most subtle part of plotting because you do not see them in action. `ggplot2` applies the transformation and stores the results behind the scenes. You only see the finished plot. Moreover, `ggplot2` applies stats automatically, with a very intuitive set of defaults. As a result, you rarely need to adjust a geom's stat. However, you can do three things with a geom's stat if you wish to.
 | 
			
		||||
 | 
			
		||||
First, you can change the stat that the geom uses with the geom's stat argument. In the code below, I change the stat of `geom_bar()` from count (the default) to identity. This let's me map the height of the bars to the raw values of a $y$ variable. 
 | 
			
		||||
First, you can change the stat that the geom uses with the geom's stat argument. In the code below, I change the stat of `geom_bar()` from count (the default) to identity. This lets me map the height of the bars to the raw values of a $y$ variable. 
 | 
			
		||||
 | 
			
		||||
```{r}
 | 
			
		||||
demo <- data.frame(
 | 
			
		||||
@@ -507,7 +507,7 @@ ggplot(data = demo) +
 | 
			
		||||
demo
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
I provide a list of the stats that are availalbe to use in ggplot2 at the end of this section. Be careful when you change a geom's stat. Many combinations of geoms and stats will create incompatible results. In practice, you will almost always use a geom's default stat.
 | 
			
		||||
I provide a list of the stats that are available to use in ggplot2 at the end of this section. Be careful when you change a geom's stat. Many combinations of geoms and stats will create incompatible results. In practice, you will almost always use a geom's default stat.
 | 
			
		||||
 | 
			
		||||
Second, you can give some stats arguments by passing the arguments to your geom function. In the code below, I pass a width argument to the count stat, which controls the widths of the bars. `width = 1` will make the bars wide enough to touch each other.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user