I’m quite new to R. I’ve been learning R Studio and been working on R Markdown in HTML format. So I apologize in advance if my code seems chaotic.
...
Variable_List <- data.frame(
...
"Method" = c(
"$$\bar{x} = \frac{\sum{x_i}}{n}$$ where "$x_{i}$" is each individual measurement while "$n$" is the number of observations.",
"$$\sum_{i=1}^{n}(x_{i}-\bar{x})^{2}$$",
"$$SS_{xy} = \sum_{i=1}^{n}(x_{i}-\bar{x})(y_{i}-\bar{y})$$",
"$$\sigma_{x} = \sqrt{\frac{SS_{x}}{n}}$$",
"$$s_{x} = \sqrt{\frac{SS_{x}}{n-1}}$$",
"$$\sigma_{xy} = \frac{SS_{xy}}{n}$$",
"$$s_{xy} = \frac{SS_{xy}}{n-1}$$",
"$$\rho_{xy} = \frac{\sigma_{xy}}{\sigma_{x}\sigma_{y}}$$",
"$$\hat{y}(x) = \alpha + \beta x$$ Where $\alpha$ and $\beta$ are constants. Although there are various methods of finding the constants, one method is through matrix regression.<br>Let ${(x_{i},y_{i})}_{i=1}^{n}$ be a range of measurements for two variables, $x$ and $y$.<br> A matrix X for the independent variable $x$ and a vector $\overrightarrow{y}$ for the dependent variable $y$ can be defined as such:<br>\begin{bmatrix}1 & x_{1} \\ \vdots & \vdots \\1 & x_{n} \end{bmatrix} "
...
),
...
I know, a lot is going on here, but I need help on this bit at the end:
\begin{bmatrix}1 & x_{1} \\ \vdots & \vdots \\1 & x_{n} \end{bmatrix}
I tried creating a matrix with the help of atomurl math TeX generator online. I got a matrix going, but apparently there’s a new column in between with each row saying “amp;” and I’m confused as to why. I wanted to create a matrix with 2 columns and three rows, where first row has “1” and “x_{1}”, second row is a set of \vdots and last row is “1” and “x_{n}”.
Here’s a bit of extra code in the same R code block. Could be helpful for anyone who’s answering?
Variable_List <- data.frame(Variable_List2, row.names = NULL)
kable(Variable_List, format = "html", escape = TRUE, row.names = FALSE, caption = "Table 1.2.1: Variable List") %>%
kable_styling(
bootstrap_options = c("striped"),
full_width = FALSE,
position = "center"
) %>%
column_spec(1, border_left = "2px solid #ddd") %>%
column_spec(2, border_left = "2px solid #ddd", border_right = "2px solid #ddd") %>%
column_spec(4, border_left = "2px solid #ddd", border_right = "2px solid #ddd")
I tried adding “” in front, it gave me an error:
”
! ‘&’ is an unrecognized escape in character string (:49:8)
”
I tried writing “&&” instead, it just added an extra column with another “amp;” in each row.
I tried writing “&” instead, same output where there’s a column of “amp;”‘s.
I’m lost.
1