And I apologize in advance for the silly question. Just teach ... I am trying to parse the material from the tutorial.
https://ru.it-brain.online/tutorial/ggplot2/ggplot2_working_with_axes/
In particular, I'm trying to highlight a segment on the chart. But for some reason, it is not the area I line that is displayed.
Here is my code.
---
title: "Pres"
output:
html_document:
#code_folding: hide
css: Проба.css
df_print: paged
toc_float: yes
pdf_document:
latex_engine: xelatex
word_document: default
mainfont: Times New Roman
---
```{r}
library("readr")
library("data.table")
library("here")
library("DT")
library("ggplot2")
```
```{r}
this_dir <- here()
setwd(this_dir)
```
```{r}
data_file_name<-"Проба.csv"
```
```{r}
data_file <- fread(data_file_name, showProgress = TRUE, sep = ";", quote = "", header = TRUE, stringsAsFactors=TRUE)
```
# {.tabset }
## Ttab 1
```{r}
datatable(data_file,
rownames = FALSE,
options = list(
columnDefs = list(list(className = 'dt-center', targets = 0:4))
)
)
```
## Ttab 2
```{r}
pts <- function(data, xcol, ycol, ccol, name_ccol, title) {
x_var <- enquo(xcol)
y_var <- enquo(ycol)
c_col <- enquo(ccol)
#name_c_col<- enquo(name_ccol)
c_title<- enquo(title)
ggplot(data, aes(x = !!x_var, y = !!y_var, colour = !!c_col)) +
geom_point(
asp = 1,
pch = 0,
cex = 4
) +
annotate("segment", x = 5, xend = 20, y = 5, yend = 20, colour = "purple", alpha=1, size=1) +
labs(y="Petal length (cm)", x = "Sepal length (cm)", colour = name_ccol) +
ggtitle(c_title) +
theme(legend.position="bottom",
legend.title = element_text(colour = "blue", size = 10, face = "bold"),
legend.text = element_text(colour = "#00FF00", size = 8, face = "bold"))
}
pts(data_file, `№ кв.`, `№ подъезда`, `Возраст`, "№\nпадика",`Название диаграммы`)
```
###
<p style="font-family: times, serif; font-size:14pt; font-style:italic">
Здесь текст
</p>
Please tell me what I'm doing wrong.
Here are all the files I used, in particular: - the code itself, - the css file, - the data file.
This is what I was trying to achieve
It doesn't matter to me which area will be selected. For this reason, any.