0

Im trying to generate an xtable of a .csv file within a knitr document. The csv file contains cells which have several math symbols such as '±'.I do not know how to tell xtable to include that math symbol within the knitr document.

Thus far i have been trying the following

    table<-read.csv("table.csv",check.names = FALSE)
    q<-xtable(table,
          caption = "This is my table",include.rownames=FALSE,label="tab:table")
    print(q,include.rownames=FALSE)

This doesn't work and gives me the following error "missing $ inserted"

Thank you in advance

kribby
  • 45
  • 7

1 Answers1

0

The fact that you read in a CSV is irrelevant. It is a data.frame after read.csv().

The result of xtable() can be post-processed as illustrated on the help page. However, if these math symbols appear only in a column or two, it is easier to pre-process your table, wrapping the cell entries in $ ... $.

e.g.,

table[,1] <- paste0("$", table[,1], "$")
user101089
  • 3,756
  • 1
  • 26
  • 53