I'm trying to get a table from R into a pgfplotstable to edit for printing.

the r code is

\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}
ignore.chars={\ }]{%
<<echo=FALSE,results='asis'>>=
temp=rbind(c(rep("",6)),c("",seq(2012,2016,1)),c(rep("",6)))
print(xtable(temp),include.rownames=F,include.colnames=F,only.content=T,hline.after=NULL)
@
}\mytable
\end{document}


and the output has the space at the end shown below and fails to compile with an error. The extra space at the end seems to be an xtable problem rather than a knitr one, but I'm not sure this one is right to ask on SO, and am hoping perhaps there is another way to get the info into the pgfplotstableread that I haven't thought of.

\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}
ignore.chars={\ }]{%
% latex table generated in R 2.15.1 by xtable 1.7-0 package
% Thu Nov  1 19:19:18 2012
&  &  &  &  &  \\
& 2012 & 2013 & 2014 & 2015 & 2016 \\
&  &  &  &  &  \\

}\mytable
\end{document}


Thanks

-
Adding a shamefaced half solution. write.table(temp,sep='&',eol='\\\\',quote=F,row.names=F,col.names=F) ... but that doesnt really give me access to all the text sanitization benefits of xtable.. –  Tahnoon Pasha Nov 1 '12 at 14:26
You can try to tell pgfplotstable that it should filter out newline characters from the input table. That should not pose any difficulty because you do not need them in your case.
To this end, you can simply use ignore chars={\ ,\^^M} . Why do you need \, by the way? The \^^M is a TeX-shorthand which means (and protects) end-of-line.