in r sweave file (.rnw), when compile pdf using knitr, there unwanted things printing. hard explain whats going on. i'm thinking it's result of using data.table package , dplyr package haven't been able find other examples of this. however, i'm not sure search for.
here's screenshot of issue:
i don't know else except figure out how rid of it. if thinks simple problem, instead of downvoting, point me in right direction of research on this?
\documentclass[11pt]{article} \usepackage[sc]{mathpazo} \usepackage[t1]{fontenc} \usepackage{geometry} \geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm} \setcounter{secnumdepth}{2} \setcounter{tocdepth}{2} \setlength{\parindent}{0in} \usepackage{url} \usepackage[unicode=true,pdfusetitle, bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2, breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] {hyperref} \hypersetup{ pdfstartview={xyz null null 1}} \usepackage{breakurl} \usepackage{longtable} \begin{document} <<setup, include=false, cache=false>>= library(knitr) library(stringr) library(rodbc) library(plyr) library(reshape2) library(ggplot2) library(grid) library(data.table) rw1 <- c("file1", "file1", "file1", "file2", "file2", "file2", "file3", "file3", "file3", "file1", "file1", "file1", "file2", "file2", "file2", "file3", "file3", "file3", "file1", "file1", "file1", "file2", "file2", "file2", "file3", "file3", "file3") rw2 <- c("0.01", "0.01", "0.01", "0.01", "0.01", "0.01", "0.01", "0.01", "0.01", "0.02", "0.02", "0.02", "0.02", "0.02", "0.02", "0.02", "0.02", "0.02", "0.03", "0.03", "0.03", "0.03", "0.03", "0.03", "0.03", "0.03", "0.03") rw3 <- c("time", "size", "final", "time", "size", "final", "time", "size", "final", "time", "size", "final", "time", "size", "final", "time", "size", "final", "time", "size", "final", "time", "size", "final", "time", "size", "final") rw4 <- c(123, 456, 789, 312, 645, 978, 741, 852, 963, 369, 258, 147, 753, 498, 951, 753, 915, 438, 978, 741, 852, 963, 369, 258, 147, 753, 498) rw5 <- c("01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12", "01/01/12") rw6 <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3) rw7 <- c("iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "iteration", "release", "release", "release", "release", "release", "release", "release", "release", "release") rw8 <- c("none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "cannot connect database", "none", "none", "none", "none", "none", "none", "none", "none") testdf = data.frame(rw1, rw2, rw3, rw4, rw5, rw6, rw7, rw8) colnames(testdf) <- c("filename", "version", "category", "value", "date", "number", "build", "error") @ \title{report} \author{current version} \maketitle \section{report summary} report documents results <<benchmarks,echo=false>>= library(ggplot2) # library(data.table) library(dplyr) versions<-unique(testdf[order(testdf$number), ][,2]) # testdf %<>% # group_by(filename) %>% # mutate(benchmark = value[which(category == "time" & number == min(number))]) %>% # ungroup() setdt(testdf) testdf[, benchmark := value[which.min(number[category == "time"])], = filename] testdf$version<-factor(testdf$version, levels = versions) testdf$deviation<-testdf$value- testdf$benchmark testdf$deviationp<-(testdf$value- testdf$benchmark)/testdf$benchmark g<-ggplot(subset(testdf, category == 'time') , aes(color = value, x = version, y = deviationp, group = filename)) + geom_line(size=.25) + geom_point(aes(shape = build), size = 1.5) + scale_shape_manual(values=c(1,15)) + stat_summary(fun.y=sum, geom="line") + ylab("run time deviation benchmark (min)") + scale_colour_gradient(name = 'run time (min)',low = 'blue', high = 'red') + coord_cartesian(ylim=c(-105,105)) + theme(axis.text.x = element_text(size = 10, angle = 90, vjust = .5)) + theme(axis.title.y = element_text(vjust = 1)) + theme(axis.title.x = element_text(vjust = -0.1)) + theme(plot.margin=unit(c(0,0,0,0),"mm")) g @ \end{document}
there 2 things going on here. table that's printing out line:
testdf[, benchmark := value[which.min(number[category == "time"])], = filename] that line both assigns benchmark column and returns modified table. can fix 2 ways:
assign output same variable (or another, doesn't matter):
testdf <- testdf[, benchmark := value[which.min(number[category == "time"])], = filename]avoid results ever printing adding
results = 'hide'header of knitr chunk:<<benchmarks,echo=false, results = 'hide'>>=
the black messages in italics package startup messages library(dplyr). again, 2 choices of how fix it:
hide messages changing dplyr-loading line to:
suppresspackagestartupmessages(library(dplyr))hide messages in chunk adding
message = falsehead of chunk:<<setup, include=false, cache=false, message=false>>=
in both cases, note can change default in chunks adding chunk @ start with:
<<set_defaults, echo = false>>= knitr::opts_chunk$set(message = false, results = 'hide') @
Comments
Post a Comment