latex - create an explanation of a table in R -
i have latex table generated inside pdf r data frame after statistical test , want create summary of table explain significant variables inside it. how can done ??
that's table :
\hline & & b & c & d & e \\ \hline & 1.00 & 0.00 & 0.00 & 0.00 & 0.02 \\ b & 0.00 & 1.00 & 0.00 & 0.08 & 0.40 \\ c & 0.00 & 0.00 & 1.00 & 0.00 & 0.00 \\ d & 0.00 & 0.08 & 0.00 & 1.00 & 0.99 \\ e & 0.02 & 0.40 & 0.00 & 0.99 & 1.00 \\ \hline note : significant varaibles variables have value bigger 0.7 , e.g (d , e have value =0.99 ) signifcant. want summary text under table (e.g variables d , e similar | , e "weakly similar" (0.02) t less similar c) , , want put * on significant numbers , , numbers came data frame in r
thanks in advance
see if want. there more efficient ways go doing this, without details structure of data - bit of mind reader's game know need. having said that, seems want assuming data comes data.frame:
require(xtable) #sample data set.seed(1) dat <- data.frame(matrix(abs(rnorm(25)), ncol = 5 , dimnames = list(letters[1:5], letters[1:5]))) xtable(apply(dat, c(1,2), function(x) ifelse(x > .7, paste(round(x,3), "**", sep = ""), ifelse(x > .5, paste(round(x,3), "*" , sep = ""),round(x,3))) )) produces:
% latex table generated in r 2.12.2 xtable 1.5-6 package % tue apr 12 21:23:31 2011 \begin{table}[ht] \begin{center} \begin{tabular}{rlllll} \hline & & b & c & d & e \\ \hline & 0.626* & 0.82** & 1.512** & 0.045 & 0.919** \\ b & 0.184 & 0.487 & 0.39 & 0.016 & 0.782** \\ c & 0.836** & 0.738** & 0.621* & 0.944** & 0.075 \\ d & 1.595** & 0.576* & 2.215** & 0.821** & 1.989** \\ e & 0.33 & 0.305 & 1.125** & 0.594* & 0.62* \\ \hline \end{tabular} \end{center} \end{table} >
Comments
Post a Comment