我是使用 Sweave 和 Latex 的新手,遇到了一些小麻烦。这是放入它自己的 tex 文件中的文档段。
\documentclass[a4paper,10pt]{article}
\usepackage[dvips]{graphicx}
\usepackage{Sweave}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% END PREAMBLE %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{plain}
\begin{figure}
\begin{center}
<<fig=TRUE,echo=FALSE>>=
data=read.table("adult_dataset/adult.data", sep=",");
age=c(t(data[1]));
fnlwgt=c(t(data[3]));
education_num=c(t(data[5]));
cap_gain=c(t(data[11]));
cap_loss=c(t(data[12]));
hrs_week=c(t(data[13]));
labels=c("Age", "Final weight", "Education num", "Capital gain", "Capital loss", "Hours per week");
dframe=data.frame(age, fnlwgt, education_num, cap_gain, cap_loss, hrs_week);
par(mfrow=c(2,3));
for (i in c(1:6) ){
boxplot(dframe[i], main=labels[i]);
}
@
\label{fig:boxplots}
\caption{Boxplots of numerical features}
\end{center}
\end{figure}
\end{document}
Adult.data 是http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data 我编译时使用:
R CMD Sweave test.rnw && latex test.tex && dvipdf test.dvi
这产生了一个水平的页面。它的大小正确,但旋转了 90 度。不是图片,而是整页。
我能做些什么来解决这个问题?这是正常行为吗?
谢谢你的任何建议:)