Before answering your question, I'd like to request you not to paste your code withing block quotes. Please paste your code withing a pair of triple back ticks for normal R
code, and for Rmd
codes, use 4
back ticks.
What's wrong with your code? It creates the table with no problem, though you haven't used caption
or setspace
anywhere, as far as I understand. multirow
is also unnecessary, as Country List
is, in my opinion, more suitable for a table caption, not for a different row of table.
I'm not sure, but does this mean that you've a data frame in R and wish to include it in a document as a table? You can use knitr::kable
. Here's an example, but for more control, check the documentation.
---
output: pdf_document
header-includes:
- \usepackage{multirow}
---
# the way you did it
\begin{tabular}{ |p{3cm}||p{3cm}|p{3cm}|p{3cm}| }
\hline
\multicolumn{4}{|c|}{Country List} \\
\hline
Country & ISO ALPHA&ISO ALPHA&ISO numeric\\
\hline
Afghan& AF &AFG& 004\\
Aland & AX & ALA &248\\
Albania &AL & ALB& 008\\
Algeria &DZ & DZA& 012\\
American Samoa& AS & ASM&016\\
Andorra& AD & AND &020\\
Angola& AO & AGO&024\\
\hline
\end{tabular}
# in case you already have the data frame in R
```{r}
df <- data.frame(stringsAsFactors = FALSE,
Country = c("Afghan", "Aland", "Albania", "Algeria", "American Samoa", "Andorra", "Angola"),
ISO.ALPHA = c("AF", "AX", "AL", "DZ", "AS", "AD", "AO"),
ISO.ALPHA = c("AFG", "ALA", "ALB", "DZA", "ASM", "AND", "AGO"),
ISO.numeric = c(4, 248, 8, 12, 16, 20, 24))
knitr::kable(x = df,
caption = "Country List")
```
The above code generates try.pdf (104.7 KB).
Since you're repeated asking questions regarding tables, I'll suggest you to look at the kableExtra
package. I've hear of another package gt
, but I haven't used it myself.