We have up-to-date data about microprocessors manufacture.
These are integrated chips that contain many transistors, and enable the modern world as it is
Transistors are one of the most important inventions
transistors <- read_tsv("Transistor_count_2020.txt")
model <- lm(log(count) ~ Date, data=transistors)
transistors$predicted <- exp(predict(model))
We add a column with the predicted number of transistors per chip
We need to fit a log-log linear model and add a new column with the predicted values
kleiber %>% ggplot(aes(x=kg, y=kcal)) +
scale_x_log10(labels = scales::label_number(accuracy=0.1)) +
scale_y_log10() + geom_point(alpha=0.5) +
geom_line(aes(x=kg, y=predicted)) -> p
Notice that we use labels = scales::label_number()
to change the number’s format on the x axis.
There are many options in the scales
package
print()
itp
We can choose a theme for the general look
If you take a picture with your camera, it usually gets saved as JPG
When we make a plot in RMarkdown, by default it is saved as a PNG file
If you are writing a paper, you may want to save it as PDF of SVG
How do we choose the format?
The difference is seen when you zoom in
device
To store the image as SVG, use dev="svg"
in the RMarkdown code chunk
```{r dev="svg"}
ggplot(students, aes(x=height_cm, y=weight_kg)) + geom_point()
```
You can set the default device at the beginning of the RMarkdown file, with the command
We can save any ggplot image with the command
Only filename
is mandatory. Other arguments are optional
If we omit the option plot=
, it will save the last one
Option device=
can be “pdf”, “tiff”, “jpeg”, “png”, “svg”, or several others
For more details, use
In particular
R packages usually include examples and an explanation document, called vignettes
Try the command