r - Adding " \\ \hline " after every component of a vector -


consider following:

v <- letters[1:4] v [1] "a" "b" "c" "d" 

i following output using v:

"a \\ \hline b \\ \hline c \\ \hline d \\ \hline" 

or version quotation marks removed. closest i've gotten

paste0(v, collapse = " \\ \\hline ") [1] "a \\ \\hline b \\ \\hline c \\ \\hline d" 

and ctrl + f find , replace in rstudio using \\hline -> \hline, simple enough, see if there's way create string without step.

this problem comes when want create tabular environment using character vector in .rnw file using latex code.

if printing, can use cat

cat(v, sep = " \\\\ \\hline ") 

Comments

Popular posts from this blog

Android volley - avoid multiple requests of the same kind to the server? -

magento2 - Magento 2 admin grid add filter to collection -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -