Sweave マニュアル訳
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
// 間瀬茂
COLOR(blue){SIZE(20){Sweave ユーザーマニュアル}} by Fried...
//COLOR(red){SIZE(16){(翻訳作業中、 2005.05.05 開始)}}~
// 翻訳暫定終了 2007.02.21 長山泰秀(4.1以降)
#contents
* 1. はじめに [#z886b078]
Sweave はドキュメントの自動作成のために、テキストと R ...
ドキュメントテキストと
R コード、とともに(もしくは)
コードの出力(テキスト、グラフ)
を織り込んだ最終ドキュメントを生成する。これは、入力デー...
Sweave は実際の翻訳に異なるドライバーを使うというモジュ...
* 2. Noweb ファイル [#v20963a6]
Noweb (Ramsey, 1998) は,プログラムソースコードと対応す...
ドキュメントチャンクは最初の文字としてサイン (@) を持ち、...
最初のチャンクは既定ではドキュメントである。noweb の最も...
脚注:~
1 See Becker et al. (1988) and Chambers (1998) for defini...
for details on the term S engine and detailed description...
language.~
2 R システム:http://www.R-project.org~
3 LATEX システム:http://www.ctan.org~
4 S-PLUS システム:http://www.insightful.com~
* 3. Sweave ファイル [#pa7f64b0]
** 3.1 簡単な例 [#d0cd9592]
Sweave のソースファイルは正規の noweb ファイルであり、最...
Sweave ファイルの一つの最小例を図 1 に示す。これは単純な ...
図 1: 最小の Sweave ファイル: example-1.Snw
(訳注:<<...>> は空白無しで行の先頭に置かないとまずいら...
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\begin{document}
\maketitle
この例では \texttt{kruskal.test} のヘルプページからの実...
埋め込む:
<<>>=
data(airquality)
library(stats)
kruskal.test(Ozone ~ Month , data = airquality)
@
これはオゾンの分布の位置パラメータが月毎に有意に変化する...
取り込む:
\begin{center}
<<fig =TRUE, echo =FALSE>>=
boxplot(Ozone ~ Month , data = airquality)
@
\end{center}
\end{document}
Sweave の既定動作が使われ、S 命令とその対応する出力が LAT...
図 2: 命令 Sweave("example-1.Snw") の出力が以下のファイ...
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\usepackage{Sweave}
\begin{document}
\maketitle
この例では \texttt{kruskal.test} のヘルプページからの実...
埋め込む:
\begin{Schunk}
\begin{Sinput}
> data(airquality)
> library(stats)
> kruskal.test(Ozone ~ Month , data = airquality)
\end{Sinput}
\begin{Soutput}
Kruskal - Wallis rank sum test
data : Ozone by Month
Kruskal - Wallis chi - squared = 29.2666 , df = 4, p- va...
\end{Soutput}
\end{Schunk}
これはオゾンの分布の位置パラメータが月毎に有意に変化する...
取り込む:
\begin{center}
\includegraphics{example-1-002}
\end{center}
\end{document}
#ref(example-1.png)
** 3.2 Sweave のオプション [#t2d1063c]
オプションは、コードチャンクとそれらの出力(テキスト、図)...
1. 一つのコードチャンクの先頭におかれた矢印括弧の中(この...
2. ドキュメントチャンクの任意の場所におかれた命令
\SweaveOpts{opt1=value1, opt2=value2, ..., optN=valueN}
(これは、以降のドキュメント全て、つまり、宣言以降の全...
のいずれかによって、指定できる。したがって、ドキュメント...
どのオプションがサポートされているかは使用されるドライバ...
engine=S: それぞれのコードチャンクを、どの S エンジン...
例えば、S, R, S3 もしくは S4 である。各ドラ...
し、それ以外は無視する。
split=FALSE: 論理値。もし TRUE なら、出力は複数のファイ...
全ての出力は一つのファイルに書き込まれる。...
label: コードチャンクに対するラベルで、split=TRUE ...
ラベルが、label.engine という形式ならば、そ...
(例えば、ラベル hello.S は hello に短縮され...
コードチャンク名中の最初(そして最初だけ)のオプションは名...
<<hello.S, split=FALSE>>
で始まれば、それは
<<split=FALSE, label=hello.S>>
と同じであるが、しかし
<<split=FALSE, hello.S>>
では構文エラーになる。ラベルに対する名前無しの第一引数は ...
** 3.3 テキスト中で数値を使う [#xc8f9c16]
テキストチャンク中で S オブジェクトの値を使うための限られ...
** 3.4 コードチャンクの再利用 [#c369f6ff]
名前付きのコードチャンクは、ドキュメント中で後に現れた他...
中で再利用出来る。次の簡単な例
<<a>>=
x <- 10
@
<<b>>=
x + y
@
<<c>>=
<<a>>
y <- 20
<<b>>
@
を考えよう。これは、最後のコードチャンクを次のように定義...
<<c>>=
x <- 10
y <- 20
x + y
@
チャンク参照演算子 <<>> は他の追加の Sweave オプション無...
** 3.5 構文の定義 [#c12d23c7]
これまでは(既定の) noweb 構文だけを使った Sweave ファイル...
\SweaveSyntax{SweaveSyntaxLatex}
もしくは
\SweaveSyntax{SweaveSyntaxNoweb}
で変更できる。構文定義は幾つかの Sweave 命令に対する正規...
*4 Tangling (縺れ)と weaving (編みあげ) [#gf9a6b78]
Sweave システムに対するユーザフロントエンドは二つの S 関...
Figure 4: LATEX 構文を用いた Sweave ファイル例: example-...
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch }
\begin{document }
\maketitle
この例では \texttt{kruskal.test} のヘルプページ中の例の
一部を \LaTeX{} 文章に埋め込む:
\begin{Scode}
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month , data = airquality)
\end{Scode}
これはオゾンの分布の位置パラメータが月毎に有意に変動する
ことを示す。次に、データのボックスプロットを含める:
\begin{center}
\begin{Scode}{fig=TRUE , echo = FALSE}
boxplot(Ozone ~ Month , data = airquality)
\end{Scode}
\end{center}
\end{document}
Sweave は S エンジンを用いてコードチャンクを実行し、それ...
Sweave レポートの自動作成
説明
Sweave はレポートの自動作成のためにテキストと S コードを...
柔軟な枠組を提供する。基本的なアイデアは、S コードをその...
最終的な文章がテキストと統計解析結果だけを含むようにする...
用法
Sweave(file, driver = RweaveLatex(), syntax = getOption(...
Stangle(file, driver = Rtangle(), syntax = getOption("Sw...
引数
file Sweave ソースファイル名
driver 実際に使われるドライバ、以下の詳細を見よ
syntax クラス SweaveSyntax のオブジェクトか、その名前...
既定のインストールでは SweaveSyntaxNoweb と Swe...
... ドライバの設定関数に引き渡される追加引数
詳細
(latex のような)文章作成マークアップと S コードを一体化...
作成する。最終的なマークアップファイルでは S コードはそ...
もし入力データが変わってもレポートを再生成し、レポートを...
た解析を再現するコードをドキュメント化する。Sweave は文...
出力を)を一つのファイルにまとめる。Stangle は Sweave フ...
をつくり出すコードだけを取り出す(そして、それを source ...
\Sexpr{} 文中のコードは S tangle により無視される。Stang...
Sweave へのフロントエンドであり、文章部分を取り去り、使...
コードチャンクを連結する。
フック関数
各コードチャンクが評価される前に、幾つかのフック関数を実...
が設定されていれば、それはフック関数の集まりとされる。一...
の各論理オプション毎に一つのフック関数を指定することがで...
の時、そしてその時だけ実行される。フックは getOption("S...
成分でなければならず、引数を持たない関数でなければならな...
が list(fig = foo) と定義されており、foo が関数なら、そ...
されるであろう。これは一連の図チャンク中の作図パラメータ...
ユーザは新しい Sweave オプションと、それらに関連する任意...
注意しよう。例えば、大局的環境中の全てのオブジェクトを取...
関数を定義できる。すると clean=TRUE である全てのコードチ...
ことになるであろう。
構文上の定義
Sweave は,ドキュメントとテキストチャンクを記述するのに...
デフォルトはnowebスタイルの構文であるが,代わりにlatexス...
詳しくはユーザーマニュアルを参照.
Author(s)
Friedrich Leisch
References
Friedrich Leisch: Sweave User Manual, 2002
http://www.ci.tuwien.ac.at/~leisch/Sweave
Friedrich Leisch: Dynamic generation of statistical repo...
Hrdle and B. Rnz, editors, Compstat 2002 - Proceedings i...
575-580. Physika Verlag, Heidelberg, Germany, 2002. ISBN...
See Also
RweaveLatex, Rtangle
Examples
testfile <- system.file("Sweave", "Sweave-test-1.Rnw", p...
## create a LaTeX file
Sweave(testfile)
## create an S source file from the code chunks
Stangle(testfile)
## which can be simply sourced
source("Sweave-test-1.R")
// ** 4.1 The RweaveLatex driver
** 4.1 RweaveLatex ドライバー [#i9d73ca4]
//This driver transforms .Snw files with LATEX documentat...
// LATEX files (for typesetting both with standard latex ...
このドライバーは,
LaTeX ドキュメントのチャンクと
R コードチャンクをもった
.Snw ファイルを
適切なLaTeXファイル
(通常のlatex と pdflatex でタイプセットするための)へと変...
RweaveLatex R/LaTeX Driver for Sweave
説明
LaTeX ファイルの中で Rコードチャンクを変換する Sweave ...
使用法
RweaveLatex()
RweaveLatexSetup(file, syntax, output = NULL, quiet =...
debug = FALSE, echo = TRUE, eval = TRUE,
split = FALSE, stylepath = TRUE,
pdf = TRUE, eps = TRUE)
引数
file Name of Sweave source file.
syntax An object of class SweaveSyntax.
output Name of output file, default is to remove exte...
‘.Snw’
and to add extension ‘.tex’. Any directory names in...
such that the output is created in the current work...
quiet If TRUE all progress messages are suppressed.
debug If TRUE, input and output of all code chunks is...
stylepath If TRUE, a hard path to the file ‘Sweave.st...
set, if FALSE, only \usepackage{Sweave} is written....
the TeX file less portable, but avoids the problem ...
version of ‘Sweave.sty’ to some place in your TeX i...
is ignored if a \usepackage{Sweave} is already pres...
file.
echo set default for option echo, see details below.
eval set default for option eval, see details below.
split set default for option split, see details below.
pdf set default for option pdf, see details below.
eps set default for option eps, see details below.
サポートされているオプション
RweaveLatex supports the following options for code c...
the default values):
echo: logical (TRUE). Include S code in the output fi...
eval: logical (TRUE). If FALSE, the code chunk is not...
output produced.
results: character string (verbatim). If verbatim, th...
the verbatim-like Soutput environment. If tex, the ...
latex markup and included as is. If hide then all o...
the code executed during the weave).
print: logical (FALSE) If TRUE, each expression in th...
statement before evaluation, such that the values o...
term: logical (TRUE). If TRUE, visibility of values e...
assignments are not printed, values of single objec...
only from explicit print or cat statements.
split: logical (FALSE). If TRUE, text output is writt...
strip.white: logical (TRUE). If TRUE, blank lines at ...
removed.
prefix: logical (TRUE). If TRUE generated filenames o...
prefix.
prefix.string: a character string, default is the nam...
include: logical (TRUE), indicating whether input sta...
statements for figures should be auto-generated. Us...
output should appear in a different place than the ...
manually).
fig: logical (FALSE), indicating whether the code chu...
only one figure per code chunk can be processed thi...
eps: logical (TRUE), indicating whether EPS figures s...
FALSE.
pdf: logical (TRUE), indicating whether PDF figures s...
FALSE.
width: numeric (6), width of figures in inch.
height: numeric (6), height of figures in inch.
Author(s)
Friedrich Leisch
References
Friedrich Leisch: Sweave User Manual, 2002
http://www.ci.tuwien.ac.at/~leisch/Sweave
See Also
Sweave, Rtangle
*** 4.1.1 分離されたファイルへの書き込み [#x8d89f6a]
// *** 4.1.1 Writing to separate files
// If split is set to TRUE, then all text corresponding t...
// environments) is written to seperate files. The filena...
// if several code chunks have the same label, their outp...
// label, then the number of the chunk is used instead. T...
もしも,splitが真にセットされると,コードチャンクに対応す...
// *** 4.1.2 LATEX style file and figure sizes [#i05aed9a]
*** 4.1.2 LaTeX のスタイルファイルと図のサイズ [#s5a0dc83]
// The driver automatically inserts a \usepackage{.../Swe...
// as last line before the \begin{document} statement of ...
// file if no \usepackage{Sweave} is found in the Sweave ...
// This style file defines the environments Sinput and So...
// typesetting code chunks.
もしも Sweave ソースファイルに \usepackage{Sweave.sty} が...
// If you do not want to include the standard style file,...
// you have your own definitions for Sinput and Soutput e...
// different place, simply insert a comment like % \usepa...
// the preamble of your latex file, this will prevent aut...
// of the line. Sweave.sty also sets the default LATEX fi...
// (which is independent of the size of the generated EPS...
// files).
もしも,たとえばあなたが自分で,別の場所にSinput,Soutput...
Sweave.sty は,既定の LaTeX の図の幅をセットする(これは生...
// The current default is
現在の既定値は,
\setkeys{Gin}{width=0.8\textwidth}
// if you want to use another width for the figures that ...
// automatically generated and included by Sweave, simply...
// similar to the one above after \begin{document}.
であり,図について,Sweaveが自動的に生成してインクルード...
// Note that a new graphics device is opened for each fig...
// (option fig=TRUE), hence all graphical parameters of t...
// must be set in each single figure chunk and are forgot...
// respective chunk (because the device is closed when le...
// chunk).
それぞれのフィギュアチャンク(option fig=TRUE)ごとに,新し...
// Attention: One thing that gets easily confused are the...
// parameters of the R graphics devices and the correspon...
// to the LATEX \includegraphics command.
注意:R グラフィックデバイスのパラメータ width/height はL...
// The Sweave options width and height are passed to the ...
// devices, and hence affect the default size of the prod...
// files.
Sweave の widthとheight オプションは,R のグラフィックデ...
// They do not affect the size of figures in the document...
// they will always be 80% of the current text width.
そしてそれは,ドキュメントの中の図のサイズには影響せず,...
// Use \setkeys{Gin} to modify figure sizes or use explicit
// \includegraphics commands in combination with Sweave o...
// include=FALSE.
図のサイズを変更するには,\setkeys{Gin} を使用するか,Swe...
// *** 4.1.3 Prompts and text width for that
*** 4.1.3 プロンプト記号とテキストの幅 [#h0f19a7b]
//As of R version 1.6.0 the driver gets the prompts used ...
// R’s options() settings. To set new prompts use somthin...
// options(prompt="MyR> ", continue="...")
// see help(options) for details. Similarly the text widt...
R バージョン1.6.0 と同じように,ドライバーは入力行と継続...
// ** 4.2 The Rtangle driver
** 4.2 Rtangle ドライバー [#b7f415b2]
// This driver can be used to extract S and R code chunks...
// be written to one large file or seperate files (one fo...
// prefix.string and engine have the same defaults and in...
// driver. Use the standard noweb command line tool notan...
// should be extracted.
このドライバーは,.SnwファイルからSとRのコードを抽出する...
Rtangle R Driver for Stangle
説明
A driver for Stangle that extracts R code chunks.
使用法
Rtangle()
RtangleSetup(file, syntax, output = NULL, annotate = T...
split = FALSE, prefix = TRUE, quiet = FALSE)
引数
file Name of Sweave source file.
syntax An object of class SweaveSyntax.
output Name of output file, default is to remove exten...
and to add extension ‘.R’. Any directory names in fi...
such that the output is created in the current worki...
annotate By default, code chunks are seperated by co...
and numbers of the code chunks. If FALSE, only the c...
any decorating comments are extracted.
split Split output in single files per code chunk?
prefix If split = TRUE, prefix the chunk labels by the...
to get output file names?
quiet If TRUE all progress messages are suppressed.
Author(s)
Friedrich Leisch
References
Friedrich Leisch: Sweave User Manual, 2002
http://www.ci.tuwien.ac.at/~leisch/Sweave
See Also
Sweave, RweaveLatex
Acknowledgements
The author wants to thank Vince Carey, Robert Gentlema...
Ripley, Anthony Rossini, and Dietrich Trenkler for pro...
development versions of the software or fixing bugs.
// * A Frequently Asked Questions
* FAQ: しばしば聞かれる質問 [#i168c9e1]
// ** A.1 Where can I find the manual and other informati...
** A.1 どこでSweaveのマニュアルやその他の情報を入手できま...
// The newest version of the Sweave manual can always be ...
// http://www.ci.tuwien.ac.at/~leisch/Sweave
// where you also find several example files, and the lis...
// addition, the homepage has several papers on Sweave li...
// miniseries from R News (Issues 2/3 and 2/3).
最新のSweaveのマニュアルはいつも[[Sweaveホームページ:http...
// ** A.2 How can I get Emacs to automatically recognize ...
** A.2 どのようにしたら Emacs に,Sweave フォーマットのフ...
// Include something like the following in your .emacs fi...
あなたの .emacs ファイルに,つぎのようなコードをいれまし...
(defun Rnw-mode ()
(require 'ess-noweb)
(noweb-mode)
(if (fboundp 'R-mode)
(setq noweb-default-code-mode 'R-mode)))
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-to-list 'auto-mode-alist '("\\.Snw\\'" . Rnw-mode))
(setq reftex-file-extensions
'(("Snw" "Rnw" "nw" "tex" ".tex" ".ltx") ("bib" ".b...
(setq TeX-file-extensions
'("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "...
// The first block of commands makes emacs to automatical...
// mode (with R mode the default code mode) for files wit...
// two lines make RefTeX work on noweb files. You can dow...
コマンドの最初のブロックは拡張子が .Rnwと .Snw のファイル...
// ** A.3 Can I run Sweave directly from a shell?
** A.3 Sweave をシェルから直接走らせることはできますか? [...
// E.g., for writing makefiles it can be useful to run Sw...
// start R and then run Sweave. This can easily be done u...
例えば,makefile を書くなどすると,手動で R を起動してか...
#!/bin/sh
echo "library(tools); Sweave(\"$1\")" | R --no-save --no...
// ** A.4 Why does LATEX not find my EPS and PDF graphic ...
** A.4 なぜLaTeXはEPSとPDFファイルがファイル名にドットを...
// Sweave uses the standard LATEX package graphicx to han...
// uses EPS files for standard LATEX and PDF files for PD...
// no extension, i.e., contains no dots. Hence, you may r...
// the name of your Sweave file contains extra dots: ‘foo...
Sweave は,グラフィックファイルを扱うために,標準の LaTeX...
// **A.5 Why does Sweave by default create both EPS and P...
**A.5 なぜ Sweave は既定値では EPS と PDF のグラフィック...
// The LATEX package graphicx needs EPS files for plain L...
// latter can also handle PNG and JPEG files). Sweave aut...
// PDF format, such that the user can freely run latex or...
LaTeX のパッケージ graphicx は素の LaTeX のためには EPS ...
// **A.6 Why do R lattice graphics not work?
**A.6 R lattice グラフィックスがなぜ動かないのですか? [#v...
// The commands in package lattice have different behavio...
// the base package: lattice commands return an object of...
// performed by the print method for the class. Encapsula...
// statements should do the trick, e.g.:
lattice パッケージでのコマンドは標準の plot コマンドとは...
<<fig=TRUE>>=
library(lattice)
print(bwplot(1:10))
@
// should work. Future versions of Sweave may have more a...
// graphics.
これでうまくいきます.Sweave の将来のバージョンでは trell...
// ** A.7 How can I get Black & White lattice graphics?
** A.7 どうすれば白黒の lattice グラフィックスを使えます...
// What is the most elegant way to specify that strip pan...
// and graphs are to be in black and white when lattice i...
// global option that stays in effect for multiple plots.
// Answer by Deepayan Sarkar: I’d do something like this ...
lattice を Sweave で使うときに,分割されたパネルが透明の...
<<...>>
library(lattice)
ltheme <- canonical.theme(color = FALSE) ## in-built B...
ltheme$strip.background$col <- "transparent" ## change...
lattice.options(default.theme = ltheme) ## set as defa...
@
// ** A.8 Creating several figures from one figure chunk ...
** A.8 ひとつのフィギュアチャンクからいくつかの図を作りた...
// Consider that you want to create several graphs in a l...
つぎのようなループの中でいくつかの図を作りたいとしましょ...
<<fig=TRUE>>
for (i in 1:4) plot(rnorm(100)+i)
@
// This will currently not work, because Sweave allows on...
// simple reason is that Sweave opens a postscript device...
// afterwards. If you need to plot in a loop, you have to...
現在のところこれはまだうまくいきません.というのは,Sweav...
<<results=tex,echo=FALSE>>=
for(i in 1:4){
file=paste("myfile", i, ".eps", sep="")
postscript(file=file, paper="special", width=6, height=6)
plot(rnorm(100)+i)
dev.off()
cat("\\includegraphics{", file, "}\n\n", sep="")
}
@
// ** A.9 How can I place all those auto-generated graphi...
** A.9 どうしたら自動的に生成されたグラフィクスファイルを...
// After
まず,
\SweaveOpts{prefix.string=foo/bar}
// Sweave will place all figures in subdirectory foo and ...
// name of the Sweave file). The subdirectory foo should ...
という風にすると,Sweave はすべての図をfoo というサブディ...
// ** A.10 How can I set default par() settings for figur...
** A.10 どうすればフィギュアチャンクに par() の既定値をセ...
// Because each EPS and PDF file opens a new device, usin...
// inside a figure chunk. If you want to use the same set...
// a hook function than repeating the same par() statemen...
// The effect of
EPS も PDF ファイルも新しいデバイスを開くので,par() を使...
options(SweaveHooks=list(fig=function() par(bg="red", fg...
// should be easy to spot. Do not forget to remove the ho...
// want to use it as a global option for all Sweave files.
の効果はすぐわかるでしょう.すべての Sweave ファイルにた...
// ** A.11 Running latex fails on Windows
** A.11 Windows で latex ファイルを走らせる [#jd34d2b5]
// If you can create the ‘.tex’ file by running Sweave() ...
// ‘.dvi’ or ‘.pdf’, this is most likely caused by a spac...
// of your R installation contains any blank characters (...
// in English versions of Windows), this may cause proble...
// cannot handle blanks in paths properly.
// Two possible solutions:
// 1. Install R in a path not containing any blanks.
// 2. Copy the file ‘Sweave.sty’ to a directory in your t...
// Sweave file and put a \usepackage{Sweave} into the pre...
R の中で Sweave() を走らせることで '.tex' ファイルを作っ...
ふたつの解決方法があります.~
1: R を,空白文字のふくまれていないパスにインストールする...
2: 'Sweave.sty' を tex のパスか Sweave ファイルをふくんで...
// ** A.12 How can I change the formatting of S input and...
** A.12 どうすれば S インプットとアウトプットのチャンクの...
// Sweave uses the fancyvrb package for formatting all S ...
// powerful and flexible package that allows fine control...
// If you want to change the default layout, simply read ...
// the definitions of the Sinput and Soutput environments...
Sweave はすべての S コードの出力のフォーマットをするため...
// ** A.13 How can I change the line length of S input an...
** A.13 どうすれば S インプットとアウトプットの1行の長さ...
// Sweave respects the usual way of specifying the desire...
// E.g., after options(width=40) lines will be formatted ...
Sweave は,S における,望みの行の長さを指定する通常のやり...
// ** A.14 Why are chunks with eval=FALSE executed by R C...
** A.14 eval=FALSE をふくむチャンクはなぜ R CMD チェック...
// This is a feature, not a bug. From the \u201cWriting R...
// Package vignettes found in directory inst/doc are test...
// all R code chunks they contain to ensure consistency b...
// Note that even code chunks with option eval=FALSE are ...
// vignette that should not be tested, move it to a norma...
// The reason for this policy is that users should be abl...
// executable as seen in the vignette.
これは仕様であってバグではありません."Writing R Extensio...
// ** A.15 Can I use Sweave for HTML files?
// Package R2HTML provides a driver for using Sweave in c...
** A.15 Sweave を HTML ファイルに使えますか? [#eeb8f1ef]
R2HTML パッケージは,LaTeX ではなく HTML との組合せで Swe...
// ** A.16 After loading package R2HTML Sweave doesn\u201...
** A.16 R2HTML パッケージをロードすると Sweave がちゃんと...
// Package R2HTML registers an Sweave driver for HTML fil...
// is in the search list before the default syntax.
R2HTML パッケージはHTML ファイルのための Sweave ドライバ...
options(SweaveSyntax="SweaveSyntaxNoweb")
//or calling Sweave like
または,Sweave をつぎのように呼ぶことで,R2HTML をロード...
Sweave(..., syntax="SweaveSyntaxNoweb")
//ensures the default syntax even after loading R2HTML.
// * References
* 文献 [#k56ec2e5]
Richard A. Becker, John M. Chambers, and Allan R. Wilks....
Chapman & Hall, London, UK, 1988.
John M. Chambers. Programming with data: A guide to the ...
Springer Verlag, Berlin, Germany, 1998.
Friedrich Leisch. Sweave: Dynamic generation of statisti...
literate data analysis.
In Wolfgang Hrdle and Bernd Rnz, editors, Compstat 200...
Computational Statistics, pages 575\u2013580. Physika ...
Germany, 2002. URL http://www.ci.tuwien.ac.at/~leisch/...
ISBN 3-7908-1517-9.
R Development Core Team. R: A language and environment f...
computing, 2002. URL http://www.R-project.org. version...
Norman Ramsey. Noweb man page. University of Virginia, U...
http://www.cs.virginia.edu/~nr/noweb. version 2.9a.
Anthony J. Rossini, Richard M. Heiberger, Rodney Sparapa...
and Kurt Hornik.
Emacs speaks statistics: A multi-platform, multi-packa...
environment for statistical analysis.
Journal of Computational and Graphical Statistics, 200...
(Accepted for publication).
Richard M. Stallman. The Emacs Editor. Free Software Fou...
Boston, MA, USA, 1999. URL http://www.gnu.org. version...
William N. Venables and Brian D. Ripley. S Programming. ...
終了行:
// 間瀬茂
COLOR(blue){SIZE(20){Sweave ユーザーマニュアル}} by Fried...
//COLOR(red){SIZE(16){(翻訳作業中、 2005.05.05 開始)}}~
// 翻訳暫定終了 2007.02.21 長山泰秀(4.1以降)
#contents
* 1. はじめに [#z886b078]
Sweave はドキュメントの自動作成のために、テキストと R ...
ドキュメントテキストと
R コード、とともに(もしくは)
コードの出力(テキスト、グラフ)
を織り込んだ最終ドキュメントを生成する。これは、入力デー...
Sweave は実際の翻訳に異なるドライバーを使うというモジュ...
* 2. Noweb ファイル [#v20963a6]
Noweb (Ramsey, 1998) は,プログラムソースコードと対応す...
ドキュメントチャンクは最初の文字としてサイン (@) を持ち、...
最初のチャンクは既定ではドキュメントである。noweb の最も...
脚注:~
1 See Becker et al. (1988) and Chambers (1998) for defini...
for details on the term S engine and detailed description...
language.~
2 R システム:http://www.R-project.org~
3 LATEX システム:http://www.ctan.org~
4 S-PLUS システム:http://www.insightful.com~
* 3. Sweave ファイル [#pa7f64b0]
** 3.1 簡単な例 [#d0cd9592]
Sweave のソースファイルは正規の noweb ファイルであり、最...
Sweave ファイルの一つの最小例を図 1 に示す。これは単純な ...
図 1: 最小の Sweave ファイル: example-1.Snw
(訳注:<<...>> は空白無しで行の先頭に置かないとまずいら...
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\begin{document}
\maketitle
この例では \texttt{kruskal.test} のヘルプページからの実...
埋め込む:
<<>>=
data(airquality)
library(stats)
kruskal.test(Ozone ~ Month , data = airquality)
@
これはオゾンの分布の位置パラメータが月毎に有意に変化する...
取り込む:
\begin{center}
<<fig =TRUE, echo =FALSE>>=
boxplot(Ozone ~ Month , data = airquality)
@
\end{center}
\end{document}
Sweave の既定動作が使われ、S 命令とその対応する出力が LAT...
図 2: 命令 Sweave("example-1.Snw") の出力が以下のファイ...
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\usepackage{Sweave}
\begin{document}
\maketitle
この例では \texttt{kruskal.test} のヘルプページからの実...
埋め込む:
\begin{Schunk}
\begin{Sinput}
> data(airquality)
> library(stats)
> kruskal.test(Ozone ~ Month , data = airquality)
\end{Sinput}
\begin{Soutput}
Kruskal - Wallis rank sum test
data : Ozone by Month
Kruskal - Wallis chi - squared = 29.2666 , df = 4, p- va...
\end{Soutput}
\end{Schunk}
これはオゾンの分布の位置パラメータが月毎に有意に変化する...
取り込む:
\begin{center}
\includegraphics{example-1-002}
\end{center}
\end{document}
#ref(example-1.png)
** 3.2 Sweave のオプション [#t2d1063c]
オプションは、コードチャンクとそれらの出力(テキスト、図)...
1. 一つのコードチャンクの先頭におかれた矢印括弧の中(この...
2. ドキュメントチャンクの任意の場所におかれた命令
\SweaveOpts{opt1=value1, opt2=value2, ..., optN=valueN}
(これは、以降のドキュメント全て、つまり、宣言以降の全...
のいずれかによって、指定できる。したがって、ドキュメント...
どのオプションがサポートされているかは使用されるドライバ...
engine=S: それぞれのコードチャンクを、どの S エンジン...
例えば、S, R, S3 もしくは S4 である。各ドラ...
し、それ以外は無視する。
split=FALSE: 論理値。もし TRUE なら、出力は複数のファイ...
全ての出力は一つのファイルに書き込まれる。...
label: コードチャンクに対するラベルで、split=TRUE ...
ラベルが、label.engine という形式ならば、そ...
(例えば、ラベル hello.S は hello に短縮され...
コードチャンク名中の最初(そして最初だけ)のオプションは名...
<<hello.S, split=FALSE>>
で始まれば、それは
<<split=FALSE, label=hello.S>>
と同じであるが、しかし
<<split=FALSE, hello.S>>
では構文エラーになる。ラベルに対する名前無しの第一引数は ...
** 3.3 テキスト中で数値を使う [#xc8f9c16]
テキストチャンク中で S オブジェクトの値を使うための限られ...
** 3.4 コードチャンクの再利用 [#c369f6ff]
名前付きのコードチャンクは、ドキュメント中で後に現れた他...
中で再利用出来る。次の簡単な例
<<a>>=
x <- 10
@
<<b>>=
x + y
@
<<c>>=
<<a>>
y <- 20
<<b>>
@
を考えよう。これは、最後のコードチャンクを次のように定義...
<<c>>=
x <- 10
y <- 20
x + y
@
チャンク参照演算子 <<>> は他の追加の Sweave オプション無...
** 3.5 構文の定義 [#c12d23c7]
これまでは(既定の) noweb 構文だけを使った Sweave ファイル...
\SweaveSyntax{SweaveSyntaxLatex}
もしくは
\SweaveSyntax{SweaveSyntaxNoweb}
で変更できる。構文定義は幾つかの Sweave 命令に対する正規...
*4 Tangling (縺れ)と weaving (編みあげ) [#gf9a6b78]
Sweave システムに対するユーザフロントエンドは二つの S 関...
Figure 4: LATEX 構文を用いた Sweave ファイル例: example-...
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch }
\begin{document }
\maketitle
この例では \texttt{kruskal.test} のヘルプページ中の例の
一部を \LaTeX{} 文章に埋め込む:
\begin{Scode}
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month , data = airquality)
\end{Scode}
これはオゾンの分布の位置パラメータが月毎に有意に変動する
ことを示す。次に、データのボックスプロットを含める:
\begin{center}
\begin{Scode}{fig=TRUE , echo = FALSE}
boxplot(Ozone ~ Month , data = airquality)
\end{Scode}
\end{center}
\end{document}
Sweave は S エンジンを用いてコードチャンクを実行し、それ...
Sweave レポートの自動作成
説明
Sweave はレポートの自動作成のためにテキストと S コードを...
柔軟な枠組を提供する。基本的なアイデアは、S コードをその...
最終的な文章がテキストと統計解析結果だけを含むようにする...
用法
Sweave(file, driver = RweaveLatex(), syntax = getOption(...
Stangle(file, driver = Rtangle(), syntax = getOption("Sw...
引数
file Sweave ソースファイル名
driver 実際に使われるドライバ、以下の詳細を見よ
syntax クラス SweaveSyntax のオブジェクトか、その名前...
既定のインストールでは SweaveSyntaxNoweb と Swe...
... ドライバの設定関数に引き渡される追加引数
詳細
(latex のような)文章作成マークアップと S コードを一体化...
作成する。最終的なマークアップファイルでは S コードはそ...
もし入力データが変わってもレポートを再生成し、レポートを...
た解析を再現するコードをドキュメント化する。Sweave は文...
出力を)を一つのファイルにまとめる。Stangle は Sweave フ...
をつくり出すコードだけを取り出す(そして、それを source ...
\Sexpr{} 文中のコードは S tangle により無視される。Stang...
Sweave へのフロントエンドであり、文章部分を取り去り、使...
コードチャンクを連結する。
フック関数
各コードチャンクが評価される前に、幾つかのフック関数を実...
が設定されていれば、それはフック関数の集まりとされる。一...
の各論理オプション毎に一つのフック関数を指定することがで...
の時、そしてその時だけ実行される。フックは getOption("S...
成分でなければならず、引数を持たない関数でなければならな...
が list(fig = foo) と定義されており、foo が関数なら、そ...
されるであろう。これは一連の図チャンク中の作図パラメータ...
ユーザは新しい Sweave オプションと、それらに関連する任意...
注意しよう。例えば、大局的環境中の全てのオブジェクトを取...
関数を定義できる。すると clean=TRUE である全てのコードチ...
ことになるであろう。
構文上の定義
Sweave は,ドキュメントとテキストチャンクを記述するのに...
デフォルトはnowebスタイルの構文であるが,代わりにlatexス...
詳しくはユーザーマニュアルを参照.
Author(s)
Friedrich Leisch
References
Friedrich Leisch: Sweave User Manual, 2002
http://www.ci.tuwien.ac.at/~leisch/Sweave
Friedrich Leisch: Dynamic generation of statistical repo...
Hrdle and B. Rnz, editors, Compstat 2002 - Proceedings i...
575-580. Physika Verlag, Heidelberg, Germany, 2002. ISBN...
See Also
RweaveLatex, Rtangle
Examples
testfile <- system.file("Sweave", "Sweave-test-1.Rnw", p...
## create a LaTeX file
Sweave(testfile)
## create an S source file from the code chunks
Stangle(testfile)
## which can be simply sourced
source("Sweave-test-1.R")
// ** 4.1 The RweaveLatex driver
** 4.1 RweaveLatex ドライバー [#i9d73ca4]
//This driver transforms .Snw files with LATEX documentat...
// LATEX files (for typesetting both with standard latex ...
このドライバーは,
LaTeX ドキュメントのチャンクと
R コードチャンクをもった
.Snw ファイルを
適切なLaTeXファイル
(通常のlatex と pdflatex でタイプセットするための)へと変...
RweaveLatex R/LaTeX Driver for Sweave
説明
LaTeX ファイルの中で Rコードチャンクを変換する Sweave ...
使用法
RweaveLatex()
RweaveLatexSetup(file, syntax, output = NULL, quiet =...
debug = FALSE, echo = TRUE, eval = TRUE,
split = FALSE, stylepath = TRUE,
pdf = TRUE, eps = TRUE)
引数
file Name of Sweave source file.
syntax An object of class SweaveSyntax.
output Name of output file, default is to remove exte...
‘.Snw’
and to add extension ‘.tex’. Any directory names in...
such that the output is created in the current work...
quiet If TRUE all progress messages are suppressed.
debug If TRUE, input and output of all code chunks is...
stylepath If TRUE, a hard path to the file ‘Sweave.st...
set, if FALSE, only \usepackage{Sweave} is written....
the TeX file less portable, but avoids the problem ...
version of ‘Sweave.sty’ to some place in your TeX i...
is ignored if a \usepackage{Sweave} is already pres...
file.
echo set default for option echo, see details below.
eval set default for option eval, see details below.
split set default for option split, see details below.
pdf set default for option pdf, see details below.
eps set default for option eps, see details below.
サポートされているオプション
RweaveLatex supports the following options for code c...
the default values):
echo: logical (TRUE). Include S code in the output fi...
eval: logical (TRUE). If FALSE, the code chunk is not...
output produced.
results: character string (verbatim). If verbatim, th...
the verbatim-like Soutput environment. If tex, the ...
latex markup and included as is. If hide then all o...
the code executed during the weave).
print: logical (FALSE) If TRUE, each expression in th...
statement before evaluation, such that the values o...
term: logical (TRUE). If TRUE, visibility of values e...
assignments are not printed, values of single objec...
only from explicit print or cat statements.
split: logical (FALSE). If TRUE, text output is writt...
strip.white: logical (TRUE). If TRUE, blank lines at ...
removed.
prefix: logical (TRUE). If TRUE generated filenames o...
prefix.
prefix.string: a character string, default is the nam...
include: logical (TRUE), indicating whether input sta...
statements for figures should be auto-generated. Us...
output should appear in a different place than the ...
manually).
fig: logical (FALSE), indicating whether the code chu...
only one figure per code chunk can be processed thi...
eps: logical (TRUE), indicating whether EPS figures s...
FALSE.
pdf: logical (TRUE), indicating whether PDF figures s...
FALSE.
width: numeric (6), width of figures in inch.
height: numeric (6), height of figures in inch.
Author(s)
Friedrich Leisch
References
Friedrich Leisch: Sweave User Manual, 2002
http://www.ci.tuwien.ac.at/~leisch/Sweave
See Also
Sweave, Rtangle
*** 4.1.1 分離されたファイルへの書き込み [#x8d89f6a]
// *** 4.1.1 Writing to separate files
// If split is set to TRUE, then all text corresponding t...
// environments) is written to seperate files. The filena...
// if several code chunks have the same label, their outp...
// label, then the number of the chunk is used instead. T...
もしも,splitが真にセットされると,コードチャンクに対応す...
// *** 4.1.2 LATEX style file and figure sizes [#i05aed9a]
*** 4.1.2 LaTeX のスタイルファイルと図のサイズ [#s5a0dc83]
// The driver automatically inserts a \usepackage{.../Swe...
// as last line before the \begin{document} statement of ...
// file if no \usepackage{Sweave} is found in the Sweave ...
// This style file defines the environments Sinput and So...
// typesetting code chunks.
もしも Sweave ソースファイルに \usepackage{Sweave.sty} が...
// If you do not want to include the standard style file,...
// you have your own definitions for Sinput and Soutput e...
// different place, simply insert a comment like % \usepa...
// the preamble of your latex file, this will prevent aut...
// of the line. Sweave.sty also sets the default LATEX fi...
// (which is independent of the size of the generated EPS...
// files).
もしも,たとえばあなたが自分で,別の場所にSinput,Soutput...
Sweave.sty は,既定の LaTeX の図の幅をセットする(これは生...
// The current default is
現在の既定値は,
\setkeys{Gin}{width=0.8\textwidth}
// if you want to use another width for the figures that ...
// automatically generated and included by Sweave, simply...
// similar to the one above after \begin{document}.
であり,図について,Sweaveが自動的に生成してインクルード...
// Note that a new graphics device is opened for each fig...
// (option fig=TRUE), hence all graphical parameters of t...
// must be set in each single figure chunk and are forgot...
// respective chunk (because the device is closed when le...
// chunk).
それぞれのフィギュアチャンク(option fig=TRUE)ごとに,新し...
// Attention: One thing that gets easily confused are the...
// parameters of the R graphics devices and the correspon...
// to the LATEX \includegraphics command.
注意:R グラフィックデバイスのパラメータ width/height はL...
// The Sweave options width and height are passed to the ...
// devices, and hence affect the default size of the prod...
// files.
Sweave の widthとheight オプションは,R のグラフィックデ...
// They do not affect the size of figures in the document...
// they will always be 80% of the current text width.
そしてそれは,ドキュメントの中の図のサイズには影響せず,...
// Use \setkeys{Gin} to modify figure sizes or use explicit
// \includegraphics commands in combination with Sweave o...
// include=FALSE.
図のサイズを変更するには,\setkeys{Gin} を使用するか,Swe...
// *** 4.1.3 Prompts and text width for that
*** 4.1.3 プロンプト記号とテキストの幅 [#h0f19a7b]
//As of R version 1.6.0 the driver gets the prompts used ...
// R’s options() settings. To set new prompts use somthin...
// options(prompt="MyR> ", continue="...")
// see help(options) for details. Similarly the text widt...
R バージョン1.6.0 と同じように,ドライバーは入力行と継続...
// ** 4.2 The Rtangle driver
** 4.2 Rtangle ドライバー [#b7f415b2]
// This driver can be used to extract S and R code chunks...
// be written to one large file or seperate files (one fo...
// prefix.string and engine have the same defaults and in...
// driver. Use the standard noweb command line tool notan...
// should be extracted.
このドライバーは,.SnwファイルからSとRのコードを抽出する...
Rtangle R Driver for Stangle
説明
A driver for Stangle that extracts R code chunks.
使用法
Rtangle()
RtangleSetup(file, syntax, output = NULL, annotate = T...
split = FALSE, prefix = TRUE, quiet = FALSE)
引数
file Name of Sweave source file.
syntax An object of class SweaveSyntax.
output Name of output file, default is to remove exten...
and to add extension ‘.R’. Any directory names in fi...
such that the output is created in the current worki...
annotate By default, code chunks are seperated by co...
and numbers of the code chunks. If FALSE, only the c...
any decorating comments are extracted.
split Split output in single files per code chunk?
prefix If split = TRUE, prefix the chunk labels by the...
to get output file names?
quiet If TRUE all progress messages are suppressed.
Author(s)
Friedrich Leisch
References
Friedrich Leisch: Sweave User Manual, 2002
http://www.ci.tuwien.ac.at/~leisch/Sweave
See Also
Sweave, RweaveLatex
Acknowledgements
The author wants to thank Vince Carey, Robert Gentlema...
Ripley, Anthony Rossini, and Dietrich Trenkler for pro...
development versions of the software or fixing bugs.
// * A Frequently Asked Questions
* FAQ: しばしば聞かれる質問 [#i168c9e1]
// ** A.1 Where can I find the manual and other informati...
** A.1 どこでSweaveのマニュアルやその他の情報を入手できま...
// The newest version of the Sweave manual can always be ...
// http://www.ci.tuwien.ac.at/~leisch/Sweave
// where you also find several example files, and the lis...
// addition, the homepage has several papers on Sweave li...
// miniseries from R News (Issues 2/3 and 2/3).
最新のSweaveのマニュアルはいつも[[Sweaveホームページ:http...
// ** A.2 How can I get Emacs to automatically recognize ...
** A.2 どのようにしたら Emacs に,Sweave フォーマットのフ...
// Include something like the following in your .emacs fi...
あなたの .emacs ファイルに,つぎのようなコードをいれまし...
(defun Rnw-mode ()
(require 'ess-noweb)
(noweb-mode)
(if (fboundp 'R-mode)
(setq noweb-default-code-mode 'R-mode)))
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-to-list 'auto-mode-alist '("\\.Snw\\'" . Rnw-mode))
(setq reftex-file-extensions
'(("Snw" "Rnw" "nw" "tex" ".tex" ".ltx") ("bib" ".b...
(setq TeX-file-extensions
'("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "...
// The first block of commands makes emacs to automatical...
// mode (with R mode the default code mode) for files wit...
// two lines make RefTeX work on noweb files. You can dow...
コマンドの最初のブロックは拡張子が .Rnwと .Snw のファイル...
// ** A.3 Can I run Sweave directly from a shell?
** A.3 Sweave をシェルから直接走らせることはできますか? [...
// E.g., for writing makefiles it can be useful to run Sw...
// start R and then run Sweave. This can easily be done u...
例えば,makefile を書くなどすると,手動で R を起動してか...
#!/bin/sh
echo "library(tools); Sweave(\"$1\")" | R --no-save --no...
// ** A.4 Why does LATEX not find my EPS and PDF graphic ...
** A.4 なぜLaTeXはEPSとPDFファイルがファイル名にドットを...
// Sweave uses the standard LATEX package graphicx to han...
// uses EPS files for standard LATEX and PDF files for PD...
// no extension, i.e., contains no dots. Hence, you may r...
// the name of your Sweave file contains extra dots: ‘foo...
Sweave は,グラフィックファイルを扱うために,標準の LaTeX...
// **A.5 Why does Sweave by default create both EPS and P...
**A.5 なぜ Sweave は既定値では EPS と PDF のグラフィック...
// The LATEX package graphicx needs EPS files for plain L...
// latter can also handle PNG and JPEG files). Sweave aut...
// PDF format, such that the user can freely run latex or...
LaTeX のパッケージ graphicx は素の LaTeX のためには EPS ...
// **A.6 Why do R lattice graphics not work?
**A.6 R lattice グラフィックスがなぜ動かないのですか? [#v...
// The commands in package lattice have different behavio...
// the base package: lattice commands return an object of...
// performed by the print method for the class. Encapsula...
// statements should do the trick, e.g.:
lattice パッケージでのコマンドは標準の plot コマンドとは...
<<fig=TRUE>>=
library(lattice)
print(bwplot(1:10))
@
// should work. Future versions of Sweave may have more a...
// graphics.
これでうまくいきます.Sweave の将来のバージョンでは trell...
// ** A.7 How can I get Black & White lattice graphics?
** A.7 どうすれば白黒の lattice グラフィックスを使えます...
// What is the most elegant way to specify that strip pan...
// and graphs are to be in black and white when lattice i...
// global option that stays in effect for multiple plots.
// Answer by Deepayan Sarkar: I’d do something like this ...
lattice を Sweave で使うときに,分割されたパネルが透明の...
<<...>>
library(lattice)
ltheme <- canonical.theme(color = FALSE) ## in-built B...
ltheme$strip.background$col <- "transparent" ## change...
lattice.options(default.theme = ltheme) ## set as defa...
@
// ** A.8 Creating several figures from one figure chunk ...
** A.8 ひとつのフィギュアチャンクからいくつかの図を作りた...
// Consider that you want to create several graphs in a l...
つぎのようなループの中でいくつかの図を作りたいとしましょ...
<<fig=TRUE>>
for (i in 1:4) plot(rnorm(100)+i)
@
// This will currently not work, because Sweave allows on...
// simple reason is that Sweave opens a postscript device...
// afterwards. If you need to plot in a loop, you have to...
現在のところこれはまだうまくいきません.というのは,Sweav...
<<results=tex,echo=FALSE>>=
for(i in 1:4){
file=paste("myfile", i, ".eps", sep="")
postscript(file=file, paper="special", width=6, height=6)
plot(rnorm(100)+i)
dev.off()
cat("\\includegraphics{", file, "}\n\n", sep="")
}
@
// ** A.9 How can I place all those auto-generated graphi...
** A.9 どうしたら自動的に生成されたグラフィクスファイルを...
// After
まず,
\SweaveOpts{prefix.string=foo/bar}
// Sweave will place all figures in subdirectory foo and ...
// name of the Sweave file). The subdirectory foo should ...
という風にすると,Sweave はすべての図をfoo というサブディ...
// ** A.10 How can I set default par() settings for figur...
** A.10 どうすればフィギュアチャンクに par() の既定値をセ...
// Because each EPS and PDF file opens a new device, usin...
// inside a figure chunk. If you want to use the same set...
// a hook function than repeating the same par() statemen...
// The effect of
EPS も PDF ファイルも新しいデバイスを開くので,par() を使...
options(SweaveHooks=list(fig=function() par(bg="red", fg...
// should be easy to spot. Do not forget to remove the ho...
// want to use it as a global option for all Sweave files.
の効果はすぐわかるでしょう.すべての Sweave ファイルにた...
// ** A.11 Running latex fails on Windows
** A.11 Windows で latex ファイルを走らせる [#jd34d2b5]
// If you can create the ‘.tex’ file by running Sweave() ...
// ‘.dvi’ or ‘.pdf’, this is most likely caused by a spac...
// of your R installation contains any blank characters (...
// in English versions of Windows), this may cause proble...
// cannot handle blanks in paths properly.
// Two possible solutions:
// 1. Install R in a path not containing any blanks.
// 2. Copy the file ‘Sweave.sty’ to a directory in your t...
// Sweave file and put a \usepackage{Sweave} into the pre...
R の中で Sweave() を走らせることで '.tex' ファイルを作っ...
ふたつの解決方法があります.~
1: R を,空白文字のふくまれていないパスにインストールする...
2: 'Sweave.sty' を tex のパスか Sweave ファイルをふくんで...
// ** A.12 How can I change the formatting of S input and...
** A.12 どうすれば S インプットとアウトプットのチャンクの...
// Sweave uses the fancyvrb package for formatting all S ...
// powerful and flexible package that allows fine control...
// If you want to change the default layout, simply read ...
// the definitions of the Sinput and Soutput environments...
Sweave はすべての S コードの出力のフォーマットをするため...
// ** A.13 How can I change the line length of S input an...
** A.13 どうすれば S インプットとアウトプットの1行の長さ...
// Sweave respects the usual way of specifying the desire...
// E.g., after options(width=40) lines will be formatted ...
Sweave は,S における,望みの行の長さを指定する通常のやり...
// ** A.14 Why are chunks with eval=FALSE executed by R C...
** A.14 eval=FALSE をふくむチャンクはなぜ R CMD チェック...
// This is a feature, not a bug. From the \u201cWriting R...
// Package vignettes found in directory inst/doc are test...
// all R code chunks they contain to ensure consistency b...
// Note that even code chunks with option eval=FALSE are ...
// vignette that should not be tested, move it to a norma...
// The reason for this policy is that users should be abl...
// executable as seen in the vignette.
これは仕様であってバグではありません."Writing R Extensio...
// ** A.15 Can I use Sweave for HTML files?
// Package R2HTML provides a driver for using Sweave in c...
** A.15 Sweave を HTML ファイルに使えますか? [#eeb8f1ef]
R2HTML パッケージは,LaTeX ではなく HTML との組合せで Swe...
// ** A.16 After loading package R2HTML Sweave doesn\u201...
** A.16 R2HTML パッケージをロードすると Sweave がちゃんと...
// Package R2HTML registers an Sweave driver for HTML fil...
// is in the search list before the default syntax.
R2HTML パッケージはHTML ファイルのための Sweave ドライバ...
options(SweaveSyntax="SweaveSyntaxNoweb")
//or calling Sweave like
または,Sweave をつぎのように呼ぶことで,R2HTML をロード...
Sweave(..., syntax="SweaveSyntaxNoweb")
//ensures the default syntax even after loading R2HTML.
// * References
* 文献 [#k56ec2e5]
Richard A. Becker, John M. Chambers, and Allan R. Wilks....
Chapman & Hall, London, UK, 1988.
John M. Chambers. Programming with data: A guide to the ...
Springer Verlag, Berlin, Germany, 1998.
Friedrich Leisch. Sweave: Dynamic generation of statisti...
literate data analysis.
In Wolfgang Hrdle and Bernd Rnz, editors, Compstat 200...
Computational Statistics, pages 575\u2013580. Physika ...
Germany, 2002. URL http://www.ci.tuwien.ac.at/~leisch/...
ISBN 3-7908-1517-9.
R Development Core Team. R: A language and environment f...
computing, 2002. URL http://www.R-project.org. version...
Norman Ramsey. Noweb man page. University of Virginia, U...
http://www.cs.virginia.edu/~nr/noweb. version 2.9a.
Anthony J. Rossini, Richard M. Heiberger, Rodney Sparapa...
and Kurt Hornik.
Emacs speaks statistics: A multi-platform, multi-packa...
environment for statistical analysis.
Journal of Computational and Graphical Statistics, 200...
(Accepted for publication).
Richard M. Stallman. The Emacs Editor. Free Software Fou...
Boston, MA, USA, 1999. URL http://www.gnu.org. version...
William N. Venables and Brian D. Ripley. S Programming. ...
ページ名: