Problem with “arg;” when creating a matrix inside of a data.frame() cell

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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>...
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} "
...
),
...
</code>
<code>... 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} " ... ), ... </code>
...
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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>\begin{bmatrix}1 & x_{1} \\ \vdots & \vdots \\1 & x_{n} \end{bmatrix}
</code>
<code>\begin{bmatrix}1 & x_{1} \\ \vdots & \vdots \\1 & x_{n} \end{bmatrix} </code>
\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?

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
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")
</code>
<code> 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") </code>

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

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật