Re: [R] Paths in knitr

2017-06-08 Thread Yihui Xie
Why do you have to set the base.dir option?

Regards,
Yihui
--
https://yihui.name


On Thu, Jun 8, 2017 at 6:15 AM,   wrote:
> Hi All,
>
> I have to compile a report for the management and decided to use RMarkdown
> and knitr. I compiled all needed plots (using separate R scripts) before
> compiling the report, thus all plots reside in my graphics directory. The
> RMarkdown report needs to access these files. I have defined
>
> ```{r setup, include = FALSE}
> knitr::opts_knit$set(
>   echo = FALSE,
>   xtable.type = "html",
>   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>   fig.path = "results/graphics")  # relative path required, see
> http://yihui.name/knitr/options
> ```
>
> and then referenced my plot using
>
> 
>
> because I want to be able to customize the plotting attributes.
>
> But that fails with the message "pandoc.exe: Could not fetch
> email_distribution_pie.png".
>
> If I give it the absolute path
> "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/graphics/email_distribution_pie.png"
> it works fine as well if I copy the plot into the directory where the
> report.RMD file resides.
>
> How can I tell knitr to fetch the ready-made plots from the graphics
> directory?
>
> Kind regards
>
> Georg
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Paths in knitr

2017-06-09 Thread Yihui Xie
I'd say it is an expert-only option. If you do not understand what it
means, I strongly recommend you not to set it.

Similarly, you set the root_dir option and I don't know why you did it, but
it is a typo anyway (should be root.dir).

Regards,
Yihui
--
https://yihui.name

On Fri, Jun 9, 2017 at 4:50 AM,  wrote:

> Hi Yi,
>
> many thanks for your reply.
>
> Why I do have to se the base.dir option? Cause, to me it is not clear from
> the documentation, where knitr looks for data files and how I can adjust
> knitr to tell it where to look. base.dir was a try, but did not work.
>
> Can you give me a hint where I can find information/documentation on this
> path issue?
>
> Kind regards
>
> Georg
>
>
> > Gesendet: Donnerstag, 08. Juni 2017 um 15:05 Uhr
> > Von: "Yihui Xie" 
> > An: g.maub...@weinwolf.de
> > Cc: "R Help" 
> > Betreff: Re: [R] Paths in knitr
> >
> > Why do you have to set the base.dir option?
> >
> > Regards,
> > Yihui
> > --
> > https://yihui.name
> >
> >
> > On Thu, Jun 8, 2017 at 6:15 AM,   wrote:
> > > Hi All,
> > >
> > > I have to compile a report for the management and decided to use
> RMarkdown
> > > and knitr. I compiled all needed plots (using separate R scripts)
> before
> > > compiling the report, thus all plots reside in my graphics directory.
> The
> > > RMarkdown report needs to access these files. I have defined
> > >
> > > ```{r setup, include = FALSE}
> > > knitr::opts_knit$set(
> > >   echo = FALSE,
> > >   xtable.type = "html",
> > >   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
> > >   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
> > >   fig.path = "results/graphics")  # relative path required, see
> > > http://yihui.name/knitr/options
> > > ```
> > >
> > > and then referenced my plot using
> > >
> > > 
> > >
> > > because I want to be able to customize the plotting attributes.
> > >
> > > But that fails with the message "pandoc.exe: Could not fetch
> > > email_distribution_pie.png".
> > >
> > > If I give it the absolute path
> > > "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/
> graphics/email_distribution_pie.png"
> > > it works fine as well if I copy the plot into the directory where the
> > > report.RMD file resides.
> > >
> > > How can I tell knitr to fetch the ready-made plots from the graphics
> > > directory?
> > >
> > > Kind regards
> > >
> > > Georg
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Paths in knitr

2017-06-12 Thread Yihui Xie
Will there be anything wrong if you do not set these options?

Regards,
Yihui
--
https://yihui.name


On Mon, Jun 12, 2017 at 2:24 AM,   wrote:
> Hi Yihui,
> Hi Duncan,
>
> I corrected my typo. Unfortunately knitr did not find my plots in the
> directory where they reside which is different from the Rmd document.
>
> The documentation of knitr says:
>
> base.dir: (NULL) an absolute directory under which the plots are generate
> root.dir: (NULL) the root directory when evaluating code chunks; if NULL,
> the directory of the input document will be used
>
> From that description I thought, if the base.dir can be used for writng
> plots, it is then also used for reading plots if set? No, it is not.
> If I set the root directory to the plots/graphics directory will knitr
> then find my plots? No, it does not.
>
> Reading blog posts my thoughts looked not so strange to me, e.g.
> https://philmikejones.wordpress.com/2015/05/20/set-root-directory-knitr/.
> Unfortunately, it does not work for me.
>
> I am using a RStudio project file. Could it be that this interferes which
> the knitr options?
>
> I tried the solution that Duncan suggested:
>
> c_path_plots <-
> "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/graphics
>
> `r knitr::include_graphics(file.path(c_path_plots,
> "email_distribution_pie.png"))`
>
> This solution works fine. I will go with it for this project as I have to
> finish my report soon.
>
> I read Hadley's book on bulding R Packages (
> https://www.amazon.de/R-Packages-Hadley-Wickham/dp/1491910593) and found
> it quite complicated and time consuming to build one. Thus I did not try
> yet to build my own packages. At the end of last week I heard from another
> library (http://reaktanz.de/R/pckg/roxyPackage/) which shall make building
> packages much easier. I plan to try that shortly.
>
> On my path to become better in analytics using R, I will try to use
> modules of Rmd files which can then easily be integrated into a Rmd
> report. I have yet to see how I can include these file into a complete
> report.
>
> Kind regards
>
> Georg
>
>
> - Weitergeleitet von Georg Maubach/WWBO/WW/HAW am 12.06.2017 08:47
> -
>
> Von:Yihui Xie 
> An: g.maub...@gmx.de,
> Kopie:  R Help 
> Datum:  09.06.2017 20:53
> Betreff:Re: [R] Paths in knitr
> Gesendet von:   "R-help" 
>
>
>
> I'd say it is an expert-only option. If you do not understand what it
> means, I strongly recommend you not to set it.
>
> Similarly, you set the root_dir option and I don't know why you did it,
> but
> it is a typo anyway (should be root.dir).
>
> Regards,
> Yihui
> --
> https://yihui.name
>
> On Fri, Jun 9, 2017 at 4:50 AM,  wrote:
>
>> Hi Yi,
>>
>> many thanks for your reply.
>>
>> Why I do have to se the base.dir option? Cause, to me it is not clear
> from
>> the documentation, where knitr looks for data files and how I can adjust
>> knitr to tell it where to look. base.dir was a try, but did not work.
>>
>> Can you give me a hint where I can find information/documentation on
> this
>> path issue?
>>
>> Kind regards
>>
>> Georg
>>
>>
>> > Gesendet: Donnerstag, 08. Juni 2017 um 15:05 Uhr
>> > Von: "Yihui Xie" 
>> > An: g.maub...@weinwolf.de
>> > Cc: "R Help" 
>> > Betreff: Re: [R] Paths in knitr
>> >
>> > Why do you have to set the base.dir option?
>> >
>> > Regards,
>> > Yihui
>> > --
>> > https://yihui.name
>> >
>> >
>> > On Thu, Jun 8, 2017 at 6:15 AM,   wrote:
>> > > Hi All,
>> > >
>> > > I have to compile a report for the management and decided to use
>> RMarkdown
>> > > and knitr. I compiled all needed plots (using separate R scripts)
>> before
>> > > compiling the report, thus all plots reside in my graphics
> directory.
>> The
>> > > RMarkdown report needs to access these files. I have defined
>> > >
>> > > ```{r setup, include = FALSE}
>> > > knitr::opts_knit$set(
>> > >   echo = FALSE,
>> > >   xtable.type = "html",
>> > >   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>> > >   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>> > >   fig.path = "results/graphics")  # relative path required, see
>> > > http://yihui.name/knitr/options
>> > > ```
>> > >
>> > > and then r

Re: [R] RMarkdown question

2017-08-29 Thread Yihui Xie
Although it is not an elegant solution, but if your output format is
HTML, you can add an arbitrary empty HTML element like  before your code chunk. Then you can jump to this
 via a link like "see [this code chunk](#foo)".

Regards,
Yihui
--
https://yihui.name


On Tue, Aug 29, 2017 at 1:30 PM, Roy Mendelssohn - NOAA Federal
 wrote:
> Hi All:
>
> In creating a R Notebook I know that in the text I can  link to a (sub) 
> section by using the command:
>
>
> [Header 1](#anchor)
>
>
>  and putting the appropriate anchor name at the appropriate header.  But can 
> the same be done for code chunks,  if the code chunk is named? What I want to 
> do is say that such and such code chunk is an example of how to do something, 
>  and have that link to the appropriate code chunk.
>
> Thanks for any help.
>
> -Roy
>
>
>
>
>
> **
> "The contents of this message do not reflect any position of the U.S. 
> Government or NOAA."
> **
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> ***Note new street address***
> 110 McAllister Way
> Santa Cruz, CA 95060
> Phone: (831)-420-3666
> Fax: (831) 420-3980
> e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/
>
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected"
> "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] WordCloud Does not display in RMD File in R Studio

2016-07-29 Thread Yihui Xie
Typically you don't need to open the png() device manually. Try
comment out that line.

BTW, I'm not sure which wordcloud package you were using, but this one
is the best one I have seen: https://github.com/Lchiffon/wordcloud2

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Fri, Jul 29, 2016 at 11:53 AM, Shivi Bhatia  wrote:
> Dear Team,
>
> I have created a text mining solution for one of my business owners.
>
> I am sharing with his using RMD via HTML. All is working ok however the
> WordCloud does not populate any output in RMD file.
>
> Few months back when this happened on R studio i searched and used
> dev.off() to shut down any concurrent running session but this also does
> not help.
>
> Other plots that i have created such ggplot and barpplot they are being
> displayed. similarly i can show wordcloud also in R Studio but not on RMD.
>
> Not sure what i am doing wrong as i only get a message staing NULL when i
> run wordcloud.
> Plz find the code for wordcloud if that helps:
> word0<- names(frequency)
> png("p3_sa_para.png", 640, 480)
>
>
> wordcloud(word0,frequency,random.order =F,
> colors = brewer.pal(8, "Dark2"),scale = c(5.5,0.5),min.freq = 100,
> max.words = Inf)
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] png package in Ubuntu 12.04 with R 3.1.0

2015-05-26 Thread Yihui Xie
sudo apt-get install libpng12-dev

I'm not sure about Ubuntu 12.04. You may need a different libpng??-dev.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Tue, May 26, 2015 at 2:10 AM, Gygli, Gudrun  wrote:
>
> Dear All,
>
>
> I am using R to analyse computer simulations of ligand docking in a protein.
>
> I am plotting the results as scatterplots and bopxplots, using the code below.
>
> This works perfectly fine.
>
>
> I would like now to add a png file to that plot, meaning I want sth like:
>
>
> png(file="analysis.png")
> par(mfrow=c(1,3), oma=c(0,0,2,0))
>
> plot
>
> boxplot
>
> PNG figure I read in
>
>
> I am running Ubuntu 12.04 and R 3.1.0.
>
>
> readPNG and the png packge do NOT work for me at this point.
>
>
> when I try to install the png package I get the error below.
>
>
> Any ideas what's wrong or other options to import png files?
>
>
> Thank you in advance for the help.
>
>
> Best regards
>
>
> Gudrun
>
>
>
> png(file="analysis.png")
> par(mfrow=c(1,2), oma=c(0,0,2,0))
> plot(data, main="all", xlab="simulations run", ylab="steps")
> boxplot(data, main="steps", horizontal = FALSE, axes = FALSE, staplewex = 1)
> text(y = boxplot.stats(data)$stats, labels = boxplot.stats(data)$stats, x = 
> 1.35)
> title("analysis", outer=TRUE)
>
>
>
> install.packages("png")
>
>
> downloaded 24 Kb
>
>
> * installing *source* package 'png' ...
> ** package 'png' successfully unpacked and MD5 sums checked
> ** libs
> gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG  `libpng-config --cflags` 
> -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
> -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c read.c 
> -o read.o
> /bin/bash: libpng-config: command not found
> read.c:3:17: fatal error: png.h: No such file or directory
> compilation terminated.
> make: *** [read.o] Error 1
> ERROR: compilation failed for package 'png'
> * removing '/home/g1/R/x86_64-pc-linux-gnu-library/3.1/png'
>
> The downloaded source packages are in
> '/tmp/Rtmpvo3r8J/downloaded_packages'
> Warning message:
> In install.packages("png") :
>   installation of package 'png' had non-zero exit status
>
>
>
>
> Gudrun Gygli, MSc
>
> PhD candidate
>
> Wageningen University
> Laboratory of Biochemistry
> Dreijenlaan 3
> 6703 HA Wageningen
> The Netherlands
>
> Phone  31 317483387
> e-mail: gudrun.gy...@wur.nl
>
> - - - - - - - - - - - - - - - - - -
>
> Project information: 
> http://www.wageningenur.nl/en/show/Bioinformatics-structural-biology-and-molecular-modeling-of-Vanillyl-Alcohol-Oxidases-VAOs.htm
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] what constitutes a 'complete sentence'?

2015-07-03 Thread Yihui Xie
Sigh, how natural it is to say "This package ...", but you probably
don't know a package can be easily rejected by CRAN simply because of
this phrase "This package" (it has been clearly stated in the R-exts
manual).

I don't think the grammar is the problem here. When in doubt, I always
check what MASS does:
http://cran.rstudio.com/web/packages/MASS/index.html Turns out its
description is not a complete sentence, either.

Sounds like R has become a language for statistical computing and
graphics, plus English grammar since 3.0.x.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Fri, Jul 3, 2015 at 8:43 AM, Rolf Turner  wrote:
> On 03/07/15 20:09, Federico Calboli wrote:
>>
>> Hi All,
>>
>> I am upgrading a package for CRAN, and I get this note:
>>
>> checking DESCRIPTION meta-information ... NOTE Malformed Description
>> field: should contain one or more complete sentences.
>>
>> This is puzzling because:
>>
>> cat DESCRIPTION
>>
>> ... Description: Functions designed to test for single gene/phenotype
>> association and for pleiotropy on genetic and genomic data. ...
>>
>> In my understanding "Functions designed to test for single
>> gene/phenotype association and for pleiotropy on genetic and genomic
>> data.” *is* a complete sentence.  So, what is complete sentence in
>> the opinion of whomever coded that check?
>
>
>
> If that is your understanding you need to go back to school and learn some
> grammar.  What you have is a noun ("Functions") modified by an adjectival
> clause.  No verb in sight.  Ergo *not* a complete sentence.
>
> OTOH you are probably in good company in not knowing your grammar.  The CRAN
> folks most likely don't know grammar either.  I suspect that they *don't*
> actually demand a complete sentence.  Such a demand would in fact be rather
> pedantic.  Moreover I really can't see how the package checker could
> possibly check for complete sentences.  This would require some very
> sophisticated programming, it seems to me.
>
> If it turns out that you *really* need a complete sentence, you could say
> (for instance):
>
> This package consists of functions designed to test for single
> gene/phenotype association and for pleiotropy on genetic and genomic data.
>
> The foregoing *is* a complete sentence.
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Rmarkdown / knitr naming the output file

2015-07-06 Thread Yihui Xie
There is no direct way to get it, but you can get 1) the input
filename via knitr::current_input(), and 2) the output format via
knitr::opts_knit$get('rmarkdown.pandoc.to'). You may be able to figure
out the output filename based on these two pieces of information.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Mon, Jul 6, 2015 at 7:24 AM, AURORA GONZALEZ VIDAL
 wrote:
> Hello.
> I have a question for Rmarkdown users.
>
> Is there any way to give a name to the output document inside the Rmd?
>
> For example, my rmd's name is "bb.Rmd" but when I knitr to pdf I want it to
> name the pdf differently than "bb.pdf", for example, "doc1.pdf". Is there
> any way to do this?
>
> Thank you very much
>
>
> --
> Aurora González Vidal
>
> Sección Apoyo Estadístico.
> Servicio de Apoyo a la Investigación (SAI).
> Vicerrectorado de Investigación.
> Universidad de Murcia
> Edif. SACE . Campus de Espinardo.
> 30100 Murcia
>
> @. aurora.gonzal...@um.es
> T. 868 88 7315
> F. 868 88 7302
> www.um.es/sai
> www.um.es/ae

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Yihui Xie
Your LyX example has two problems: 1) We don't have your .RData; 2)
You didn't library(reshape) and library(lattice). Hence it is not a
self-contained reproducible example.

After fixing these two issues, I don't see why lattice graphics can be
problematic with knitr. There is no need to print() the plot, and no
need to pdf(), either. See the attached PDF I generated.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Fri, Jul 10, 2015 at 7:18 PM, Rich Shepard  wrote:
> On Fri, 10 Jul 2015, David Winsemius wrote:
>
>> #Generally one needs to complete a pdf() call with:
>>
>> dev.off()
>>
>> # And an empty file is the symptom os such a failure.
>
>
>
> David,
>
>   I did leave that off the example file, but it make no difference. The
> attached is the compiled example.pdf
>
> Rich
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


example.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot() [RESOLVED]

2015-07-11 Thread Yihui Xie
I guess you didn't tell us you were compiling the document with dvips
(BTW, I'm surprised that dvips is still alive today...), otherwise the
solution would be simply to use the postscript device instead of the
default pdf device (i.e. use the chunk option dev='postscript').
Hopefully you learned some lessons on what a reproducible example
means.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Sat, Jul 11, 2015 at 9:03 AM, Rich Shepard  wrote:
> On Fri, 10 Jul 2015, Yihui Xie wrote:
>
>> Your LyX example has two problems:
>
>
> Yihui, et al.:
>
>   All fixed now. After adding the specific libraries the chuck calling
> xyplot() to produce the graphic caused an error when I tried to generate a
> dvips preview:
>
> LaTeX Error: File 'figure/unnamed-chunk-7-1' not found.
>
> I could not locate the file with any of these extensions:
> .eps,.ps,.eps.gz,.ps.gz,.eps.Z
>
> Which is what sent me down the path of specifying pdf() and dev.off().
>
>   However, compiling with pdflatex produces the graphic in the document. All
> part of being brand new to using knitr.
>
> Thank you all very much,
>
> Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread Yihui Xie
Perhaps it is not obvious to you, but it is fairly obvious to me that
the R code in this code chunk is incomplete:

<<>>=
xyplot(value ~ sampdate | variable, data=carlin.2.melt, rm.na = T,
ylab = 'Measured Value', xlab = 'Date'
@

There is a ')' missing in the end. When you see errors from parse(),
that often means the code is not syntactically correct.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Sat, Jul 11, 2015 at 7:07 PM, Rich Shepard  wrote:
> On Sat, 11 Jul 2015, Yihui Xie wrote:
>
>> I guess you didn't tell us you were compiling the document with dvips
>
>
>   That's how I preview lyx docs for the past decade-and-a-half or so. The
> final .pdf is generated with pdflatex.
>
>   There is now an issue when a second figure is added to the document: it
> won't compile.
>
>   Attached are the .RData file from the cwd, the test.lyx file (lyx-2.1.3),
> and the two test files from /tmp/.../lyx_tmpbuf3/.
>
>   Here are the lyx messages when I tried compiling the document with
> pdflatex:
>
> 16:51:11.255: Exporting ...
> 16:51:11.259: (buffer-export pdf2)
> 16:51:11.278: Rscript --verbose --no-save --no-restore
> "/usr/share/lyx/scripts/lyxknitr.R"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.Rnw"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.tex" ISO-8859-15
> "/home/rshepard/documents/white-papers/water-chem-anal/"
> 16:51:11.281: running
> 16:51:11.286:   '/usr/lib/R/bin/R --slave --no-restore --no-save
> --no-restore --file=/usr/share/lyx/scripts/lyxknitr.R --args
> -- /tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/test.Rnw
> -- / /tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpb
> 16:51:11.288: uf3/test.tex ISO-8859-15
> /home/rshepard/documents/white-papers/water-chem-anal/'
> 16:51:11.292: 16:51:11.697: Loading required package: methods
> 16:51:11.709: Loading required package: survival
> 16:51:11.712: Loading required package: graphics
> 16:51:11.721: Loading required package: stats
> 16:51:11.921: 16:51:11.923: Attaching package: ‘NADA’
> 16:51:11.925: 16:51:11.927: The following object is masked from
> ‘package:stats’:
> 16:51:11.929: 16:51:11.932: cor
> 16:51:11.933: 16:51:11.969: 16:51:11.970: Attaching package: ‘zoo’
> 16:51:11.972: 16:51:11.975: The following objects are masked from
> ‘package:base’:
> 16:51:11.976: 16:51:11.979: as.Date, as.Date.numeric
> 16:51:11.981: 16:51:12.091: 16:51:12.092: 16:51:12.094: processing file:
> /tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/test.Rnw
> 16:51:12.112:
>   |
>   | |   0%
>   | 16:51:12.113:
>   | |   6%
> 16:51:12.116:   ordinary text without R code
> 16:51:12.118: 16:51:12.120:
>   |
>   | |  12%
> 16:51:12.123: label: unnamed-chunk-1 (with options) 16:51:12.126: List of 1
> 16:51:12.128:  $ echo: logi FALSE
> 16:51:12.130: 16:51:12.204:
>   |
>   |...  |  18%
> 16:51:12.205:   ordinary text without R code
> 16:51:12.207: 16:51:12.210:
>   |
>   |...  |  24%
> 16:51:12.213: label: unnamed-chunk-2
> 16:51:12.239:
>   |
>   |...  |  29%
> 16:51:12.240:   ordinary text without R code
> 16:51:12.242: 16:51:12.244:
>   |
>   |...  |  35%
> 16:51:12.247: label: unnamed-chunk-3
> 16:51:12.293:
>   |
>   |...  |  41%
> 16:51:12.295:   ordinary text without R code
> 16:51:12.297: 16:51:12.299:
>   |
>   |...  |  47%
> 16:51:12.302: label: unnamed-chunk-4
> 16:51:12.344:
>   |
>   |..   |  53%
> 16:51:12.346:   ordinary text without R code
> 16:51:12.348: 16:51:12.350:
>   |
>   |..   |  59%
> 16:51:12.353: label: unnamed-chunk-5
> 16:51:12.432:
>   |
>   |..   |  65%
> 16:51:12.434:   ordinary text without R code
> 16:51:12.436: 16:51:12.438:
>   |
>   |..   |  71%
> 16:51:12.441: label: unnamed-chunk-6
> 16:51:12.484:
>   |
>   |..   |  76%
> 16:51:12.486:   ordinary text without R 

Re: [R] Knitr: setting echo = FALSE globally

2015-07-20 Thread Yihui Xie
Section 5.1.3 of the book "Dynamic Documents with R and knitr" is
titled "Global Options". I don't know how to make it more clear for
readers to find information on global options in the book.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Mon, Jul 20, 2015 at 12:58 PM, Rich Shepard  wrote:
>   Near the beginning of a LyX document I have a knitr chunk with options
> that begin with 'global_options', and includes echo=F. This presents the R
> code in that chunk from displaying in the compiled PDF file. However, all
> following knitr chunks are included in the PDF file.
>
>   Reading the docs (including the Knitr book) does not show me what I am
> doing incorrectly. A pointer to the solution is needed.
>
> Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, : unable to start device PNG

2015-08-11 Thread Yihui Xie
>From my experience, that is often an indication that you built R from
source but didn't pay attention to the cairo/pango dependencies. You
can either install R from a repository, or make sure you have all the
dependencies installed before you build R from source (e.g. for
Ubuntu, use apt-get build-dep r-base-dev).

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Tue, Aug 11, 2015 at 8:32 AM, Ramiro Barrantes
 wrote:
> Hello,
>
> I have the following reproducible knitr document:
>
> \documentclass{article}
> \usepackage[sc]{mathpazo}
> \usepackage[T1]{fontenc}
> \usepackage{geometry}
>
> \begin{document}
>
> <>=
> library(lattice)
> xyplot(1:2~1:2)
> @
>
> \end{document}
>
>
> but knitr is giving me an error:
>
> Quitting from lines 9-11 (test.Rnw)
> Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width,  :
>   unable to start device PNG
> In addition: Warning message:
> In (function (filename = "Rplot%03d.png", width = 480, height = 480,  :
>   unable to open connection to X11 display ''
>
> I don't have X11 installed in this machine and I was hoping not to have to.  
> I am guessing that this is the problem right?
>
> Any suggestions??
>
> Thanks,
> Ramiro

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread Yihui Xie
Can you try to compile your .Rmd file in the R console (instead of
clicking the button in RStudio)?

  rmarkdown::render('your.Rmd')

If it gives the same error, please post the traceback() information. I
just tried the following minimal example, and I was unable to
reproduce your problem. You may also try to reinstall the package:
BiocInstaller::biocLite('IlluminaHumanMethylation450kanno.ilmn12.hg19')

---
output: pdf_document
---

```{r}
library(IlluminaHumanMethylation450kanno.ilmn12.hg19)
data(IlluminaHumanMethylation450kanno.ilmn12.hg19)
```


Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Mon, Jan 12, 2015 at 12:06 AM, Molly Elliott
 wrote:
> R version: 3.1.2 (2014-10-31)
> RStudio version: 0.98.1091
> MacOS X Yosemite v. 10.10.1
>
> When I run the following in the console, all is well:
> data(IlluminaHumanMethylation450kanno.ilmn12.hg19)
>
> Yet, when I compile in my .Rmd file, in RStudio (knit to PDF), I get the 
> following error:
> Error in file(file, "rt") : cannot open the connection
> Calls:  ... withVisible -> eval -> eval -> read.delim -> 
> read.table -> file
> Execution halted
>
> From what I have read, this could be alleviated by pointing the the source 
> file for data(IlluminaHumanMethylation450kanno.ilmn12.hg19) as opposed to 
> LazyLoading with the data() function.  Yet, I’m not sure how to work around 
> this. (This is my first R project ever) The 
> data(IlluminaHumanMethylation450kanno.ilmn12.hg19) is just loading an 
> annotation file from library(IlluminaHumanMethylation450kanno.ilmn12.hg19), 
> and I’m not sure of the file type the data are stored under (.txt, .csv, etc).
>
> Thanks in advance!
>
> Molly

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RMarkdown vignettes v. Jupyter notebooks?

2018-10-11 Thread Yihui Xie
I just have one comment on the multi-language support in R Markdown
(inline below):

On Thu, Oct 11, 2018 at 6:19 AM Ista Zahn  wrote:
>
> Hi Spencer,
>
> On Thu, Oct 11, 2018 at 5:08 AM Spencer Graves
>  wrote:
> >
> > Hello:
> >
> >
> >What are the differences between Jupyter notebooks and RMarkdown
> > vignettes?
>
> Here are some of the main differences I'm aware of:
>
> Rmarkdown files include code and prose. The results produced by the
> code do not appear in the Rmarkdown file; instead, the file must be
> processed and typeset to produce a .pdf or .html (etc.) file that
> includes those results. Jupyter notebooks dispense with with
> processing step: output is displayed directly in the notebook. That
> is, a notebook includes code, prose, and results, while an Rmarkdown
> file includes only code and prose.
>
> Rmarkdown allows control over the inclusion of code and results, and
> over how the results are displayed via header arguments. There is no
> such thing in Jupyter notebooks. Controlling the precise appearance of
> a document produced by Jupyter is much more difficult. Going farther,
> one can even say that Jupyter notebooks are designed primarily to be
> read as Jupyter notebooks; exporting to other formats is kind of an
> afterthought. In contrast, Rmarkdown is designed to produce the final
> readable result in another format (.html or .pdf typically).
>
> Rmarkdown is based on markdown, a human readable markup language,
> Jupyter notebooks are based on JSON, a data interchange format common
> on the web. This means that Rmarkdown files can be easily edited using
> any text editor you like. The same is not true of Jupyter notebooks.
> While you can of course edit the JSON directly, the format is designed
> to be written and read by a computer; editing it yourself is not easy.
>
> Rmarkdown is specific to R (I guess there is some basic support in
> knitr for other languages, but in my experience it never worked well)
> while Jupyter notebooks are language agnostic and "kernels" exist for
> a large number of programming languages. However, each Jupyter
> notebook can use only one kernel; you can't easily have R and Python
> code in the same notebook.

You might want to at least update your impression about the Python
support in R Markdown now :) Last year, with the release of the
reticulate package, the support for Python has been substantially
enhanced in both R Markdown
(https://bookdown.org/yihui/rmarkdown/language-engines.html) and
RStudio 
(https://blog.rstudio.com/2018/10/09/rstudio-1-2-preview-reticulated-python/).
You can easily have both R and Python code in the same R Markdown
document, and the two worlds can freely talk to each other.

> Jupyter notebooks typically run in your browser where the actual text
> editing features are somewhat limited. Rmarkdown is typically run in
> an editor such as Emacs or Rstudio where editing and project support
> is much better and greater customization may be possible. You can work
> indirectly with Jupyter notebooks in Emacs
> (https://github.com/millejoh/emacs-ipython-notebook) and perhaps other
> editors as well; this goes some way toward escaping the tyranny of the
> browser but is more fragile and difficult to get working compared to
> Rmarkdown.
>
> Because Jupyter uses a web-based client-server model, it is easy to
> provide live interactive notebooks on your website (see e.g.,
> https://github.com/jupyterhub/binderhub). As far as I know this is not
> currently possible with Rmarkdown.
>
> >
> >
> >I'm trying to do real time monitoring of the broadcast quality of
> > a radio station, and it seems to me that it may be easier to do that in
> > Python than in R.[1]  This led me to a recent post to
> > "python-l...@python.org" that mentioned "Jupyter, Mathematica, and the
> > Future of the Research Paper"[2] by Paul Romer, who won the 2018 Nobel
> > Memorial Prize in Economics only a few days ago.  In brief, this article
> > suggests that Jupyter notebooks may replace publication in refereed
> > scientific journals as the primary vehicle for sharing scientific
> > research, because they make it so easy for readers to follow both the
> > scientific and computational logic and test their own modifications.
> >
> >
> >A "Jupyter Notebook Tutorial: The Definitive Guide"[3] suggested
> > I first install Anaconda Navigator.  I got version 1.9.2 of that.  It
> > opens with options for eight different "applications" including
> > JupyterLab 0.34.9, Jupyter Notebook 5.6.0, Spyder 3.3.1 (an IDE for
> > Python), and RStudio 1.1.456.
> >
> >
> >This leads to several questions:
> >
> >
> >  1.  In general, what experiences have people had with
> > Jupyter Notebooks, Anaconda Navigator, and RMarkdown vignettes in
> > RStudio, and the similarities and differences?  Do you know any
> > references that discuss this?
>
> I've used both extensively, and noted the differences I've discovered above.
>
> >
> >
> > 

Re: [R] RMarkdown vignettes v. Jupyter notebooks?

2018-10-11 Thread Yihui Xie
In case Jeff's point was not clear enough: the *.nb.html file is very
similar to *.ipynb and it is very different with other output formats
that R Markdown generates. A .nb.html file is generated alongside .Rmd
when you preview an R Markdown notebook, and it contains both the R
Markdown source document and its output (in a single file). See
Section 3.2.2 of the R Markdown book for more info:
https://bookdown.org/yihui/rmarkdown/notebook.html

But I think you are correct that R Markdown and Jupyter have different emphasis.

Regards,
Yihui
--
https://yihui.name

On Thu, Oct 11, 2018 at 9:14 AM Ista Zahn  wrote:
>
> On Thu, Oct 11, 2018 at 10:03 AM Jeff Newmiller
>  wrote:
> >
> > Ista, you do not seem to be aware of the
> > .nb.html format, which is way easier to share with a non-uswr than an ipynb 
> > file yet allows the same in-progress kinds of results to be shared and the 
> > source can be extracted easily using a web browser (no server needed).
>
> Yes, I am aware that notebooks can be exported / converted to other
> formats, including .html and .pdf. My point is about emphasis:
> Rmarkdown gives you header arguments and other tools that allow you a
> great deal of control over how the final .html or .pdf file looks. The
> system seems designed to produce .html or .pdf as the final output
> format. Jupyter notebooks on the other hand seem primarily designed to
> be viewed as Jupyter notebooks: they don't give you a log of tools for
> controlling how the converted / exported notebook appears. That's not
> so say there is not conversion / export possible of course...
>
> --Ista
>
> >
> > There is some controversy about this whole notebook approach [1] but I 
> > think deciding whether it is right for your purposes is highly subjective.
> >
> > FWIW It took me years to figure out how to even open a Jupyter notebook, so 
> > the idea that they should be the gold standard for sharing results seems 
> > absurd to me.
> >
> > [1] https://yihui.name/en/2018/09/notebook-war/
> >
> > On October 11, 2018 5:53:29 AM PDT, Ista Zahn  wrote:
> > >On Thu, Oct 11, 2018 at 8:36 AM Duncan Murdoch
> > > wrote:
> > >>
> > >> On 11/10/2018 7:18 AM, Ista Zahn wrote:
> > >> > Hi Spencer,
> > >> >
> > >> > On Thu, Oct 11, 2018 at 5:08 AM Spencer Graves
> > >> >  wrote:
> > >> >>
> > >> >> Hello:
> > >> >>
> > >> >>
> > >> >> What are the differences between Jupyter notebooks and
> > >RMarkdown
> > >> >> vignettes?
> > >> >
> > >> > Here are some of the main differences I'm aware of:
> > >> >
> > >> > Rmarkdown files include code and prose. The results produced by the
> > >> > code do not appear in the Rmarkdown file; instead, the file must be
> > >> > processed and typeset to produce a .pdf or .html (etc.) file that
> > >> > includes those results. Jupyter notebooks dispense with with
> > >> > processing step: output is displayed directly in the notebook. That
> > >> > is, a notebook includes code, prose, and results, while an
> > >Rmarkdown
> > >> > file includes only code and prose.
> > >>
> > >> RStudio can display the output mixed in with the text in the editor.
> > >
> > >True, but the _file_ does not include the output. Thus it functions
> > >more as a preview, and will not be visible to you if I email you a
> > >.Rmd file. On the other hand, .ipynb files really do contain the
> > >output; if I email one to you and you open it in Jupyter you will see
> > >the output as well.
> > >
> > >--Ista
> > >
> > >>
> > >> >
> > >> > Rmarkdown allows control over the inclusion of code and results,
> > >and
> > >> > over how the results are displayed via header arguments. There is
> > >no
> > >> > such thing in Jupyter notebooks. Controlling the precise appearance
> > >of
> > >> > a document produced by Jupyter is much more difficult. Going
> > >farther,
> > >> > one can even say that Jupyter notebooks are designed primarily to
> > >be
> > >> > read as Jupyter notebooks; exporting to other formats is kind of an
> > >> > afterthought. In contrast, Rmarkdown is designed to produce the
> > >final
> > >> > readable result in another format (.html or .pdf typically).
> > >> >
> > >> > Rmarkdown is based on markdown, a human readable markup language,
> > >> > Jupyter notebooks are based on JSON, a data interchange format
> > >common
> > >> > on the web. This means that Rmarkdown files can be easily edited
> > >using
> > >> > any text editor you like. The same is not true of Jupyter
> > >notebooks.
> > >> > While you can of course edit the JSON directly, the format is
> > >designed
> > >> > to be written and read by a computer; editing it yourself is not
> > >easy.
> > >> >
> > >> > Rmarkdown is specific to R (I guess there is some basic support in
> > >> > knitr for other languages, but in my experience it never worked
> > >well)
> > >> > while Jupyter notebooks are language agnostic and "kernels" exist
> > >for
> > >> > a large number of programming languages. However, each Jupyter
> > >> > notebook can use only one kernel; you 

Re: [R] a knitr question

2014-07-29 Thread Yihui Xie
Yeah, it is just my personal opinion. Some users like it, and some do not.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Tue, Jul 29, 2014 at 5:36 PM, Peter Alspach
 wrote:
> Kia ora Erin
>
> But beware - to quote from Yihui 2013 introduction to knitr
>
> "It is easy to revert to the output with prompts (set option prompt=TRUE), 
> and you will quickly realize the inconvenience to the readers if they want to 
> copy and run the code ..."
>
> Peter Alspach
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf Of Erin Hodgess
> Sent: Wednesday, 30 July 2014 10:28 a.m.
> To: r-help@r-project.org
> Subject: Re: [R] a knitr question
>
> Sorry:  just solved it.
>
> You simply include "prompt=TRUE" in the <<>> section
>
> Thanks,
> Erin
>
>
>
> On Tue, Jul 29, 2014 at 6:22 PM, Erin Hodgess 
> wrote:
>
>> Hello!
>>
>> When constructing code using knitr, is there a way to get the ">"
>> prompt to appear, please?
>>
>> Everything else works great!!
>>
>> Thank you!
>>
>> Sincerely,
>> Erin
>>
>>
>>
>> --
>> Erin Hodgess
>> Associate Professor
>> Department of Mathematical and Statistics University of Houston -
>> Downtown
>> mailto: erinm.hodg...@gmail.com
>>
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] one more knitr question, please

2014-07-30 Thread Yihui Xie
Not sure if you mean \newpage{}/\pagebreak{} in LaTeX. If that is the
case, it is possible but easy, and I do not understand why you want to
break a code chunk onto two pages. The easiest thing to do is just to
write two code chunks.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Jul 30, 2014 at 6:58 AM, Erin Hodgess  wrote:
> Hello again:
>
> Is there a way to put a page break inside of a code chunk, please?
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] a knitr question

2014-07-30 Thread Yihui Xie
As a reader, I often want to run the code by myself _while_ I'm
reading a particular part of an article/report. I find it convenient
to be able to copy the code as I'm reading it, instead of minimizing
my current window, opening an R script, and running the part that I'm
interested in. Of course, this may not work if the code I copy is not
self-contained; your purl() approach certainly has an advantage
sometimes.

I do not see a whole lot of value in maintaining the same appearance
of the R code in the R console and a report. You can teach your
students what the prompt characters mean, and I think that is enough.
Journal of Statistical Software requires "R> " as the prompt character
(which is worse), and your students will probably be confused when
reading JSS papers if they have been seeing the default prompts all
the time. I see the point of keeping prompts (i.e. I do not completely
disagree), but I do not think it is an essential or important thing to
do. Personally I prefer reading "vanilla" code, and >/+ may confuse my
eyes occasionally, e.g.

> z > 5
> x +
+ y

(More on prompts:
http://yihui.name/en/2013/01/code-pollution-with-command-prompts/)

Re Rich: yes, I'm aware of approaches of post-processing the prompts,
but this problem would not have existed in the first place if we do
not include prompts at all. I'm not sure if it makes much sense to
create some mess and clean it afterwards.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Jul 30, 2014 at 12:50 PM, Greg Snow <538...@gmail.com> wrote:
> My preference when teaching is to have the code and results look the
> same as it appears in the R console window, so with the prompts and
> without the output commented.  But then I also `purl` my knitr file to
> create a script file to give to the students that they can copy and
> paste from easily.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] a knitr question

2014-07-30 Thread Yihui Xie
No. That is not my suggestion. Joshua Wiley correctly explained what I
was suggesting. Prompts are useful in the R console, but not
necessarily in a report.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Jul 30, 2014 at 6:47 PM, Duncan Murdoch
 wrote:
> So your suggestion is that the R console should not prompt for input?
> Do you know of *any* interactive system which doesn't prompt for input?
>  How would users be able to tell the difference between R waiting for
> input, and R busy on the last calculation?
>
> Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] a knitr question

2014-07-31 Thread Yihui Xie
Great.

I also said "I see the point of keeping prompts", and that is why the
chunk option prompt=TRUE is provided in knitr. I may not agree with
your preference, but that does not mean I should stop you completely
from having your own preference.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Thu, Jul 31, 2014 at 6:34 AM, Duncan Murdoch
 wrote:
> On 30/07/2014, 11:12 PM, Yihui Xie wrote:
>> No. That is not my suggestion. Joshua Wiley correctly explained what I
>> was suggesting. Prompts are useful in the R console, but not
>> necessarily in a report.
>
> Okay, then we agree.  For Erin's purpose (teaching), it is helpful to
> beginners if the document looks the same as what they see in the
> console.  More sophisticated users don't need the prompts.
>
> Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] knitr and stopifnot replacement.

2014-08-22 Thread Yihui Xie
Yep, that is exactly the answer.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Fri, Aug 22, 2014 at 6:35 AM, Bart Kastermans  wrote:
> On 22 Aug 2014, at 12:39, Duncan Murdoch  wrote:
>
>> On 22/08/2014, 6:02 AM, Bart Kastermans wrote:
>>> I have a daily generated report in which I put a check using stopifnot.  
>>> Unfortunately
>>> I didn’t check the effect very well, turns out that if the condition 
>>> checked fails
>>> this is not shown in the knitr output (I only get an error much later due 
>>> to a missing
>>> object).
>>>
>>> So my question is, what is the correct way to use assertions in a 
>>> .Rnw
>>> file.  I want to perform a check, and if it fails everything should stop 
>>> with a message
>>> I can generate.
>>>
>>
>> One of the differences between knitr and Sweave is that knitr handles
>> errors, and Sweave doesn't.  I expect there's some knitr option to tell
>> it to quit in case of error (a hook?), but you'll have to check the
>> documentation to find it.
>
> Thanks; that helped me to find the exact right option:
>
> <>=
> # check all files exist before continuing
> stopifnot(all(sapply(files, file.exists)))
> @

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Apply rmarkdown::render() outside the RStudio don't find pandoc

2014-08-28 Thread Yihui Xie
Please check out the instructions here:
https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md

Creating an alias might work, although I have not really tried. What I
have been doing is to uninstall the old version of Pandoc in my
system, and create symlinks following the instructions above. You said

> I try overcome this by creating an alias
> *pandoc='/usr/lib/rstudio/bin/pandoc/pandoc'*, bus this doesn't work.

but you did not describe what "this doesn't work" really means
(whenever you report something that does not work, please attach the
error message so we do not have to imagine what could be wrong).
Anyway, at least you have to let your system know where is
pandoc-citeproc (per instructions above again), which may or may not
be the problem given the missing error message.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Thu, Aug 28, 2014 at 2:06 PM, walmes .  wrote:
> Hello,
>
> I want to render a Rmd file using rmarkdown::render() function but I'm used
> to edit files with Emacs and I open a linux terminal session to compile
> this file with knitr::knit2html()
>
> ## On the linux terminal.
> $ echo "require(knitr); knit2html('teste01.Rmd')" | R --vanilla
>
> I want to use rmarkdown::render instead. When I tried this, with a R
> session open in the linux terminal, I get the message
>
> ## In a R session inside the linux terminal
>> rmarkdown::render("teste01.Rmd")
> Error: pandoc version 1.12.3 or higher is required and was not found.
>
> So I open the the teste01.Rmd file in RStudio and clicked on the "knit
> HTML" button and it works. The output is bellow.
>
> ## Output in the RStudio after clicking on the "Knit HTML" button.
>
> processing file: teste01.Rmd
>   |.|  20%
>   ordinary text without R code
>
>   |..   |  40%
> label: unnamed-chunk-1
>   |...  |  60%
>   ordinary text without R code
>
>   | |  80%
> label: unnamed-chunk-2 (with options)
> List of 1
>  $ echo: logi FALSE
>
>   |.| 100%
>   ordinary text without R code
>
>
> output file: teste01.knit.md
>
> */usr/lib/rstudio/bin/pandoc/pandoc* teste01.utf8.md --to html --from
> markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
> --output teste01.html --smart --email-obfuscation none --standalone
> --section-divs --table-of-contents --toc-depth 3 --template
> /home/walmes/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/default.html
> --css /home/walmes/Dropbox/ridiculas/markdown/ridiculas.css --variable
> theme:cerulean --include-in-header
> /tmp/RtmpkgSjDp/rmarkdown-str4aee5c225085.html --mathjax --variable
> mathjax-url:
> https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
> --no-highlight --variable highlightjs=teste01_files/highlight --variable
> highlightjs-theme=textmate
>
> Output created: teste01.html
>
> Its possible to see that RStudio call the pandoc that is at
> */usr/lib/rstudio/bin/pandoc/* and not the old version of pandoc in my
> system.
>
> I try overcome this by creating an alias
> *pandoc='/usr/lib/rstudio/bin/pandoc/pandoc'*, bus this doesn't work.
> Someone has any idea to solve this? I want to use rmarkdown::render()
> outside the RStudio.
>
> Thanks.
> Walmes.
>
> ==
> Walmes Marques Zeviani
> LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
> Departamento de Estatística - Universidade Federal do Paraná
> fone: (+55) 41 3361 3573
> skype: walmeszeviani
> homepage: http://www.leg.ufpr.br/~walmes
> linux user number: 531218
> ==

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] shiny datatables column filtering plugin

2014-09-02 Thread Yihui Xie
I just tested it and this plugin does not seem to work with the new
.DataTable() API in DataTables 1.10.x, so I guess it is unlikely to
make it work in (the current development version of) shiny. It is not
in the official list of plugins, either:
http://www.datatables.net/extensions/index

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Tue, Sep 2, 2014 at 11:59 AM, Charles Determan Jr  wrote:
> Greetings,
>
> I am currently exploring some capabilities of the 'Shiny' package.  I am
> currently working with the most recent version of 'shiny' from the rstudio
> github repository (version - 0.10.1.9006) in order to use the most up to
> date datatables plugin.  Using the ggplot2 diamonds dataset, I can easily
> set columns as unsearchable (commented out below) and I could also subset
> out all the 'Ideal' diamonds for example, however I cannot filter out
> multiple conditions such as 'Ideal' and 'Fair' diamonds together.  From my
> searching, this multiple filtering can be done with checkboxes from the
> column using the jquery column filtering plugin (
> http://jquery-datatables-column-filter.googlecode.com/svn/trunk/checkbox.html).
> Despite this, I cannot get this plugin to work with my shiny app.  Any
> insight would be appreciated.
>
> library(shiny)
> library(ggplot2)
> runApp(
>   list(ui = basicPage(
> h1('Diamonds DataTable with TableTools'),
>
> # added column filter plugin
> 
> singleton(tags$head(tags$script(src='https://code.google.com/p/jquery-datatables-column-filter/source/browse/trunk/media/js/jquery.dataTables.columnFilter.js',
> type='text/javascript'))),
> dataTableOutput("mytable")
>   )
>   ,server = function(input, output) {
> output$mytable = renderDataTable({
>   diamonds[,1:6]
> }, options = list(
>   pageLength = 10,#   columnDefs = I('[{"targets": [0,1],
> "searchable": false}]')
>   columnFilter = I('[{
> columnDefs: ["targets": [0,1], type: "checkbox"]
> }]')
>
> )
> )
>   }
>   ))
>
>
>
> Charles

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] shiny datatables column filtering plugin

2014-09-03 Thread Yihui Xie
The built-in version of DataTables in shiny has already supported
numeric ranges. For a numeric column x in data, if you type a,b in the
search box, the data will be filtered using a <= x <= b. The check
boxes are not supported, but you can use regular expressions (more
flexible) to achieve the same thing, e.g. (this example requires the
development version of shiny:
https://groups.google.com/forum/#!topic/shiny-discuss/-0u-wTnq_lA)

library(shiny)
runApp(list(
  ui = fluidPage(
dataTableOutput("mytable")
  ),
  server = function(input, output) {
output$mytable = renderDataTable(
  iris[sample(nrow(iris)), ],
  options = list(search = list(regex = TRUE))
)
  }
))


Then you can search for ^setosa|versicolor$, which means both setosa
and versicolor in the iris data. Or 4,5 in the search box of
Sepal.Length to filter this column. Depending on what you want, this
may or may not be enough.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Sep 3, 2014 at 7:12 AM, Charles Determan Jr  wrote:
> Thank you for checking Yihui, on the off chance are you familiar with any
> other methods to filter on multiple conditions?
>
>
> On Tue, Sep 2, 2014 at 11:07 PM, Yihui Xie  wrote:
>>
>> I just tested it and this plugin does not seem to work with the new
>> .DataTable() API in DataTables 1.10.x, so I guess it is unlikely to
>> make it work in (the current development version of) shiny. It is not
>> in the official list of plugins, either:
>> http://www.datatables.net/extensions/index
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Web: http://yihui.name
>>
>>
>> On Tue, Sep 2, 2014 at 11:59 AM, Charles Determan Jr 
>> wrote:
>> > Greetings,
>> >
>> > I am currently exploring some capabilities of the 'Shiny' package.  I am
>> > currently working with the most recent version of 'shiny' from the
>> > rstudio
>> > github repository (version - 0.10.1.9006) in order to use the most up to
>> > date datatables plugin.  Using the ggplot2 diamonds dataset, I can
>> > easily
>> > set columns as unsearchable (commented out below) and I could also
>> > subset
>> > out all the 'Ideal' diamonds for example, however I cannot filter out
>> > multiple conditions such as 'Ideal' and 'Fair' diamonds together.  From
>> > my
>> > searching, this multiple filtering can be done with checkboxes from the
>> > column using the jquery column filtering plugin (
>> >
>> > http://jquery-datatables-column-filter.googlecode.com/svn/trunk/checkbox.html).
>> > Despite this, I cannot get this plugin to work with my shiny app.  Any
>> > insight would be appreciated.
>> >
>> > library(shiny)
>> > library(ggplot2)
>> > runApp(
>> >   list(ui = basicPage(
>> > h1('Diamonds DataTable with TableTools'),
>> >
>> > # added column filter plugin
>> >
>> > singleton(tags$head(tags$script(src='https://code.google.com/p/jquery-datatables-column-filter/source/browse/trunk/media/js/jquery.dataTables.columnFilter.js',
>> > type='text/javascript'))),
>> > dataTableOutput("mytable")
>> >   )
>> >   ,server = function(input, output) {
>> > output$mytable = renderDataTable({
>> >   diamonds[,1:6]
>> > }, options = list(
>> >   pageLength = 10,#   columnDefs = I('[{"targets": [0,1],
>> > "searchable": false}]')
>> >   columnFilter = I('[{
>> > columnDefs: ["targets": [0,1], type: "checkbox"]
>> > }]')
>> >
>> > )
>> > )
>> >   }
>> >   ))
>> >
>> >
>> >
>> > Charles
>
>
>
> Charles

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] shiny datatables column filtering plugin

2014-09-03 Thread Yihui Xie
It looks like a problem of DataTables -- I cannot find a way to
specify the search.regex option for individual columns. You may ask
this question on the DataTables forum. Basically I was expecting this
to work:

.DataTable({
  "search": { "regex": true },
  "columnDefs": [{ "search": { "regex": true }, "targets": [0, 1, 2, 3, 4] }]
})

The global search box works, though.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Sep 3, 2014 at 2:09 PM, Charles Determan Jr  wrote:
> Thank you Yihui, this would certainly work for me however I have having
> trouble getting the regex to work appropriately.  I am using the
> developmental version of shiny and have copied your code.  I launch the app
> and the filtering of numbers works fine (i.e. 4,5) but the search for setosa
> and versicolor gives me a blank datatable.  Is there some dependency that I
> am missing that would prevent this regex to work with shiny?
>
>
> On Wed, Sep 3, 2014 at 11:27 AM, Yihui Xie  wrote:
>>
>> The built-in version of DataTables in shiny has already supported
>> numeric ranges. For a numeric column x in data, if you type a,b in the
>> search box, the data will be filtered using a <= x <= b. The check
>> boxes are not supported, but you can use regular expressions (more
>> flexible) to achieve the same thing, e.g. (this example requires the
>> development version of shiny:
>> https://groups.google.com/forum/#!topic/shiny-discuss/-0u-wTnq_lA)
>>
>> library(shiny)
>> runApp(list(
>>   ui = fluidPage(
>> dataTableOutput("mytable")
>>   ),
>>   server = function(input, output) {
>> output$mytable = renderDataTable(
>>   iris[sample(nrow(iris)), ],
>>   options = list(search = list(regex = TRUE))
>> )
>>   }
>> ))
>>
>>
>> Then you can search for ^setosa|versicolor$, which means both setosa
>> and versicolor in the iris data. Or 4,5 in the search box of
>> Sepal.Length to filter this column. Depending on what you want, this
>> may or may not be enough.
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Web: http://yihui.name
>>
>>
>> On Wed, Sep 3, 2014 at 7:12 AM, Charles Determan Jr 
>> wrote:
>> > Thank you for checking Yihui, on the off chance are you familiar with
>> > any
>> > other methods to filter on multiple conditions?
>> >
>> >
>> > On Tue, Sep 2, 2014 at 11:07 PM, Yihui Xie  wrote:
>> >>
>> >> I just tested it and this plugin does not seem to work with the new
>> >> .DataTable() API in DataTables 1.10.x, so I guess it is unlikely to
>> >> make it work in (the current development version of) shiny. It is not
>> >> in the official list of plugins, either:
>> >> http://www.datatables.net/extensions/index
>> >>
>> >> Regards,
>> >> Yihui
>> >> --
>> >> Yihui Xie 
>> >> Web: http://yihui.name
>> >>
>> >>
>> >> On Tue, Sep 2, 2014 at 11:59 AM, Charles Determan Jr 
>> >> wrote:
>> >> > Greetings,
>> >> >
>> >> > I am currently exploring some capabilities of the 'Shiny' package.  I
>> >> > am
>> >> > currently working with the most recent version of 'shiny' from the
>> >> > rstudio
>> >> > github repository (version - 0.10.1.9006) in order to use the most up
>> >> > to
>> >> > date datatables plugin.  Using the ggplot2 diamonds dataset, I can
>> >> > easily
>> >> > set columns as unsearchable (commented out below) and I could also
>> >> > subset
>> >> > out all the 'Ideal' diamonds for example, however I cannot filter out
>> >> > multiple conditions such as 'Ideal' and 'Fair' diamonds together.
>> >> > From
>> >> > my
>> >> > searching, this multiple filtering can be done with checkboxes from
>> >> > the
>> >> > column using the jquery column filtering plugin (
>> >> >
>> >> >
>> >> > http://jquery-datatables-column-filter.googlecode.com/svn/trunk/checkbox.html).
>> >> > Despite this, I cannot get this plugin to work with my shiny app.
>> >> > Any
>> >> > insight would be appreciated.
>> >> >
>> >> > library(shiny)
>> >> > library(ggplot2)
>> >> > runApp(
>> >>

Re: [R] [Sweave] doesn't accept unicode?

2014-10-21 Thread Yihui Xie
That blog post is not entirely correct about UTF-8: if you use
pdflatex, you have to declare the font encoding
\usepackage[T1]{fontenc} when you save the document with UTF-8, e.g.
the following minimal example should work with pdflatex + knitr in
RStudio with UTF-8:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
<<>>=
degree <- "°"
print(degree)
@
\end{document}

For XeTeX, you will have to use different packages, fontspec and
xunicode. Here is a minimal example for XeTeX:

\documentclass{article}
\usepackage{fontspec}
\usepackage{xunicode}
\begin{document}
<<>>=
degree <- "°"
print(degree)
@
\end{document}

Similar things apply to ü. You need to specify the argument `encoding
= 'UTF-8'` when calling Sweave() or knitr::knit().

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Tue, Oct 21, 2014 at 10:58 PM, Marc Girondot  wrote:
> Look at here for an example using an encoding in knitr:
> http://max2.ese.u-psud.fr/epc/conservation/Girondot/Publications/Blog_r/Entrees/2014/9/4_symbol_in_knitr.html
>
> Sincerely
>
> Marc
>
> Le 22/10/2014 02:45, moon...@posteo.org a écrit :
>
>> Of course I manage and write my tex-files in unicode (utf-8) (running
>> XeTeX). That is why my R-output need to be in unicode, too.
>>
>> But Sweave doesn't accept unicode files.
>>
>> [R]
>>>
>>> Sweave("analy.Snw")
>>
>> Fehler: ‘analy.Snw’ is not ASCII and does not declare an encoding
>> [/R]
>>
>> [analy.Snw]
>> <<>>=
>> x <- ü
>>
>> table(x)
>> @
>> [/analy.Snw]
>>
>> How should I "declare an encoding". I can not find an option for the <<>>.
>>
>> I don't have to declare any of my tex-files explicite because XeTeX use
>> the files like they come. It knows for itself the encoding.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Markdown and scan()

2014-10-25 Thread Yihui Xie
RStudio uses a non-interactive R session to compile R Markdown
documents, which means the functions that involve human interaction
will not work. The only way to make these functions work is to use an
interactive R session, which basically means you should not click the
button in RStudio to compile the documents, but should type
rmarkdown::render() in the R console instead. You cannot put the
numbers under scan() and expect they will be read by scan() as if they
were typed by a human, even though they look similar.

If the function in your case only allows file input for scan(), I
guess the only way is to make a connection, such as textConnection()
as you mentioned.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Sat, Oct 25, 2014 at 10:58 AM, John Fox  wrote:
> Dear Peter,
>
> Thanks for the suggestion -- it's a bit better for the example I provided 
> than my approach of using textConnection() of putting the lines in a file.
>
> I'd still be interested in whether I've missed something like a text-chunk 
> option that would allow the R Markdown document to behave like a script 
> executed at the console. For example, your approach doesn't work for the 
> application where I encountered the problem, which is in a function that 
> calls scan() and that passes the file argument to it, but doesn't use the 
> text argument.
>
> Best,
>  John
>
> On Sat, 25 Oct 2014 17:11:14 +0200
>  peter dalgaard  wrote:
>>
>> > On 25 Oct 2014, at 16:43 , John Fox  wrote:
>> >
>> > Dear JJ and list members,
>> >
>> > I wonder whether it's possible to get scan() to read in-line data in an R 
>> > Markdown document. The following code, for example, works (of course) when 
>> > entered in the R console but fails in an R block in an R Markdown document 
>> > (using an up-to-date version of RStudio):
>> >
>> > ```{r}
>> > x <- scan()
>> > 1 2 3
>> > 4 5 6
>> >
>> > x
>> > 
>> >
>> > I'm aware of a couple of work-arounds, such as putting the data in a file 
>> > or a character string (as below), but am interested in whether it's 
>> > possible to get this to work directly.
>> >
>> > ```{r}
>> > text <- "
>> > 1 2 3
>> > 4 5 6
>> > "
>> > (x <- scan(file=textConnection(text)))
>> > 
>> >
>> > Any help would be appreciated.
>>
>> This generally isn't easy. You can't source() a file like that either, it 
>> only works on std.input, and even there it is tricky it you have tabs in the 
>> (pasted) data. Notice that
>>
>> scan(text="
>> 1 2 3
>> 4 5 6
>> ")
>>
>> was designed for the purpose of reading inline data.
>>
>>
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error: pandoc version 1.12.3 or higher is required and was not found

2015-09-23 Thread Yihui Xie
I guess the confusion here is the relationship between knitr::pandoc()
and rmarkdown::render(). The error message you saw was from
rmarkdown::render(), which requires Pandoc 1.12.3. The easiest way to
go to use rmarkdown (I mean the R package rmarkdown) is to use
RStudio, and you don't even need to install Pandoc separately. There
are a number of possible reasons for the failure you saw: 1) You
didn't install Pandoc; 2) You installed but didn't put it on PATH; 3)
You installed a lower version of Pandoc. I don't mean you should not
figure out the exact reason, but it just saves so much time not having
to take care of such technical details by yourself.

knitr::pandoc() is almost a completely different story. If you are
familiar with Pandoc command-line arguments, please feel free to use
it. If you don't want to waste time on remembering those arguments, go
for rmarkdown::render() instead, which has a much better interface to
Pandoc than knitr::pandoc(). As the author of knitr::pandoc(), I can
tell you this function was about two afternoon's work, and rmarkdown
has been under active development for almost two years now. Hopefully
that makes it clear enough for you to choose between knitr::pandoc()
and rmarkdown::render() :-)

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Sep 23, 2015 at 6:13 AM, Ryszard Czermiński
 wrote:
> I am trying to use R Markdown, but call to render() gives me an error:
> Error: pandoc version 1.12.3 or higher is required and was not found.
>
> As I understand [http://yihui.name/knitr/demo/pandoc/] pandoc is a function
> defined in knitr, which I have installed and it has pandoc() function
> defined.
>
> Looks like some version incompatibility issue, but I do not really know how
> to resolve it.
> Do I need to go to older R version to use it?
>
> I would appreciate your help.
>
> Best regards,
> Ryszard
>
>> sessionInfo()
> R version 3.2.2 (2015-08-14)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X 10.10.3 (Yosemite)
> other attached packages: knitr_1.11
> [...]
>
> Ryszard Czerminski
> 508-358-6328
> rysz...@czerminski.net
> LinkedIn.com/in/Ryszard.Czerminski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] r-markdown - keeping figures

2015-10-21 Thread Yihui Xie
Yes, setting the fig.path option will prevent rmarkdown from deleting
the figure files, and the more natural way to preserve these
intermediate files is to set the rmarkdown option keep_tex or keep_md
(depending on your output format) to yes, e.g.

---
output:
  pdf_document:
keep_tex: yes
  html_document:
keep_md: yes
---

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Wed, Oct 21, 2015 at 7:21 AM, Jeff Newmiller
 wrote:
> I think the default now is to not save them unless you set the fig.path chunk 
> option.
>
> http://kbroman.org/knitr_knutshell/pages/Rmarkdown.html
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> On October 21, 2015 1:47:33 PM GMT+02:00, Bob O'Hara  
> wrote:
>>The figures should be saved somewhere. e.g. if you have x.Rmd, you
>>should have a X_files/ folder with subfolders for the figures (e.g.
>>X-html or X-latex). At least that's what I have.
>>
>>Bob
>>
>>On 20 October 2015 at 18:18, Witold E Wolski 
>>wrote:
>>> I am running r-markdown from r-studio and can't work out how to keep
>>> the figures.
>>> I mean I have a few figures in the document and would like to have
>>> them as separate pdf's too as I have been used to have them when
>>using
>>> Sweave.
>>>
>>>
>>>
>>> best regards
>>> Witold
>>>
>>>
>>> --
>>> Witold Eryk Wolski
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] conditionally disable evaluation of chunks in Rmarkdown...

2015-11-10 Thread Yihui Xie
The short answer is you cannot. Inline R code is always evaluated.
When it is not evaluated, I doubt if your output still makes sense,
e.g. "The value of x is `r x`." becomes "The value of x is ." That
sounds odd to me.

If you want to disable the evaluate of inline code anyway, you may use
a custom function to do it. e.g.

cond_eval = function(x) {
  if (isTRUE(knitr::opts_chunk$get('eval'))) x
}

Then `r cond_eval(x)` instead of `r x`.

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Tue, Nov 10, 2015 at 4:40 AM, Witold E Wolski  wrote:
> I do have an Rmd where I would like to conditionally evaluate the second part.
>
> So far I am working with :
>
> ```{r}
> if(length(specLibrary@ionlibrary) ==0){
>   library(knitr)
>   opts_chunk$set(eval=FALSE, message=FALSE, echo=FALSE)
> }
> ```
>
> Which disables the evaluation of subsequent chunks.
>
> However my RMD file contains also these kind of snippets : `r `
>
> How do I disable them?
>
> regards
>
>
>
> --
> Witold Eryk Wolski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] installing tikzDevices for R 3.2.3

2016-01-15 Thread Yihui Xie
Please do not use http://r-forge.r-project.org/ to install tikzDevice.
We no longer update tikzDevice on R-Forge. It may be a problem of your
CRAN mirror. When in doubt, try the RStudio mirror (the chance that
Amazon CloudFront is down should be much smaller than a single metal
server somewhere):

install.packages("tikzDevice", repos="https://cran.rstudio.com";)
# make sure your version of R supports https

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Fri, Jan 15, 2016 at 9:37 PM, Ranjan Maitra
 wrote:
> On Fri, 15 Jan 2016 21:25:06 -0600 Ranjan Maitra 
>  wrote:
>
>> Hi,
>>
>> I wanted to install tikzDevices on a installation of R (3.2.3) on a new 
>> machine. However, I am getting:
>>
>> > install.packages('tikzDevices')
>>
>> Warning message:
>> package ‘tikzDevices’ is not available (for R version 3.2.3)
>>
>> Is there any way out for me other than wait for the tikzDevices to be 
>> updated in the repos? I am on Fedora 23 with everything up to date.
>>
>> Many thanks in advance for any suggestions and best wishes,
>> Ranjan
>
>
> Sorry to answer my own question, but I found a way out (only specific to 
> tikzDevices):
>
> install.packages("tikzDevice", repos="http://R-Forge.R-project.org";)
>
> It would be nice to have a general approach, especially when R updated does 
> not mostly mean that packages installed under and earlier version of R stop 
> working.
>
> Best wiehes,
> Ranjan
>
> 
> Can't remember your password? Do you need a strong and secure password?
> Use Password manager! It stores your passwords & protects your account.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] tikzDevice and Sweave

2016-01-18 Thread Yihui Xie
Yeah, the philosophy of knitr from the very beginning is that if you
want to draw a plot, simply draw it, and knitr will take care of the
rest of work (http://i.imgur.com/jrwbX.jpg). You rarely need to think
about graphical devices or LaTeX or a specific output format. With
knitr, the example can be reduced to the absolutely minimal:

\documentclass{article}
\begin{document}
<>=
plot(sin, -pi, 2*pi, main = "A stand alone TikZ plot", xlab = "x",
ylab = "sin(x)")
@
\end{document}


Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Mon, Jan 18, 2016 at 6:30 AM, Duncan Murdoch
 wrote:
> On 18/01/2016 6:12 AM, Naresh Gurbuxani wrote:
>>
>> Duncan,
>>
>> Many thanks for looking at my code and for your suggestion.
>>
>> Your solution works.  But my problem is different.  This code gives me a
>> tex file with a lot of tikz code.  If there are several graphs in the
>> document, then tex file become very large.  I would like the code to result
>> in a pdf file for each graph.  When this pdf file is included in the tex
>> file, the tex file is more readable.
>
>
> You probably don't want to do that -- tikz outputs LaTeX code, so you'd need
> to run pdflatex once in every figure in your document.  And you probably
> shouldn't care:  when using Sweave, the .tex file is not really of interest.
> Concentrate on the .Rnw file as the source file.
> However, sometimes you need to deal with other people...
>
> You can easily redirect tikz output to a file, and \input{} that file. Just
> change the figure chunk to
>
> <>=
> library(tikzDevice)
> # added height and width
> tikz(file = "tikzFig.tex", width = 4, height = 3)
> plot(sin, -pi, 2*pi, main = "A stand alone TikZ plot", xlab = "x", ylab =
> "sin(x)")
> dummy <- dev.off()
> cat("\\input{tikzFig.tex}")
> @
>
> As mentioned, this is a bit simpler in knitr.
>
> Duncan Murdoch
>
>
>> Naresh
>>
>> 
>>>
>>> From: dulca...@bigpond.com
>>> To: r-help@r-project.org
>>> Date: Mon, 18 Jan 2016 14:17:42 +1000
>>> Subject: Re: [R] tikzDevice and Sweave
>>>
>>> Hi
>>>
>>> I use Sweave and some tikz in latex but not in Sweave
>>>
>>> Your problem is that you left out Sweave in the preamble
>>> It must be in the preamble of any Sweave document
>>>
>>> I added sizing so that it is not off the page.
>>> I do not know if Sweave options will cover this or you have to set it.
>>> eg
>>> \setkeys{Gin}{width=1.0\textwidth}
>>>
>>> \documentclass{article}
>>> \usepackage{tikz}
>>> \usepackage{Sweave}
>>>
>>> \begin{document}
>>>
>>> Figure~\ref{tikzExampleFig} is an example of \texttt{tikzDevice} package.
>>>
>>> \begin{figure}
>>> \begin{center}
>>>
>>> <>=
>>> # % <>=
>>>
>>> # %<>=
>>> # setwd("/Users/nareshgurbuxani/Documents/tex/tikz")
>>> library(tikzDevice)
>>>
>>> # added height and width
>>> tikz(console = TRUE, width = 4, height = 3)
>>> plot(sin, -pi, 2*pi, main = "A stand alone TikZ plot", xlab = "x", ylab =
>>> "sin(x)")
>>> dummy <- dev.off()
>>> @
>>>
>>> \caption{Example of tikz graph}
>>> \label{tikzExampleFig}
>>> \end{center}
>>> \end{figure}
>>>
>>> \end{document}
>>>
>>> If this is an example for a larger document then have a look at the latex
>>> hyperref package
>>>
>>> Regards
>>>
>>> Duncan
>>>
>>> Duncan Mackay
>>> Department of Agronomy and Soil Science
>>> University of New England
>>> Armidale NSW 2351
>>> Email: home: mac...@northnet.com.au
>>>
>>> -Original Message-
>>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Naresh
>>> Gurbuxani
>>> Sent: Monday, 18 January 2016 06:54
>>> To: R-help@r-project.org
>>> Subject: Re: [R] tikzDevice and Sweave
>>>
>>> Resending as a useable example
>>>
>>> \documentclass{article}
>>> \usepackage{tikz}
>>>
>>> \begin{document}
>>>
>>> Figure~\ref{tikzExampleFig} is an example of \texttt{tikzDevice} package.
>>>
>>> \begin{figure}
>>> \begin{center}
>>>
>>> <>=
>>> # % <>=
>>

Re: [R] roxygen2 v6.0.0

2017-02-06 Thread Yihui Xie
If your package source is version controlled (meaning you are free to
regret any time), I'd recommend you to delete the three files
NAMESPACE, chr.Rd, and essai-package.Rd. Then try to roxygenize again.
Basically the warnings you saw indicates that roxygen2 failed to find
the line

% Generated by roxygen2: do not edit by hand

in your NAMESPACE and .Rd files, so it thinks these files were
probably not previously generated by roxygen2. I think the cause is
package.skeleton(), which generated the Rd files. Seriously, friends
don't let friends use package.skeleton()... (it is 2017 now)

Regards,
Yihui
--
Yihui Xie 
Web: http://yihui.name


On Mon, Feb 6, 2017 at 9:46 AM, Marc Girondot via R-help
 wrote:
> Hi,
>
> I used roxygen2 v5.0.1 to document my package, and all was ok. I have just
> updated to roxygen2 v6.0.0 and my script is broken and I can't find why.
>
> I have done a simple version of a package folder as a test with 3 files:
> chr.R, essai-package.R and DESCRIPTION.
>
> Previously, I did:
>
> package.skeleton("essai",code_files=c('chr.R',"essai-package.R"))
> roxygenize("essai")
> system(paste0("R CMD build '", getwd(), "/essai'"))
> install.packages(file.path(getwd(), "essai_1.0.tar.gz"), repos = NULL,
> type="source")
>
> And it worked well.
>
> Now I get an error at the second line: roxygenize("essai")
>
>> roxygenize("essai")
> First time using roxygen2. Upgrading automatically...
> Updating roxygen version in
> /Users/marcgirondot/Documents/Espace_de_travail_R/Package_Essai/essai/DESCRIPTION
> Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and
> will not be overwritten.
> Warning: The existing 'chr.Rd' file was not generated by roxygen2, and will
> not be overwritten.
> Warning: The existing 'essai-package.Rd' file was not generated by roxygen2,
> and will not be overwritten.
>
> And of course it fails after.
>
> Are you aware of this situation ? And do you have a solution ?
>
> Thanks a lot
>
> Marc
>
>
> A file DESCRIPTION:
>
> Package: essai
> Type: Package
> Title: Package Used For Try
> Version: 1.0
> Date: 2017-02-06
> Author: Marc Girondot 
> Maintainer: Marc Girondot 
> Description: Trying package.
> Depends: R (>= 2.14.2)
> License: GPL-2
> LazyData: yes
> LazyLoad: yes
> Encoding: UTF-8
> RoxygenNote: 6.0.0
>
> A file essai-package.R (essai=try in French):
>
> #' Trying package
> #'
> #' \tabular{ll}{
> #'  Package: \tab essai\cr
> #'  Type: \tab Package\cr
> #'  Version: \tab 1.0 - build 1\cr
> #'  Date: \tab 2017-02-06\cr
> #'  License: \tab GPL (>= 2)\cr
> #'  LazyLoad: \tab yes\cr
> #'  }
> #' @title The package essai
> #' @author Marc Girondot \email{marc.girondot@@u-psud.fr}
> #' @docType package
> #' @name essai-package
>
> NULL
>
> A file chr.R:
>
> #' chr returns the characters defined by the codes
> #' @title Return the characters defined by the codes
> #' @author Based on this blog:
> http://datadebrief.blogspot.com/2011/03/ascii-code-table-in-r.html
> #' @return A string with characters defined by the codes
> #' @param n The vector with codes
> #' @description Return a string with characters defined by the codes.
> J'essaye avec un code utf-8: ê.
> #' @examples
> #' chr(65:75)
> #' chr(unlist(tapply(144:175, 144:175, function(x) {c(208, x)})))
> #' @encoding UTF-8
> #' @export
>
>
> chr <- function(n) {
> rawToChar(as.raw(n))
> }
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-15 Thread Yihui Xie
I'm the author of the animation package, and I do plan to switch to
the magick package in the future instead of using ImageMagick as a
system dependency.

Regards,
Yihui
--
https://yihui.name


On Wed, Mar 15, 2017 at 12:32 AM, Bert Gunter  wrote:
> A google search on "ImageMagick Package R" brought this up, which
> seems relevant:
>
> https://cran.r-project.org/web/packages/magick/vignettes/intro.html
>
> -- Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Mar 14, 2017 at 10:21 PM, C W  wrote:
>> Dear list,
>>
>> I am trying to use saveGIF() from library animation.
>> https://cran.r-project.org/web/packages/animation/animation.pdf
>>
>> saveGIF() has dependency on package ImageMagick.
>>
>> I got the following,
>>> install.packages("ImageMagick")
>> Warning in install.packages :
>>   package ‘ImageMagick’ is not available (for R version 3.3.2)
>>
>> Does that mean I can't use saveGIF() anymore? It seems that this is the
>> only package capable in R.
>>
>> Thank you in advance!
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] "panel.first" passed to plot() in "..."

2009-09-02 Thread Yihui Xie
Hi everyone,

The code below will only draw grid lines in the *first* plot because
'panel.first' has already been evaluated (and hence it's NULL) after
the first plot is drawn:

devAskNewPage(TRUE)
f = function(...) {
for (i in 1:5) plot(rnorm(10), ...)
}
f(panel.first = grid())

For i in 2:5, panel.first = NULL will not produce the grid. I didn't
understand it until I saw Prof Ripley's reply in the trashcan of the
bug list 9 years ago
(http://bugs.r-project.org/cgi-bin/R/trashcan?id=458;expression=panel.first;user=guest).
I wonder in my example, how can I get the grid drawn in each plot with
"panel.first" in "..."? Thanks a lot!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Create directory and copy files in R

2009-09-22 Thread Yihui Xie
You assigned values to 'fn' and 'dpath' outside the function body and
use these names as the arguments of your function, so actually 'cyfun'
does not know what 'fn' and 'path' are. The solution is to put them in
the arguments as default values:

cyfun <- function(fn = "C:/Documents and
Settings/lma/Desktop/FamilyAEntrepreneurs/Entrepreneurs/Juha/book_log-20041210T095019.txt",
dpath = "C:/Documents and Settings/lma/My Documents/Juha/book") {
dir <- dirname(fn)
fn <- basename(fn)
deskdir <- dir.create(dpath)
file.copy(fn, deskfile)
}

But even if you have fixed this problem, I don't think you can
successfully copy all the files under 'dir', as you've only copied a
single file 'fn' to 'deskdir' (and as 'fn' is only a base name,
probably this function will fail again if R does not know where is
'fn'!). To get the file list under 'dir', you may need
list.files(dirname(fn), all.files = TRUE); then copy this file list to
'deskdir'.

BTW, it's not a good programming habit to assign values to the names
of internal R functions/objects, as you did in 'dir <- dirname(fn)'
because 'dir' is already an R function.

> library(fortunes)
> fortune('dog')

Firstly, don't call your matrix 'matrix'. Would you call your dog
'dog'? Anyway, it might clash
with the function 'matrix'.
   -- Barry Rowlingson
  R-help (October 2004)

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Mon, Sep 21, 2009 at 9:24 AM, Don MacQueen  wrote:
> In your file.copy() command you have "deskfile", but "deskfile" does not
> appear anywhere else. Perhaps you meant deskdir?
>
> After the error occurs, type
>
>  traceback()
>
> and try to discern exactly where things went wrong.
>
> -Don
>
> At 5:05 PM +0300 9/21/09, Tammy Ma wrote:
>>
>> Content-Type: text/plain
>> Content-Disposition: inline
>> Content-length: 792
>>
>>
>>
>> HI, All R users,
>>
>> My problem is:
>>
>>>  fn
>>
>> [1] "C:/Documents and
>> Settings/lma/Desktop/FamilyAEntrepreneurs/Entrepreneurs/Juha/book_log-20041210T095019.txt"
>>>
>>>  dpath
>>
>> [1] "C:/Documents and Settings/lma/My Documents/Juha/book"
>>
>>
>> I want to make  a function "cyfun" to copy all files in "dir" to "deskdir"
>> but I always got the following problem:
>>
>> Error in file.exists(to) : invalid 'file' argument.
>> Whats the problem??
>>
>>
>>
>>
>> cyfun<-function(fn,dpath){
>> dir<-dirname(fn)
>> fn<-basename(fn)
>>
>> deskdir<-dir.create(dpath)
>> file.copy(fn, deskfile)
>>
>> }
>>
>> Thanks!
>>
>> Tammy
>>
>> _
>> Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
>>
>> http://*www.*microsoft.com/windows/windowslive/products/photos.aspx
>>        [[alternative HTML version deleted]]
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://*stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://*www.*R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
> --
> Don MacQueen
> Environmental Protection Department
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R PNG graph width limitation

2009-09-22 Thread Yihui Xie
Given the DPI=72, do you really need a graph that's wider than 450
inches? Or can you really read a picture that is so wide?

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Sep 22, 2009 at 11:30 AM, zphnabr  wrote:
>
> Hi folks,
>
> I am trying to do a clustering and generate a long dendrogram in R on Linux
> server:
> =
> data<-read.table(file="mean_ratio.txt.noheader",row.names=1,sep="\t",quote="\"")
> hc<-hclust(dist(data),"ward")
> png(file="mean_ratio.txt.noheader.ward.png",bg="white",pointsize=8,width=32767,height=1536)
> plot(hc,hang=-1)
> dev.off()
> =
>
> I found that 32767 is the largest width I can go.  I tried 32768 and the
> graphics becomes all black.  I need to go higher since even with 32767 width
> is not enough for the dendrogram.  What is the problem and what is the
> workaround?
>
> Thanks,
>
> zphnabr
> --
> View this message in context: 
> http://www.nabble.com/R-PNG-graph-width-limitation-tp25530814p25530814.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem in using BATCH command

2009-09-22 Thread Yihui Xie
BATCH is not an R object, and it is not for use in R console. As
Henrik mentioned, you should use it in the command line. Open a
terminal window/command window (depending on your OS), and type "R CMD
BATCH ..." there. If you are using Windows, cd to the 'bin' directory
of R first (or put the 'bin' directory into your environment variable
'PATH').

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Sep 22, 2009 at 11:01 AM, Manuj Sharma  wrote:
> I tried to use BATCH command to run an input file (a simple text file) which 
> contained a few R commands.
>
> I first saw the BATCH help page using
>  > ?BATCH
>
> The help page mentioned the Usage as:
> Batch Execution of RR CMD BATCH [options] infile [outfile]
>
> The Detailed section mentioned the following:
>
> Use R CMD BATCH --help to be reminded of the usage.
>
> My input file is called batchchk, which contains the following R commands:
> ls()
> ox <- read.table("rev_full_idle.out", header=TRUE)
> ov <- ox$Times
> length(ov)
> summary(ov)
>
> I loaded the utils library (probably it is loaded by default):
>   > library(utils)
>
> I ran the following commands and got the indicated errors:
>
>   > BATCH batchchk
>     Error: unexpected symbol in "BATCH batchchk"
>
>   > R CMD BATCH batchchk
>     Error: unexpected symbol in "R CMD"
>
>   > R CMD BATCH --help
>     Error: unexpected symbol in "R CMD"
>
>   > BATCH --help
>     Error: object 'BATCH' not found
>
> Can somebody please point out where I am going wrong?
>
> Thanks in advance,
>
> Manuj
>
>
>
>
>
>
>      Connect more, do more and share more with Yahoo! India Mail. Learn more. 
> http://in.overview.mail.yahoo.com/
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R PNG graph width limitation

2009-09-22 Thread Yihui Xie
Well, if you don't care about its width, I'd suggest you use the pdf()
device instead, e.g.

# 200 inches!
pdf("hugeplot.pdf", width = 200, height = 200)
par(mar = rep(0, 4))
plot(rnorm(1), pch = 19)
dev.off()

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2009/9/22 Zhengping Huang :
> Thanks a lot Yihui for your kindness and help.  Yes I do need that graph.  I 
> do not care about resolution as long as it's human readable.  Please suggest 
> how I can make that work.
>
> Thanks again,
>
> Zhengping
>
>
> On Tue, Sep 22, 2009 at 10:06 AM, Yihui Xie  wrote:
>>
>> Given the DPI=72, do you really need a graph that's wider than 450
>> inches? Or can you really read a picture that is so wide?
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Phone: 515-294-6609 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 3211 Snedecor Hall, Ames, IA
>>
>>
>>
>> On Tue, Sep 22, 2009 at 11:30 AM, zphnabr  wrote:
>> >
>> > Hi folks,
>> >
>> > I am trying to do a clustering and generate a long dendrogram in R on Linux
>> > server:
>> > =
>> > data<-read.table(file="mean_ratio.txt.noheader",row.names=1,sep="\t",quote="\"")
>> > hc<-hclust(dist(data),"ward")
>> > png(file="mean_ratio.txt.noheader.ward.png",bg="white",pointsize=8,width=32767,height=1536)
>> > plot(hc,hang=-1)
>> > dev.off()
>> > =
>> >
>> > I found that 32767 is the largest width I can go.  I tried 32768 and the
>> > graphics becomes all black.  I need to go higher since even with 32767 
>> > width
>> > is not enough for the dendrogram.  What is the problem and what is the
>> > workaround?
>> >
>> > Thanks,
>> >
>> > zphnabr
>> > --
>> > View this message in context: 
>> > http://www.nabble.com/R-PNG-graph-width-limitation-tp25530814p25530814.html
>> > Sent from the R help mailing list archive at Nabble.com.
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R PNG graph width limitation

2009-09-22 Thread Yihui Xie
I see. What you meant by "human readable" is to separate the lines and
texts in the graph, and that's why you need a so wide graph. Well, I
guess, as Henrik told you, the graph was indeed generated there, but
your viewer was not able to show it.

I also found Adobe Reader cannot display a document that's wider than
200 inches (my OS: Windows XP). Maybe you should try to print it on a
huge piece of paper?

Again, I cannot understand how can a 450-inches-long graph be "human
readable"; I mean, how can your eyes read 5981 subjects in a single
graph... It sounds like counting the stars in the sky. If you insist
on reading the result of your clustering of 5981 cases, I'd suggest
looking at smaller pieces of results at one time (i.e. sub-clusters).

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Sep 22, 2009 at 1:43 PM, Zhengping Huang  wrote:
> Dear Mr. Xie,
>
> Please find the attached ZIP file, which when unzip will expand to four
> files:
>
> (1) mean_ratio.090921_08.txt.noheader
> input data file;
>
> (2) mean_ratio.090921_08.txt.noheader.ward.width_200.pdf
>
> By these R command:
>
>>
>> data<-read.table(file="mean_ratio.090921_08.txt.noheader",row.names=1,sep="\t",quote="\"")
>> hc<-hclust(dist(data),"ward")
>>
>> pdf(file="mean_ratio.090921_08.txt.noheader.ward.pdf",bg="white",pointsize=8,width=200,height=16)
>> plot(hc,hang=-1)
>> dev.off()
>
> (3) mean_ratio.090921_08.txt.noheader.ward.width_100.pdf
>
> By these R command (only difference from (2) is width):
>
>>
>> data<-read.table(file="mean_ratio.090921_08.txt.noheader",row.names=1,sep="\t",quote="\"")
>> hc<-hclust(dist(data),"ward")
>>
>> pdf(file="mean_ratio.090921_08.txt.noheader.ward.pdf",bg="white",pointsize=8,width=100,height=16)
>> plot(hc,hang=-1)
>> dev.off()
>
> (4) mean_ratio.090921_08.txt.noheader.ward.width_200.yihan.pdf
>
> By these R command (suggested by you):
>
>>
>> data<-read.table(file="mean_ratio.090921_08.txt.noheader",row.names=1,sep="\t",quote="\"")
>> hc<-hclust(dist(data),"ward")
>>
>> pdf(file="mean_ratio.090921_08.txt.noheader.ward.pdf",bg="white",pointsize=8,width=200,height=16)
>> par(mar = rep(0, 4))
>> plot(rnorm(1), pch = 19)
>> dev.off()
>
> Obviously the graph generated by your suggested R codes is not what I want.
> From graph in (2) you can see even with width 200 the graph is still not
> readable in PDF.  I tried to go beyond 200 (210) and it did not work.
>
> You could try to cluster and generate dendrogram on your machine.  I just
> need a human readable dendrogram.
>
> Many thanks!
>
> Zhengping
>
>
>
> On Tue, Sep 22, 2009 at 10:56 AM, Yihui Xie  wrote:
>>
>> Well, if you don't care about its width, I'd suggest you use the pdf()
>> device instead, e.g.
>>
>> # 200 inches!
>> pdf("hugeplot.pdf", width = 200, height = 200)
>> par(mar = rep(0, 4))
>> plot(rnorm(1), pch = 19)
>> dev.off()
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Phone: 515-294-6609 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 3211 Snedecor Hall, Ames, IA
>>
>>
>>
>> 2009/9/22 Zhengping Huang :
>> > Thanks a lot Yihui for your kindness and help.  Yes I do need that
>> > graph.  I do not care about resolution as long as it's human readable.
>> > Please suggest how I can make that work.
>> >
>> > Thanks again,
>> >
>> > Zhengping
>> >
>> >
>> > On Tue, Sep 22, 2009 at 10:06 AM, Yihui Xie  wrote:
>> >>
>> >> Given the DPI=72, do you really need a graph that's wider than 450
>> >> inches? Or can you really read a picture that is so wide?
>> >>
>> >> Regards,
>> >> Yihui
>> >> --
>> >> Yihui Xie 
>> >> Phone: 515-294-6609 Web: http://yihui.name
>> >> Department of Statistics, Iowa State University
>> >> 3211 Snedecor Hall, Ames, IA
>> >>
>> >>
>> >>
>> >> On Tue, Sep 22, 2009 at 11:30 AM, zphnabr  wrote:
>> >> >
>> >> > Hi folks,
>> >> >
>> >> > I am trying to do a clustering and generate a long dendrogram in R on
>> >>

Re: [R] how to save plots automatically

2009-09-22 Thread Yihui Xie
Something like

for(i in 1:20){
  pdf(sprintf("myplot%d.pdf",i))
  # your calculation and plots here
  dev.off()
}

If you have 100 plots in total, then you should have 5 graphs in each
single pdf.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Sep 22, 2009 at 10:23 PM, David Winsemius
 wrote:
>
> On Sep 22, 2009, at 9:50 PM, Weiwei Shi wrote:
>
>> Hi there,
>>
>> I am wondering if there is a function in R to save plots automatically,
>> like
>> save() for R objects? I have e.g. 100 plots and I cannot put them in one
>> pdf
>> file so I split them, eg into 20 files, but I don't want to save one file
>> each time. Can I use a function to do such save.plot as pdf?
>>
>
> ?pdf
>
>
>>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sweve/cacheSweave

2010-02-11 Thread Yihui Xie
If I understand pgfSweave correctly, a line like this

\usepackage{C:/PROGRA~1/R/some.version/share/texmf/Sweave}

will be added to the preamble of your LaTeX document if you didn't
explicitly add \usepackage{Sweave} by yourself.

That will cause the error like

Missing  \endcsname inserted
The control sequence marked  should not appear
between \csname and \endcsname.

(I cc'ed to Cameron to see if I'm correct)

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Thu, Feb 11, 2010 at 7:39 AM, Unger, Kristian  wrote:
> Thank you very much Duncan! Adding the line \usepackage{Sweave} fixed the 
> problem.
>
> Best wishes
>
> Kristian
> _
>
> Dr Kristian Unger
>
> Bioinformaticist Chernobyl Tissue Bank
>
> Division of Surgery and Cancer
>
> Imperial College London
>
> Rm G02, Ground floor G Block
> Hammersmith Hospital
> Du Cane Road,
> London W12 0HS
>
> Tel +44-20-8383-2443
>
> Mob +44-795-1080619
>
> Skype kristianunger
>
> http://www1.imperial.ac.uk/medicine/about/divisions/is/histo/
> http://www.chernobyltissuebank.com
>
> -Original Message-
> From: Duncan Murdoch [mailto:murd...@stats.uwo.ca]
> Sent: 11 February 2010 12:06
> To: Unger, Kristian
> Cc: 'r-help@r-project.org'
> Subject: Re: [R] Sweve/cacheSweave
>
> On 11/02/2010 6:06 AM, Duncan Murdoch wrote:
>> Unger, Kristian wrote:
>>> Hi there
>>>
>>> I have a problem with using Sweave in combination with the option driver = 
>>> cacheSweave.
>>>
>>> Whichever code I try to run  - when it comes to converting the tex file 
>>> into pdf it comes up with the same errors (\csname \endcsname errors). Does 
>>> anybody have an idea what it going wrong?
>>>
>>>
>>>> Sweave("pgfSweave-example.Rnw",driver  =  cacheSweaveDriver)
>>>>
>>> Writing to file pgfSweave-example.tex
>>> Processing code chunks ...
>>>  1 : term verbatim (label=setup)
>>>  2 : echo term verbatim (label=data)
>>>  3 : term verbatim eps pdf (label=boxplot)
>>>
>>> You can now run LaTeX on 'pgfSweave-example.tex'
>>>
>>>
>>>> tools::texi2dvi("pgfSweave-example.tex", pdf=TRUE)
>>>>
>>> Error in tools::texi2dvi("pgfSweave-example.tex", pdf = TRUE) :
>>>   running 'texi2dvi' on 'pgfSweave-example.tex' failed
>>>
>>> LaTeX errors:
>>> C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
>>> Missing
>>>  \endcsname inserted
>>> The control sequence marked  should
>>> not appear between \csname and \endcsname.
>>>
>>> C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
>>> LaTeX E
>>> rror: Missing \begin{document}.
>>>
>>
>> I think this is the important error:  it looks as though your .tex file
>> isn't a complete LaTeX document.  The other errors likely follow from this.
>
>  From an offline followup:  the .tex was complete, but it included a
> path to Sweave.sty that contained TeX-special characters, and that was
> the source of the error.  See ?RweaveLatex for a discussion of how to
> avoid this.
>
> Duncan Murdoch
>
>>
>> Duncan Murdoch
>>> See the LaTeX manual or LaTeX Companion for explanation.
>>> Type  H   for immediate help
>>> C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
>>> Extra \
>>> endcsname
>>> I'm ignoring this, since I wasn't doing a \csname.
>>>
>>>
>>> C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
>>> Missing
>>>  \endcsname inserted
>>> The control sequence marked  should
>>> not appear between \csname and \endcsname.
>>>
>>> C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
>>> Extra \
>>> endcsname
>>> I'm ignoring this, since I wasn't doing a \csname.
>>>
>>> I am running this under Windows XP, R version 2.9.2 (2009-08-24), > 
>>> package.version("cacheSweave")
>>> [1] "0.4-3".
>>>
>>> Any help or advice on this would be highly appreciated!
>>>
>>> Best wishes
>>>
>>> Kristian
>>>
>>> _
>>>
>>> Dr Kristian Unger
>>>
>>> Bioinformaticist Chernobyl Tissue Bank
>>>
>>> Division of S

Re: [R] SVGAnnotation in Windows

2010-03-07 Thread Yihui Xie
SVGAnnotation works fine for me under Windows. I guess Cleber was
using R < 2.10.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2010/3/6 Uwe Ligges :
>
>
> On 06.03.2010 18:35, Cleber Borges wrote:
>>
>> Does anyone know if there is SVGAnnotation package for Windows, and if
>> so, a link to download?
>
> A Google search reveals SVGAnnotation is an Omegahat hosted package.
> http://www.omegahat.org tells us to use
>
>  install.packages(packageName, repos = "http://www.omegahat.org/R";)
>
> and the Windows binary 2.10 repository seems to be fine.
>
> So what is your problem?
>
> Best,
> Uwe Ligges
>
>
>
>
>
>> Thank you!
>>
>>
>> Cleber N. Borges
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] parse an HTML page with verbose error message (using XML)

2010-03-11 Thread Yihui Xie
I'm using the function htmlParse() in the XML package, and I need a
little bit help on error handling while parsing an HTML page. So far I
can use either the default way:

# error = xmlErrorCumulator(), by default
library(XML)
doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/";)
# the error message is:
# htmlParseStartTag: invalid element name

or the tryCatch() approach:

# error = NULL, errors to be caught by tryCatch()
tryCatch({
doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/";,
error = NULL)
}, XMLError = function(e) {
cat("There was an error in the XML at line", e$line, "column",
e$col, "\n", e$message, "\n")
})
# verbose error message as:
# There was an error in the XML at line 90 column 2
# htmlParseStartTag: invalid element name

I wish to get the verbose error messages without really stopping the
parsing process; the first approach cannot return detailed error
messages, while the second one will stop the program...

Thanks!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] rmaxwell in C

2010-03-12 Thread Yihui Xie
rmaxwell() depends on rgamma(), so what you actually need is to
download R source (rgamma() might depend further on other functions,
though).

> library(VGAM)
> rmaxwell
function (n, a)
{
if (!is.Numeric(n, posit = TRUE, allow = 1))
stop("bad input for argument 'n'")
if (any(a <= 0))
stop("argument 'a' must be positive")
sqrt(2 * rgamma(n = n, 1.5)/a)
}


Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Fri, Mar 12, 2010 at 12:18 AM, 王杰彪  wrote:
> Hi R useRs:
>
> How can I generate a random sample from Maxwell Distribution in C language?
> Since I know the function rmaxwell {VGAM}, I tried the function r2c {r2c}.
> But I still cannot find the source code.
>
> Thanks for your kind help.
>
> RegaRds,
>
> 2010-03-12
>
>
>
> Randel
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] rmaxwell in C

2010-03-12 Thread Yihui Xie
The manual R-exts, section 6.7.1 should help if you want to call rgamma() in C.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2010/3/12 xie :
> rmaxwell() depends on rgamma(), so what you actually need is to download R 
> source (rgamma() might depend further on other functions, though).
>
>> library(VGAM)
>> rmaxwell
> function (n, a)
> {
> if (!is.Numeric(n, posit = TRUE, allow = 1))
> stop("bad input for argument 'n'")
> if (any(a <= 0))
> stop("argument 'a' must be positive")
> sqrt(2 * rgamma(n = n, 1.5)/a)
> }
> 
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-6609 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 3211 Snedecor Hall, Ames, IA
>
>
>
> On Fri, Mar 12, 2010 at 12:18 AM, 王杰彪  wrote:
>> Hi R useRs:
>>
>> How can I generate a random sample from Maxwell Distribution in C language?
>> Since I know the function rmaxwell {VGAM}, I tried the function r2c {r2c}.
>> But I still cannot find the source code.
>>
>> Thanks for your kind help.
>>
>> RegaRds,
>>
>> 2010-03-12
>>
>>
>>
>> Randel
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] XML: Slower parsing over time with htmlTreeParse()

2010-03-15 Thread Yihui Xie
So you are parsing a *URL* instead of a local HTML file? I guess it
might have something to do with your internet connection as well as
the web server for that URL (some servers may restrict your access if
you visit it too frequently). Can you provide a reproducible example?

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Mon, Mar 15, 2010 at 7:09 AM, Janko Thyson
 wrote:
> Sorry, I listed the wrong package in the header of my previous post!
>
>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>
>
> Dear List,
>
>
>
> has anyone of you experienced a significant increase in the time it takes to
> parse an URL via "htmlTreeParse()" when this function is called repeatedly
> every minute over a couple of hours?
>
>
>
> Initially, a single parse takes about 0.5 seconds on my machine (Quad Core,
> 2.67 GHz, 8 MB RAM, Windows 7 64 Bit), . After some time, this can go up to
> 15 seconds or more.
>
>
>
> I've tried garbage collect, "catalogClearTable()" (though I don't think that
> has anything to do with the issue) and lately wondered if it maybe had to do
> with the accumulation of errors over time ("xmlErrorCumulator()"). Are
> parsing errors cumulated globally in the workspace over distinct calls to
> this function? If so, is there a way to "clean the buffer"?
>
>
>
> I would greatly appreciate if anyone had an idea about how to keep
> request/parsing time fairly constant at the initial low level of 0.5
> seconds.
>
>
>
> Thanks a lot,
>
> Janko
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Export rgl plot3d scatter

2009-06-29 Thread Yihui Xie
Will it be so difficult to switch to R during your demonstration? I
think it's much more difficult to embed the rgl demo in your document
and keep the rotating feature. You may take a look at the example for
'rgl.snapshot', which shows you how to create an animation with
ImageMagick, but I still prefer using rgl directly.

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Mon, Jun 29, 2009 at 8:39 AM, Patrick Gedeon wrote:
> Hello,
> I have created a 3d scatter plot using plot3d. Is it possible to export the
> resulting graph so that it can be placed in a pdf, powerpoint, or something
> of the sort and still be able to rotate it?
>
> Thanks
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!

2010-03-30 Thread Yihui Xie
In a Binomial GLM, typically y is a factor with two levels (indicating
success/failure) instead of a numeric vector on [0, 1]. Perhaps the
description in the book is not so clear. You should interpret "data on
proportions" as the observations from a Binomial distribution (rather
than we observed some proportion data which fell in [0,1]). E.g.

y=rbinom(10, size = 1, prob = .3); x=rnorm(y)
# or y = factor(y)
glm(y~x, family = binomial)


Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Mar 30, 2010 at 9:51 AM, Corrado  wrote:
> Dear friends,
>
> I am testing glm as at page 514/515 of THE R BOOK by M.Crawley, that is on
> proportion data.
>
> I use glm(y~x1+,family=binomial)
>
> y is a proportion in (0,1), and x is a real number.
>
> I get the error:
>
> In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
>
> But that is exactly what was suggested in the book, where there is no
> mention of a similar warning. Where am I going wrong?
>
> Here is the output:
>
>> glm(response.prepared~x,data=,family=binomial)
>
> Call:  glm(formula = response.prepared ~ x, family = binomial, data = )
>
> Coefficients:
> (Intercept)            x    -0.3603       0.4480
> Degrees of Freedom: 510554 Total (i.e. Null);  510553 Residual
> Null Deviance:      24420
> Residual Deviance: 23240        AIC: 700700
> Warning message:
> In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
>>
>
>
>
> Regards
> --
>
> Corrado Topi
> PhD Researcher
> Global Climate Change and Biodiversity
> Area 18,Department of Biology
> University of York, York, YO10 5YW, UK
> Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] WinBUGS Question

2010-04-13 Thread Yihui Xie
If you are using R2WinBUGS, I guess you may put them in a loop like:

# models
...
data_i[j]~dnorm(...)
...
# save them in a sequence of files with names like 'model_i.bug'
# write.model() might help?

# then call bugs()
for(i in names.of.your.100.datasets){
  bugs(data=i,...,model.file='model_i.bug',...)
}

The above code might need paste() here and there, e.g. paste('data_',
i, sep='').

I don't know if WinBUGS itself supports such a loop.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Apr 13, 2010 at 1:48 PM, Anamika Chaudhuri  wrote:
> Hi:
>
> Is there a way we can set up WINBUGS to run 100 simulated datasets on the
> same model and output results? Or do we have to call in each dataset at a
> time and repeat the process 100 times manually?
>
> Thanks
> Anamika
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] formatR: farewell to ugly R code

2010-04-16 Thread Yihui Xie
This is an announcement of the release of an R package 'formatR',
which can help us format our R code to make it more human-readable. If
you have ugly (I mean unformatted) R code like this:

 # rotation of the word "Animation"
# in a loop; change the angle and color
# step by step
for (i in 1:360) {
 # redraw the plot again and again
plot(1,ann=FALSE,type="n",axes=FALSE)
# rotate; use rainbow() colors
text(1,1,"Animation",srt=i,col=rainbow(360)[i],cex=7*i/360)
# pause for a while
Sys.sleep(0.01)}

There are no spaces, no appropriate indent... The package 'formatR'
provides a GUI (by gWidgets) to make messy R code clean and tidy, e.g.

# rotation of the word 'Animation'
# in a loop; change the angle and color
# step by step
for (i in 1:360) {
   # redraw the plot again and again
   plot(1, ann = FALSE, type = "n", axes = FALSE)
   # rotate; use rainbow() colors
   text(1, 1, "Animation", srt = i, col = rainbow(360)[i],
       cex = 7 * i/360)
   # pause for a while
   Sys.sleep(0.01)
}

The usage is simple:

# formatR depends on RGtk+; will be installed automatically
# better use the latest version of R (>=2.10.1)
install.packages('formatR')
library(formatR)
# or formatR()

Screen-shots can be found here:
http://yihui.name/en/2010/04/formatr-farewell-to-ugly-r-code/

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [R-pkgs] formatR: farewell to ugly R code... Problem with too old ver. of Gtk

2010-04-18 Thread Yihui Xie
Sorry, I was thinking about GTK+ and RGtk2, then they got mixed up in
my mind to the strange animal "RGtk+"...

I noticed a few users had troubles with installing RGtk2, so I removed
the strict dependence on 'gWidgetsRGtk2' in the next version of
'formatR' (0.1-4). Users can specify other types of GUI's now. For
example, a screenshot for the Java interface is here:
http://yihui.name/en/2010/04/formatr-farewell-to-ugly-r-code/#comment-9788

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Sun, Apr 18, 2010 at 7:25 AM, Prof Brian Ripley
 wrote:
> On Sun, 18 Apr 2010, Brian Lunergan wrote:
>
>> Yihui Xie wrote:
>>>
>>> This is an announcement of the release of an R package 'formatR',
>>> which can help us format our R code to make it more human-readable. If
>>> you have ugly (I mean unformatted) R code like this:
>>>
>>>  # rotation of the word "Animation"
>>> # in a loop; change the angle and color
>>> # step by step
>>> for (i in 1:360) {
>>>     # redraw the plot again and again
>>> plot(1,ann=FALSE,type="n",axes=FALSE)
>>> # rotate; use rainbow() colors
>>> text(1,1,"Animation",srt=i,col=rainbow(360)[i],cex=7*i/360)
>>> # pause for a while
>>> Sys.sleep(0.01)}
>>>
>>> There are no spaces, no appropriate indent... The package 'formatR'
>>> provides a GUI (by gWidgets) to make messy R code clean and tidy, e.g.
>>>
>>> # rotation of the word 'Animation'
>>> # in a loop; change the angle and color
>>> # step by step
>>> for (i in 1:360) {
>>>   # redraw the plot again and again
>>>   plot(1, ann = FALSE, type = "n", axes = FALSE)
>>>   # rotate; use rainbow() colors
>>>   text(1, 1, "Animation", srt = i, col = rainbow(360)[i],
>>>       cex = 7 * i/360)
>>>   # pause for a while
>>>   Sys.sleep(0.01)
>>> }
>>>
>>> The usage is simple:
>>>
>>> # formatR depends on RGtk+; will be installed automatically
>
> I think he meant RGtk2, and 'attempt to install'.
>
>>> # better use the latest version of R (>=2.10.1)
>>> install.packages('formatR')
>>> library(formatR)
>>> # or formatR()
>>>
>>> Screen-shots can be found here:
>>> http://yihui.name/en/2010/04/formatr-farewell-to-ugly-r-code/
>>
>> Interested in adding this package but when I tried to load it and its
>> dependencies the system spit back that I didn't have the right version of
>> Gtk.
>
> You didn't show us the actual message, though, nor tell us if you were doing
> a source package install (or if a binary one, where you got binaries from).
>  I suspect it came from RGtk2 and actually means that you do not have all
> the RGtk2-related development packages installed. I had something similar
> (given the vagueness of your description) yesterday on Solaris, when the
> issue was that I missing gnome-devel (I did have gtk-2.0-devel installed).
>
> It is unlikely that you have the components but they are too old.  The
> stated minimum requirement is Gtk 2.8.0 (August 2005).
>
> If you download and unpack the RGtk2 tarball and run R CMD INSTALL on it
> there will be a file RGtk2/config.log: that is what told me what it thought
> I had missing.
>
>> I'm running Ubuntu Linux 8.04 (Hardy Heron) with all the called for
>> updates. I've looked in synaptic but I'm not an 'under the hood' type of
>> user so I have no clue what to look for in there to find out what I have
>> or
>> even if it is possible to update. Oh yes, I'm running v2.10.1 of R.
>>
>> Is there any likely solution to this situation, or am I SOL because my
>> Linux version is now simply too old?
>>
>> Regards...
>> --
>> Brian Lunergan
>> Nepean, Ontario
>> Canada
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> --
> Brian D. Ripley,                  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to open only one file in a .gz file?

2009-09-27 Thread Yihui Xie
gzfile() can handle a single file in *.gz. If you want to read one of
the files in a bunch of files, you may as well extract them first
using "tar -zxvf yourarchive.tar.gz" (sounds like a stupid solution),
or if you only want to use R, system() could help, e.g. system("tar
-zxvf yourarchive.tar.gz"). You didn't tell us sessionInfo(), so I'm
not sure whether you are able to use the "tar" command.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2009/9/27 Uwe Ligges :
>
>
> Peng Yu wrote:
>>
>> Hi,
>>
>> Suppose that there are multiple files in a .gz file.
>
> Well, the extension .gz regularly stand for a (single) gzip compressed file.
> Tyoically you will find more tan one file in a tar archive or a zip
> compressed archive. For the latter see ?unz.
>
> Uwe Ligges
>
>
>
>> How to open only
>> one file in it? I don't find such options in the help.
>>
>> Regards,
>> Peng
>>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Is there a R function that can do similar things like 'pdist' in Matlab?

2009-09-30 Thread Yihui Xie
That's not correlation. It's distance instead.

See ?dist

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Sep 29, 2009 at 8:22 PM, RT Ye  wrote:
> Hi,
>
> I want to compute the pairwise correlation for about 10,000 genes. In
> Matlab there is a function called 'pdsit' that can do this very
> efficiently. I am wondering is there a similar function in R?
>
> Thanks,
>
> RT Ye.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Modify base R functions in Rprofile.site

2009-10-03 Thread Yihui Xie
Hi everyone,

I want to modify two base R functions 'parse' and 'deparse'
immediately after R has started, so I added some code in the file
'Rprofile.site' under the 'etc' directory. Here is a simple example:

parse=function(...){
base::parse(...)
}

I'll get an error when I start R as follows:

Error: cannot change value of locked binding for 'parse'

Is there a solution for my problem? Please note that I *have to*
override the function names. Thanks very much!

> sessionInfo()
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese_People's Republic of
China.936;LC_CTYPE=Chinese_People's Republic of
China.936;LC_MONETARY=Chinese_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese_People's Republic of China.936

attached base packages:
[1] datasets  utils stats graphics  grDevices methods   base

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Modify base R functions in Rprofile.site

2009-10-04 Thread Yihui Xie
Thanks a lot, Charlie. What a coincidence -- I'm also working on
Sweave functions. parse() and deparse() can make the code more tidy
(they are used in source() and RweaveLatexRuncode()),

> RweaveLatex
function ()
{
list(setup = RweaveLatexSetup, runcode = RweaveLatexRuncode,
writedoc = RweaveLatexWritedoc, finish = RweaveLatexFinish,
checkopts = RweaveLatexOptions)
}


but we can either (1) let R automatically 'tidy up' our code and
remove all the comments or (2) keep the comments but leave the
original code untouched.

I worked out a trick to preserve the comments while tidying up the R
code, and I want to replace parse() and deparse() with my customized
functions, in which case Sweave will keep the comments.

However, my functions will need base::parse() and base::deparse() to
help me, therefore my real difficulty is, how to let Sweave use my
functions to parse and deparse R code without really modifying them in
the base enviroment? I'm using the command 'R CMD Sweave'. If there is
no neat approach, I'll change my question to: how to write a package,
say, Sweave2, that can be run using command line 'R CMD Sweave2 file'?

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2009/10/4 cls59 :
>
>
>
> Yihui Xie wrote:
>>
>> Hi everyone,
>>
>> I want to modify two base R functions 'parse' and 'deparse'
>> immediately after R has started, so I added some code in the file
>> 'Rprofile.site' under the 'etc' directory. Here is a simple example:
>>
>> parse=function(...){
>>     base::parse(...)
>> }
>>
>> I'll get an error when I start R as follows:
>>
>> Error: cannot change value of locked binding for 'parse'
>>
>> Is there a solution for my problem? Please note that I *have to*
>> override the function names. Thanks very much!
>>
>>
>
>
> Hi Yihui,
>
> I have had cause to do some some similar things to Sweave functions-- maybe
> the following will help:
>
>  # Find out where the function lives.
>  env <- as.environment( 'package:base' )
>
>  # Crack the binding.
>  unlockBinding( 'parse', env )
>
>  # Replace the function.
>  assignInNamespace( 'parse', function(...){
>
>   # Your function here, or an object that contains it.
>
>   }, ns = 'base' )
>
>  # Relock the binding.
>  lockBinding( 'parse', env )
>
>
> Note that the above is *very* dark voodoo-- it may cause unforeseen
> consequences.
>
> Good luck!
>
> -Charlie
>
> -
> Charlie Sharpsteen
> Undergraduate
> Environmental Resources Engineering
> Humboldt State University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Modify base R functions in Rprofile.site

2009-10-04 Thread Yihui Xie
Hi Charlie,

Thanks a lot! Your "dark voodoo" really helps!

And also, thanks so much to Duncan for your detailed explanation!
Finally I used Charlie's trick to modify makeRweaveLatexCoderunner(),
and has left parse() & deparse() untouched.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Sun, Oct 4, 2009 at 5:51 PM, cls59  wrote:
>
>
> Yihui Xie wrote:
>>
>>
>> Thanks a lot, Charlie. What a coincidence -- I'm also working on
>> Sweave functions. parse() and deparse() can make the code more tidy
>> (they are used in source() and RweaveLatexRuncode()),
>>
>>> RweaveLatex
>> function ()
>> {
>>     list(setup = RweaveLatexSetup, runcode = RweaveLatexRuncode,
>>         writedoc = RweaveLatexWritedoc, finish = RweaveLatexFinish,
>>         checkopts = RweaveLatexOptions)
>> }
>> 
>>
>> but we can either (1) let R automatically 'tidy up' our code and
>> remove all the comments or (2) keep the comments but leave the
>> original code untouched.
>>
>> I worked out a trick to preserve the comments while tidying up the R
>> code, and I want to replace parse() and deparse() with my customized
>> functions, in which case Sweave will keep the comments.
>>
>> However, my functions will need base::parse() and base::deparse() to
>> help me, therefore my real difficulty is, how to let Sweave use my
>> functions to parse and deparse R code without really modifying them in
>> the base enviroment? I'm using the command 'R CMD Sweave'.
>>
>>
>
> Well, if you want to alter the behavior of RweaveLatexRunCode(), it can be
> done from within a Sweave file. This happens to be what I did to Sweave-- I
> wanted a little more control over the specifics of how it formatted code
> chunk output in the .tex file. The steps involved are:
>
> 1. Make a copy of the Sweave function makeRweaveLatexCoderunner(). Patch it
> so that it generates a RweaveLatexRuncode() function of your liking.
>
> 2. Overwrite utils:::makeRweaveLatexCodeRunner using the method I described
> previously.
>
> 3. Generate a new code runner function using your patched version of
> makeRweaveLatexCodeRunner().
>
> 4. Search all environments for old versions of RweaveLatexRuncode() and
> replace them with your patched one.
>
> An example of this approach is used to build the tikzDevice vignette, you
> can view it at:
>
> http://github.com/Sharpie/RTikZDevice/blob/master/inst/doc/tikzDevice.Rnw
>
> Look for the line that says "Begin Mother of All R Hacks".
>
>
>
>
> Yihui Xie wrote:
>>
>>
>> If there is no neat approach, I'll change my question to: how to write a
>> package,
>> say, Sweave2, that can be run using command line 'R CMD Sweave2 file'?
>>
>>
>
> This is also doable, at least for Linux and OS X systems that are installing
> from source. You need to add a Make target that installs your script, named
> Sweave2, into R_HOME/bin/ when the package is installed. This is the
> approach we took in the pgfSweave package-- you can view an example at:
>
> http://github.com/cameronbracken/pgfSweave/blob/master/src/Makevars
>
> I hope this helps!
>
> -Charlie
>
> -
> Charlie Sharpsteen
> Undergraduate
> Environmental Resources Engineering
> Humboldt State University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with na.omit when using length()

2009-10-05 Thread Yihui Xie
just put na.omit() inside length() if you intend to omit the NA
elements of the vector (otherwise you are trying to omit the NA's of
the returned value of length() which is a scalar 2):

length(na.omit(sno[a==1 & b==0]))

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Mon, Oct 5, 2009 at 11:51 PM, Viju Moses  wrote:
> I'm seeing what looks to me like odd behaviour when I use na.omit on a
> simple "length" function, as follows.
>
>> sno
>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
> 25 26 27 28 29 30 31 32 33 34
>> a
>  [1] 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
>> b
>  [1]  1  1  0  1  1  1  0  0 NA  0  0  0 NA  0  1 NA  0  1  0  0  0  0 NA  0
>  0  0  0 NA  0 NA  0  1  0  0
>
> #NA refers to no data available.
>
>> df=data.frame(sno,a,b)
> # I'm pasting the sorted data frame below:
>> sortdf=df[order(a,b),]
>> sortdf
>   sno a  b
> 3    3 0  0
> 7    7 0  0
> 8    8 0  0
> 10  10 0  0
> 11  11 0  0
> 12  12 0  0
> 14  14 0  0
> 17  17 0  0
> 20  20 0  0
> 21  21 0  0
> 22  22 0  0
> 24  24 0  0
> 25  25 0  0
> 26  26 0  0
> 27  27 0  0
> 29  29 0  0
> 31  31 0  0
> 33  33 0  0
> 34  34 0  0
> 1    1 0  1
> 4    4 0  1
> 9    9 0 NA
> 13  13 0 NA
> 23  23 0 NA
> 28  28 0 NA
> 30  30 0 NA
> 19  19 1  0
> 2    2 1  1
> 5    5 1  1
> 6    6 1  1
> 15  15 1  1
> 18  18 1  1
> 32  32 1  1
> 16  16 1 NA
>
> #Now I wish to count howmany records have a=1 AND b=0. From the lower
> section of that sorted dataframe we see the answer is 1 (record # 19). But
> instead I'm seeing 2. Probably counting record # 16 also.
>
>> na.omit(length(sno[a==1 & b==0]))
> [1] 2
>
> I'd be grateful to anyone who can point out what I'm doing wrong.
>
> Regards.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] celebrating revision 50000

2009-10-09 Thread Yihui Xie
I extracted the data for hours of a day and created some graphs here:
http://yihui.name/en/2009/10/5-revisions-committed-to-r/

Certainly our R core gods are so very hard-working and devoted that
some even commit revisions to R at 3am in the morning!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Fri, Oct 9, 2009 at 1:13 PM, Romain Francois
 wrote:
> Thanks to Dirk for pointing it out in my blog : "thomas" and "tlumley" are
> the same person. Also "martyn" and "plummer", and "paul" and "murrell" ...
> updated number of commits per author below
>
>> sort( table( simple$author ), decreasing=T )
>
>     ripley    maechler      hornik          pd     murdoch       iacus
>      20523       10207        6744        4655        1370         915
>     leisch         jmc        luke       ihaka     murrell       bates
>        743         643         618         481         427         350
>    tlumley    rgentlem    urbaneks (no author)      duncan           r
>        337         299         274         203         172          96
>    plummer      lyndon       guido    deepayan      falcon        mike
>         65          54          39          20          18           1
>
>
> Not quite sure who "r" is (96 commits) and "mike" (1 commit). Also there are
> 203 commits that have "(no author)"
>
> The other thing is that it does not include data from the pre-svn era.
>
> Romain
>
> On 10/09/2009 03:41 PM, Romain Francois wrote:
>>
>> Hello,
>>
>> Today, Brian Ripley commited the revision 5 of R's svn repository.
>>
>> I took this as an opportunity to do some data analysis of the log and
>> posted some code and graphics on my blog:
>>
>> http://romainfrancois.blog.free.fr/index.php?post/2009/10/09/celebrating-R-commit-5
>>
>>
>> The plots of the number of commits per day (and per month) indicates a
>> peak in 2002.
>>
>> Here are the top 20 modified files :
>>
>>  > most.updated <- head( sort( table( data$file ), decreasing=TRUE ), 20 )
>>  > cat( sprintf( "%40s : %6d", names(most.updated), most.updated ), sep
>> ="\n" )
>> /trunk/NEWS : 5449
>> /trunk/date-stamp : 2219
>> /trunk/BUGS : 1485
>> /trunk/src/gnuwin32/CHANGES : 994
>> /trunk/configure : 979
>> /trunk/doc/manual/R-FAQ.texi : 948
>> /trunk/doc/manual/R-exts.texi : 814
>> /trunk/doc/manual/R-admin.texi : 666
>> /trunk/src/main/names.c : 634
>> /trunk/tests/reg-tests-1.R : 621
>> /trunk/src/gnuwin32/Makefile : 542
>> /trunk/FAQ : 471
>> /trunk/doc/html/faq.html : 458
>> /trunk/src/include/Defn.h : 455
>> /trunk/configure.ac : 447
>> /trunk/src/scripts/check.in : 433
>> /trunk/src/library/tools/R/QC.R : 397
>> /branches/unlabeled-1.1139.4/date-stamp : 386
>> /trunk/src/main/connections.c : 349
>> /trunk/src/main/plot.c : 325
>>
>>
>> The most modified file extensions (the second element indicates files
>> without extensions) :
>>
>>  > head( sort( table( data$extension ), decreasing=T ) , 24 )
>>
>> Rd c R po in mo h
>> 36766 33999 29849 25221 10215 8806 6280 6147
>> texi gmo html save pot f win m4
>> 5274 3705 1920 1668 1285 1148 1060 1041
>> pl ac afm pm mac y packages sh
>> 910 527 482 461 402 384 311 215
>>
>> Many thanks to the R core team for these 50 000 commits.
>>
>> Romain
>>
>
>
> --
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
> http://romainfrancois.blog.free.fr
> |- http://tr.im/BcPw : celebrating R commit #5
> |- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
> `- http://tr.im/yw8E : New R package : sos
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how do you know which functions are being debugged?

2009-10-23 Thread Yihui Xie
list all objects first; use a loop (explicitly or not) to check
whether (1) your objects are functions (2) functions are debugged

> f = function(x) x
> g = 1
> x = ls()
> debug(f)
> sapply(x[sapply(x, function(i) is.function(get(i)))], isdebugged)
   f
TRUE
> undebug(f)
> sapply(x[sapply(x, function(i) is.function(get(i)))], isdebugged)
f
FALSE

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Fri, Oct 23, 2009 at 12:28 PM, Andrew Yee  wrote:
> This is kind of a dumb question:  I know you can use isdebugged() to find
> out if a specific function is flagged for debugging, but is there a way to
> list all the functions that are flagged for debugging?
> Thanks,
> Andrew
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how do you know which functions are being debugged?

2009-10-23 Thread Yihui Xie
Oops... I forgot to mention that 'envir' (or 'pos') should be
specified in ls()/get() in my last reply if you are looking for
debugged functions in environments other than ".GlobalEnv".

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Fri, Oct 23, 2009 at 1:02 PM, Duncan Murdoch  wrote:
> On 10/23/2009 1:28 PM, Andrew Yee wrote:
>>
>> This is kind of a dumb question:  I know you can use isdebugged() to find
>> out if a specific function is flagged for debugging, but is there a way to
>> list all the functions that are flagged for debugging?
>
> No, R doesn't keep any master list, it sets a flag in each one.  So you
> could iterate over all visible objects to find the ones that have the flag
> set (and this is quite slow, there are a lot of places to look), but there
> would always be the chance that one was hiding somewhere you didn't look.
>
> Duncan Murdoch
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Datasets for "The Statistical Sleuth"

2009-10-24 Thread Yihui Xie
Hi everyone,

I wonder if there already exists any R packages containing all the
data sets for the book "The Statistical Sleuth"
(http://www.proaxis.com/~panorama/home.htm; also available at StatLib
http://lib.stat.cmu.edu/datasets/sleuth).

I'm writing an R package with a friend for one of our stat courses
where SAS is the main tool being used. As the time is limited and half
of the semester has gone, we want to finish the package ASAP before
the biased (my personal feeling) impression towards R comes up. It
will save us some time (especially the time on writing R
documentation) if anyone has already done the work of packing up all
the data sets. Thanks a lot!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Announcement: the 2nd Chinese R Conference

2009-10-29 Thread Yihui Xie
Hi everyone,

Sorry for the so late announcement: we are organizing the 2nd Chinese
R Conference now following the one held last year in Beijing (see
"Conference Review: The 1st Chinese R Conference". The R Journal.
Vol1/1. P69.) The conference will be focused on:

  * introducing and popularizing R as a powerful tool for statistical
computation and graphics in China;
  * gathering Chinese R users and promoting communication between
different disciplines and industries;

For Chinese useRs and English speakeRs who will be in Beijing in
November or December, please feel free to participate and we will be
grateful if talks can be contributed at the conference. The conference
will be mainly in Chinese but English talks are also welcome.

There will be two successive sessions at two difference locations:
Beijing (Renmin University of China) and Shanghai (East China Normal
University). There is no registration fee for the Beijing session
(thanks to the support from the School of Statistics, Renmin
University), and we will try our best to cover the conference fee for
the Shanghai session. So the conference is basically free (as in
beer).

The dates for the sessions are still to be determined (sorry again for
the hasty organization), but the probability of holding this
conference in December is greater than .95.

Please visit the following page (in Chinese) for further information:

http://cos.name/useR/useR-2009/

Beijing useRs please contact user-2009...@cos.name for registration,
and Shanghai useRs: user-2009...@cos.name

Thanks!

P.S. we hope the next conference will be better prepared; please
contact user-2...@cos.name if you have any suggestions on the 3rd
Chinese R Conference.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] qqplot

2009-11-02 Thread Yihui Xie
abline(0,1) is somewhere in the upper-left corner which you are unable
to see. At least the first distribution seems to have a larger mean
than the second one (i.e. they are not the same distribution).

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Mon, Nov 2, 2009 at 10:33 AM, carol white  wrote:
> if I have the two following matrices, abline(0,1) doesn't go through. QQplot 
> is attached.
>
>            [,1]     [,2]     [,3]     [,4]     [,5]
>  2.149644 1.992864 3.346375 2.793511 3.428230
>  1.100762 2.152981 2.735401 2.175185 3.323058
> 1.212406 2.131813 2.672598 2.389996 3.242490
> 1.183770 1.908633 2.661237 2.590545 2.906059
>  1.665190 1.778923 2.636062 2.475619 4.013407
>
>
>    0.601   0.083   0.520    0.920  -0.007
>   -0.778   0.427  -0.605   -0.066  -0.283
>  -0.599   0.348  -0.693    0.284  -0.436
>   -0.519   0.081  -0.590    0.678  -1.095
>    0.009  -0.253  -0.940    0.526   1.623
>
>
> --- On Mon, 11/2/09, David Winsemius  wrote:
>
>> From: David Winsemius 
>> Subject: Re: [R] qqplot
>> To: "carol white" 
>> Cc: r-h...@stat.math.ethz.ch
>> Date: Monday, November 2, 2009, 8:17 AM
>>
>> On Nov 2, 2009, at 10:40 AM, carol white wrote:
>>
>> > Hi,
>> > We could use qqplot to see how two distributions are
>> different from each other. To show better how they are
>> different (departs from the straight line), how is it
>> possible to plot the straight line that goes through them? I
>> am looking for some thing like qqline for qqnorm. I thought
>> of abline but how to determine the slope and intercept?
>>
>> I always assumed that the intercept was zero and the slope
>> = unity.
>>
>>  y <- rt(200, df = 5)
>>  qqnorm(y); qqline(y, col = 2)
>>  qqplot(y, rt(300, df = 5))
>>  abline(0, 1, col="red")
>>
>> I am open to education if that assumption is too
>> simplistic, but you have not offered anything in the way of
>> a counter-example.
>>
>> >
>> ==
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] about the cox result

2009-11-03 Thread Yihui Xie
coef(summary(fit_cox)) should give you what you wanted.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Nov 3, 2009 at 12:31 AM, 孟欣  wrote:
> Hi all:
> I finished cox analysis like this:
> fit_cox<-coxph(Surv(dat$Time, dat$death) ~ dat$CD4 + 
> strata(dat$gender),data=dat);
>> fit_cox
> Call:
> coxph(formula = Surv(data_ori$Time, data_ori$death) ~ data_ori$drug +
>    strata(data_ori$gender), data = data_ori)
>
>                  coef exp(coef) se(coef)    z    p
> data_ori$drugddI 0.216      1.24    0.146 1.47 0.14
> Likelihood ratio test=2.17  on 1 df, p=0.140  n= 467
>
> I wanna extract the result:
> 0.216      1.24    0.146 1.47 0.14 and the corresponding name "coef exp(coef) 
> se(coef)    z    p"
> from fit_cox.
>
> I use the command:
> str(fit_cox),but I can only find 0.216 of the result,but the other four 
> results( 1.24    0.146 1.47 0.14) can't be found.
>
>
> Anyone can help me?
> Thanks a lot!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Rpad and R 2.10.0

2009-11-07 Thread Yihui Xie
Yes I noticed the same problem since R 2.10.0, and I don't know why
either. Let's forward the email to the maintainer.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2009/11/7 Erich Neuwirth :
> I have problems with Rpad and R 2.10.0 (Windows XP and Windows 7,
> browser is Firefox)
>
> Just starting Rpad by
> library(Rpad)
> Rpad()
>
> opens the browser and displays the
> .html files and the .Rpad files in my home directory, but these
> files do not have links and are not clickable.
>
> Doing the same in R 2.9.2 gives clickable links in the browser.
>
> Furthermore, in both cases an empty graphics window opens.
>
> Has anybody else similar experiences?
> Can anybody offer advice?
>
>
>
>
> --
> Erich Neuwirth, University of Vienna
> Faculty of Computer Science
> Computer Supported Didactics Working Group
> Visit our SunSITE at http://sunsite.univie.ac.at
> Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] deparse() and the 'else' statement

2009-11-09 Thread Yihui Xie
Hi all,

It is recommended in ?'if' that we use 'else' right after '}' instead
of starting a new line, but I noticed deparse() will separate '}' and
'else' when the 'if...else' clause is used inside {...} (e.g. function
body). Here is an example:

## if/else inside {}
> cat(deparse(parse(text='function(){if (TRUE) {1} else {2}}')), sep='\n')
structure(expression(function() {
if (TRUE) {
1
}
else {
2
}
}), srcfile = )
## no {}
> cat(deparse(parse(text='if (TRUE) {1} else {2}')), sep='\n')
structure(expression(if (TRUE) {
1
} else {
2
}), srcfile = )

I wonder if there is a way to let 'else' stay with '}' when deparsing
the expression. Thanks!

> sessionInfo()
R version 2.10.0 (2009-10-26)
i386-pc-mingw32

locale:
[1] LC_COLLATE=Chinese_People's Republic of China.936
[2] LC_CTYPE=Chinese_People's Republic of China.936
[3] LC_MONETARY=Chinese_People's Republic of China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese_People's Republic of China.936

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] animation_1.0-8 MASS_7.3-3

loaded via a namespace (and not attached):
[1] tools_2.10.0

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Rpad and R 2.10.0

2009-11-12 Thread Yihui Xie
Good job, Jeff! I've downloaded the source package, modified
HTMLargs() as you suggested and recompiled the package. Rpad works
perfectly now!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2009/11/12 Jeffrey Dick :
> Hi Erich and Yihui,
>
> I saw your posts on the R-help mailing list about Rpad and R-2.10.0. I
> had the same problem and found a simple fix that I posted on the
> google code page (http://code.google.com/p/rpad/issues/detail?id=5).
>
> I'm copying Tom Short on this so he's aware of the problem. Thanks,
> Tom, for Rpad!
>
> Jeff
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] vignettes: .png graphics or pre-compiled .pdf

2009-11-13 Thread Yihui Xie
Hi Michael,

I have a dirty solution as attached to use png() for Sweave.

HTH.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA


On Fri, Nov 13, 2009 at 10:02 AM, Michael Friendly  wrote:
> In a package I'm working on there is a vignette with a number of graphs that
> result in huge .pdf files, so
> the .pdf for the vignette is around 17 Mb.  If these graphs are converted to
> .png, and the .tex file
> is compiled with pdflatex, the resulting .pdf is ~1 Mb.
>
> I'm reluctant to put the .Rnw file into the package as is, generating the
> huge .pdf for the vignette.
> I first tried installing the smaller .pdf file in the package by itself (no
> .Rnw)
> together with a file inst/doc/index.html as recommended
> in 'Writing R Extensions.'  However, when the package is installed,
> vignette() can't find it
>
>> vignette(package="Guerry")
> no vignettes found
>> vignette("MultiSpat")
> Warning message:
> vignette 'MultiSpat' *not* found
>
> Alternatively, is there a way to generate .png graphs from the .Rnw file so
> that those are used in building
> the .pdf for the package?  AFAICS, \SweaveOpts{} offers only the choices of
> eps/pdf = {TRUE/FALSE}.
>
> -Michael
>
> --
> Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology
> Dept.
> York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT  M3J 1P3 CANADA
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] vignettes: .png graphics or pre-compiled .pdf

2009-11-13 Thread Yihui Xie
I was reminded that the attachments were blocked by the list, so I
send these links again:

http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.Rnw
http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.r
http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.pdf

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Fri, Nov 13, 2009 at 8:31 PM, Yihui Xie  wrote:
> Hi Michael,
>
> I have a dirty solution as attached to use png() for Sweave.
>
> HTH.
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-6609 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 3211 Snedecor Hall, Ames, IA
>
>
> On Fri, Nov 13, 2009 at 10:02 AM, Michael Friendly  wrote:
>> In a package I'm working on there is a vignette with a number of graphs that
>> result in huge .pdf files, so
>> the .pdf for the vignette is around 17 Mb.  If these graphs are converted to
>> .png, and the .tex file
>> is compiled with pdflatex, the resulting .pdf is ~1 Mb.
>>
>> I'm reluctant to put the .Rnw file into the package as is, generating the
>> huge .pdf for the vignette.
>> I first tried installing the smaller .pdf file in the package by itself (no
>> .Rnw)
>> together with a file inst/doc/index.html as recommended
>> in 'Writing R Extensions.'  However, when the package is installed,
>> vignette() can't find it
>>
>>> vignette(package="Guerry")
>> no vignettes found
>>> vignette("MultiSpat")
>> Warning message:
>> vignette 'MultiSpat' *not* found
>>
>> Alternatively, is there a way to generate .png graphs from the .Rnw file so
>> that those are used in building
>> the .pdf for the package?  AFAICS, \SweaveOpts{} offers only the choices of
>> eps/pdf = {TRUE/FALSE}.
>>
>> -Michael
>>
>> --
>> Michael Friendly     Email: friendly AT yorku DOT ca Professor, Psychology
>> Dept.
>> York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
>> 4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
>> Toronto, ONT  M3J 1P3 CANADA
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Silently loading an R package.

2009-11-13 Thread Yihui Xie
please read the 'Details' section of ?require

 To suppress messages during the loading of packages use
 'suppressPackageStartupMessages': this will suppress all messages
 from R itself but not necessarily all those from package authors.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Fri, Nov 13, 2009 at 6:02 PM, Guillaume Yziquel
 wrote:
> Hello.
>
> I've been working an a binding between OCaml and R (i.e. calling R from
> OCaml, mostly). See below for a taste of it.
>
> I'm currently wondering how to load a given R package silently. I tried
>
>        require(xts, quietly = TRUE)
>
> but I still get some ugly output. Is it possible to squeeze off this output
> on stdout?
>
> All the best,
>
> Guillaume Yziquel.
>
>
>> yziq...@seldon:~$ ocaml-batteries        Objective Caml version 3.11.1
>>
>>      _
>>     |       | |                       |
>>    [| +     | | Batteries Included  - |
>>     |___|_|___|
>>      _
>>     |                       | |       |
>>     | -    Type '#help;;'   | |     + |]
>>     |___|_|___|
>>
>>
>> # #require "R.interpreter";;
>> # R.sexp "require(xts)";;
>> Le chargement a nécessité le package : xts
>> Le chargement a nécessité le package : zoo
>>
>> Attachement du package : 'zoo'
>>
>>
>>        The following object(s) are masked from package:base :
>>
>>         as.Date.numeric
>> xts now requires a valid TZ variable to be set
>>  no TZ var is set, setting to TZ=GMT
>> - : R.sexp = 
>> #
>
> --
>     Guillaume Yziquel
> http://yziquel.homelinux.org/
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] vignettes: .png graphics or pre-compiled .pdf

2009-11-14 Thread Yihui Xie
Yes, I also wish Sweave could give us more flexible options, e.g. it
should not be difficult to free the graphics device specification as
an R function (pdf, png, CairoPDF, ...) instead of just letting us set
pdf=T/F and eps=T/F.

If we don't want to hack the Sweave code, we may also rewrite it as a
package. This has been in my mind for a long time.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



2009/11/14 Michael Friendly :
> Thanks, Yihui
> Your solution, for png(), only looks dirty because you had to hack the Sweave 
> code.
> It would be nice to have png() support included directly.
>
> Yihui Xie wrote:
>>
>> I was reminded that the attachments were blocked by the list, so I
>> send these links again:
>>
>> http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.Rnw
>> http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.r
>> http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.pdf
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Phone: 515-294-6609 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 3211 Snedecor Hall, Ames, IA
>>
>>
>>
>> On Fri, Nov 13, 2009 at 8:31 PM, Yihui Xie  wrote:
>>
>>>
>>> Hi Michael,
>>>
>>> I have a dirty solution as attached to use png() for Sweave.
>>>
>>> HTH.
>>>
>>> Regards,
>>> Yihui
>>> --
>>> Yihui Xie 
>>> Phone: 515-294-6609 Web: http://yihui.name
>>> Department of Statistics, Iowa State University
>>> 3211 Snedecor Hall, Ames, IA
>>>
>>>
>>> On Fri, Nov 13, 2009 at 10:02 AM, Michael Friendly  
>>> wrote:
>>>
>>>>
>>>> In a package I'm working on there is a vignette with a number of graphs 
>>>> that
>>>> result in huge .pdf files, so
>>>> the .pdf for the vignette is around 17 Mb.  If these graphs are converted 
>>>> to
>>>> .png, and the .tex file
>>>> is compiled with pdflatex, the resulting .pdf is ~1 Mb.
>>>>
>>>> I'm reluctant to put the .Rnw file into the package as is, generating the
>>>> huge .pdf for the vignette.
>>>> I first tried installing the smaller .pdf file in the package by itself (no
>>>> .Rnw)
>>>> together with a file inst/doc/index.html as recommended
>>>> in 'Writing R Extensions.'  However, when the package is installed,
>>>> vignette() can't find it
>>>>
>>>>
>>>>>
>>>>> vignette(package="Guerry")
>>>>>
>>>>
>>>> no vignettes found
>>>>
>>>>>
>>>>> vignette("MultiSpat")
>>>>>
>>>>
>>>> Warning message:
>>>> vignette 'MultiSpat' *not* found
>>>>
>>>> Alternatively, is there a way to generate .png graphs from the .Rnw file so
>>>> that those are used in building
>>>> the .pdf for the package?  AFAICS, \SweaveOpts{} offers only the choices of
>>>> eps/pdf = {TRUE/FALSE}.
>>>>
>>>> -Michael
>>>>
>>>> --
>>>> Michael Friendly     Email: friendly AT yorku DOT ca Professor, Psychology
>>>> Dept.
>>>> York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
>>>> 4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
>>>> Toronto, ONT  M3J 1P3 CANADA
>>>>
>>>> __
>>>> R-help@r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide 
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>>
>>
>>
>
>
> --
> Michael Friendly     Email: frien...@yorku.ca Professor, Psychology Dept.
> York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT  M3J 1P3 CANADA
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to extract the variable names from a formula

2009-11-19 Thread Yihui Xie
Hi all,

Suppose I have a formula: a = log(y) ~ x1 + I(x2^2)

How can I extract the original variable names 'y', 'x1', 'x2' from
this formula? Thanks a lot!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to remove R banner?

2009-12-02 Thread Yihui Xie
Rgui (Windows) does support '--quiet'.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Dec 1, 2009 at 11:17 PM, Sharpie  wrote:
>
>
> Peng Yu wrote:
>>
>> I always see a banner like the following, which is annoying. I'm
>> wondering how to disable it.
>>
>> R version 2.7.1 (2008-06-23)
>> Copyright (C) 2008 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>>   Natural language support but running in an English locale
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>
> Launch R from the command line and specify the --quiet flag:
>
>  R --quiet
>
> I'm not sure if this functionality can be invoked using the GUI versions.
>
> -Charlie

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Announcement: the 2nd Chinese R Conference

2009-12-02 Thread Yihui Xie
Hi useRs,

We are happy to announce that "the 2nd Chinese R Conference" is to be
held on Dec 5 - 6 in Beijing (Renmin University of China) and Dec 12
-13 in Shanghai (East China Normal University). Although the
registration has been turned off now and we have got more participants
than we expected, we still welcome more useRs to attend the conference
(free of charge but might be crowded).

Here is a rough list of topics to be covered on the conference:

- R and WinBUGS
- spatial statistics
- statistical graphics and visualization
- embedding R into other applications
- econometrics
- security issues
- biology
- nonparametric and robust statistics
- spectral analysis
- gray models
- data mining
- market analysis
- geological and environmental statistics
- web applications
- automated reporting
- psychology
- applications in food industry
- survival analysis
- applications in semiconductor industry
- Java programming with R
- social network analysis
- writing R extensions

For more details, please visit: http://cos.name/useR/useR-2009/

Thanks!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Thu, Oct 29, 2009 at 3:26 PM, Yihui Xie  wrote:
> Hi everyone,
>
> Sorry for the so late announcement: we are organizing the 2nd Chinese
> R Conference now following the one held last year in Beijing (see
> "Conference Review: The 1st Chinese R Conference". The R Journal.
> Vol1/1. P69.) The conference will be focused on:
>
>  * introducing and popularizing R as a powerful tool for statistical
> computation and graphics in China;
>  * gathering Chinese R users and promoting communication between
> different disciplines and industries;
>
> For Chinese useRs and English speakeRs who will be in Beijing in
> November or December, please feel free to participate and we will be
> grateful if talks can be contributed at the conference. The conference
> will be mainly in Chinese but English talks are also welcome.
>
> There will be two successive sessions at two difference locations:
> Beijing (Renmin University of China) and Shanghai (East China Normal
> University). There is no registration fee for the Beijing session
> (thanks to the support from the School of Statistics, Renmin
> University), and we will try our best to cover the conference fee for
> the Shanghai session. So the conference is basically free (as in
> beer).
>
> The dates for the sessions are still to be determined (sorry again for
> the hasty organization), but the probability of holding this
> conference in December is greater than .95.
>
> Please visit the following page (in Chinese) for further information:
>
> http://cos.name/useR/useR-2009/
>
> Beijing useRs please contact user-2009...@cos.name for registration,
> and Shanghai useRs: user-2009...@cos.name
>
> Thanks!
>
> P.S. we hope the next conference will be better prepared; please
> contact user-2...@cos.name if you have any suggestions on the 3rd
> Chinese R Conference.
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-6609 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 3211 Snedecor Hall, Ames, IA
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] animated R plots

2009-12-23 Thread Yihui Xie
Hi,

saveSWF() (and other save*() functions) will only record the plots by
*high-level* plotting commands, and this is because most graphics
devices can only record high-level plots by default. In your animation
code, there is actually one plot generated, and the rest are produced
by low-level plotting commands like text() and points() - they will
not get recorded. So you have to draw the whole plot again by
plot(...) inside the loop. Here is a simple example:

x = runif(10)
y = runif(10)

# you can see the animation in the graphics window
# but only one image file is generated at last
plot(0:1, 0:1)
for (i in 1:10) {
points(x[i], y[i])
Sys.sleep(0.1)
}

# this is equivalent to the above animation
# but 10 image frames are generated in the end
for (i in 1:10) {
plot(0:1, 0:1)
points(x[1:i], y[1:i])
Sys.sleep(0.1)
}

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Wed, Dec 23, 2009 at 9:59 AM, Zd Gibbs  wrote:
>  Hi,
> I want to be able to save the following animated plot as a flash.  There are 
> ultimately 6 plots, but when I run this and save it as a flash all I get is 
> the last (6th) plot, not all six different plots in order by "year".  I’ve 
> tested the flash commands and they work; so it has to be my function code. I 
> am guessing that the problem has something to do with overlaying the plot 
> points, but I don’t know how to rewrite it and keep the animated elements.
> I am running R version 2..9.2 on Windows Vista.
>
> Data looks like this:
>
> service usage amount year
> transport 11.33105 15.75016 2004
> transport 11.38398 15.82374 2005
> transport 11.44057 15.90239 2005
>
> Thanks!
>
> ZdGibbs (I can provide a subset of the data as .txt if necessary).
>
> #order service year in ascending order and set frame options
> library(animation)
> library(lattice)
> service <- service[order(service$year), ]
> oopt = ani.options(interval = 1.0)
>
> # create the function
>
> Service <- function (...)
>      {
>
> interval = ani.options("interval")
> index <- unique(service$year)
>
> plot(amount~usage, data=service, type="n", xlab = " ", ylab = " ", bty="l", 
> ylim=c(0,500))
>
> legend("topright", legend=c("Transport", "Family", "Housing", "Substance 
> Use", "Medical", "Mental Health"), pch=c(19,19,19,19,19,19), col=c("#7FC97F", 
> "#BEAED4", "#FDC086", "#99", "#386CB0", "#F0027F"), bty="n", inset=.02)
>
> for (i in 1:length(index)) {
> rect(11.4, 425, 11.9, 500, col="white", border="red")
>
> year.service <- service[which(service$year==index[i]),]
>
> graphics <- year.service[year.service$service=="Graphics",]
>
>   trans <- year.service[year.service$service=="transport",]
>   fam <- year.service[year.service$service=="family",]
>   hous <- year.service[year.service$service=="housing",]
>   subuse <- year.service[year.service$service=="subuse",]
>   med <- year.service[year.service$service=="genhealth",]
>   menhlth <- year.service[year.service$service=="mental health",]
>
> text(mean(range(service$usage, na.rm=TRUE)), 455, index[i], col = rgb(0, 0, 
> 0, 0.5), cex = 4)
> points(amount~usage, data=trans, pch=19, col="#7FC97F")
> points(amount~usage, data=fam, pch=19, col="#BEAED4")
> points(amount~usage, data=hous, pch=19, col="#FDC086")
> points(amount~usage, data=subuse, pch=19, col="#99")
> points(amount~usage, data=med, pch=19, col="#386CB0")
> points(amount~usage, data=menhlth, pch=19, col="#F0027F")
>
>     Sys.sleep(interval)
>
> }
>
> }
> #run animation
> Service()
>
> #save as flash
> oopt = ani.options(nmax = 6, interval = 1.0)
> saveSWF(Service(), interval = 2.0, swfname="place.swf", dev = "pdf", 
> filename="Pplot", fmt = "%03d", outdir = getwd(), swftools="C:/Program 
> Files/SWFTools")
> ani.options(oopt)
>
>
>
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] An unprofessional message

2009-12-24 Thread Yihui Xie
As a useR, you'd better present this message in a more professional
way :) Let's see Christmas shining in R:

n = length(speed <- runif(angle <- runif(x <- strsplit("MERRY
CHRISTMAS", "")[[1]], 0, 360), 0, 15))
x11(10, 3)
par(mar = rep(0, 4), bg = "black")
for (j in 1:1000) {
angle = angle + speed
plot.new()
plot.window(c(1, n), c(0, 1))
for (i in 1:n) text(i, 0.5, x[i], srt = angle[i], cex = runif(1,
1, 4), col = sample(colors(), 1))
    Sys.sleep(0.02)
}


Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Thu, Dec 24, 2009 at 5:18 AM, Maithili Shiva
 wrote:
> Dear R helpers,
>
> I understand that this is absolutely unprofessional on my part and this group 
> doesn't entertain such things. I have been associted with this group 
> since last 1 and half years and have been immensely benefited by the noble 
> service rendred by many R helpers.
>
> So I take this opportunity to thank all of you and wish you all
>
> "MERRY CHRISTMAS".
>
> I sincerely apologize for using this platform for writing such an 
> unprofessional message and especially when I am aware that nobody has ever 
> done such thing but I really mean it.
>
> Warm Regards
>
> Maithili
>
>
>
>
>      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] An unprofessional message

2009-12-24 Thread Yihui Xie
I have wrapped it into a Flash animation, so we can really see it now:
http://yihui.name/en/2009/12/merry-christmas-using-r/

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Thu, Dec 24, 2009 at 12:36 PM, Yihui Xie  wrote:
> As a useR, you'd better present this message in a more professional
> way :) Let's see Christmas shining in R:
>
> n = length(speed <- runif(angle <- runif(x <- strsplit("MERRY
> CHRISTMAS", "")[[1]], 0, 360), 0, 15))
> x11(10, 3)
> par(mar = rep(0, 4), bg = "black")
> for (j in 1:1000) {
>    angle = angle + speed
>    plot.new()
>    plot.window(c(1, n), c(0, 1))
>    for (i in 1:n) text(i, 0.5, x[i], srt = angle[i], cex = runif(1,
> 1, 4), col = sample(colors(), 1))
>    Sys.sleep(0.02)
> }
>
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-6609 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 3211 Snedecor Hall, Ames, IA
>
>
>
> On Thu, Dec 24, 2009 at 5:18 AM, Maithili Shiva
>  wrote:
>> Dear R helpers,
>>
>> I understand that this is absolutely unprofessional on my part and this 
>> group doesn't entertain such things. I have been associted with this group 
>> since last 1 and half years and have been immensely benefited by the noble 
>> service rendred by many R helpers.
>>
>> So I take this opportunity to thank all of you and wish you all
>>
>> "MERRY CHRISTMAS".
>>
>> I sincerely apologize for using this platform for writing such an 
>> unprofessional message and especially when I am aware that nobody has ever 
>> done such thing but I really mean it.
>>
>> Warm Regards
>>
>> Maithili
>>
>>
>>
>>
>>      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
>>        [[alternative HTML version deleted]]
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] I'm offering $300 for someone who know R-programming to do the assignments for me.

2009-05-07 Thread Yihui Xie
Homework?...

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Fri, May 8, 2009 at 12:19 PM, ayaku1...@gmail.com
 wrote:
> There are six assignments in total. It won't take you long if you were
> familiar with R. For those who are interested, please send me an email
> with your profile (your experience with R, how long and how often have
> you been using it.) I will be paying through paypal. Thanks!
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to generate pdf in more than 1 papes

2009-05-11 Thread Yihui Xie
pdf() WILL draw all graphs in a single pdf file by default (onefile = TRUE)

# you didn't tell us your R version
> R.version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  9.0
year   2009
month  04
day17
svn rev48333
language   R
version.string R version 2.9.0 (2009-04-17)
> pdf()
> for(i in 1:10)plot(rnorm(10))
> dev.off()
null device
  1
# see Rplots.pdf under getwd()
# 10 pages in one file instead of single pages in 10 files

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Tue, May 12, 2009 at 1:14 PM, Xiaogang Yang  wrote:
> I have a problem,
> everytime I plot in pdf, I could only draw in one page,
> does anyone know how to generate more than one page
>  for example, I have 10 pics to plot in pdf, each page only could be plotted
> 5 pics,
>  so how can I generate just one pdf of 2 pages, instead of two pdf
>
>
> Thank you
> --
> Xiaogang Yang
> Sensorweb Research Laboratory
> http://sensorweb.vancouver.wsu.edu/
> Washington State University Vancouver
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] graphically representing frequency of words in a speech?

2009-06-10 Thread Yihui Xie
Hi,

As Gregor Gorjanc mentioned, it's very inconvenient to let R decide
the fontsize and placement of words in a plot. There have already been
very mature applications of tag cloud; one of them I'm relatively
familiar is the WordPress plugin "wp-cumulus", which makes use of a
Flash object to generate tag cloud, and it has fantastic 3D rotation
effect of the cloud. I've spent a couple of hours porting it into R;
see the source code and effect here:

http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/

HTH.

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Mon, Jun 8, 2009 at 2:41 AM, Brown, Tony
Nicholas wrote:
> Dear all,
>
>
>
> I recently saw a graph on television that displayed selected
> words/phrases in a speech scaled in size according to their frequency.
> So words/phrases that were often used appeared large and words that were
> rarely used appeared small. The closest thing I can find on the web to
> approximate what I saw can be found here:
> http://stateoftheunion.onetwothree.net/ The example at that website is
> more complicated but captures the general idea.
>
>
>
> Would someone point me in the right direction in terms of replicating
> such a graph.
>
>
>
> Thanks in advance,
>
> Tony
>
>
>
> 
> -
>
> Tony N. Brown, Ph.D.
>
> Editor-Elect, American Sociological Review
>
> Associate Professor of Sociology and Human and Organizational
> Development (secondary)
>
> Program Faculty, Effective Health Communication and African American &
> Diaspora Studies
>
> Faculty Head of Hank Ingram House, The Commons
>
> Vanderbilt University
>
> (615) 322-7518
>
> (615) 322-7505 fax
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to get commands history as a character vector instead of displaying them?

2009-03-23 Thread Yihui Xie
Hi Everyone,

I want to get the commands history as a character vector instead of
just displaying them, but the function history() just returns NULL. I
checked the source code of 'history' and could not find a solution.
Anybody has an idea? Thanks!

P. S. My original problem is, when a user opens a graphics device like
png() or pdf(), I want to know the file name used by this device. I
thought history() would help, but it could not.

> sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese_People's Republic of
China.936;LC_CTYPE=Chinese_People's Republic of
China.936;LC_MONETARY=Chinese_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese_People's Republic of China.936

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton method

2009-03-23 Thread Yihui Xie
I'm not sure what you meant by "a topic on newton's method"
(algorithm? demo?), but the demonstration in the package 'animation'
might help:

install.packages('animation')
par(pch = 20)
ani.options(nmax = 50)
newton.method(function(x) 5 * x^3 - 7 * x^2 - 40 *
x + 100, 7.15, c(-6.2, 7.1))

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Mon, Mar 23, 2009 at 11:15 AM, Roslina Zakaria  wrote:
>
> Hi R-users,
>
> Does R has a topic on newton's method?
>
> Thank you for the info.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to get commands history as a character vector instead of displaying them?

2009-03-30 Thread Yihui Xie
Thanks, Wacek and Romain! Your solutions worked very well in RGui and
Rterm in interactive mode.

My final purpose was to obtain the file name of the postscript device
in Rweb (http://pbil.univ-lyon1.fr/Rweb/); now I found savehistory()
would not work because Rweb was non-interactive. I didn't realize it
until I try(savehistory()) and got an error message.

Now I found a solution by myself: we can list the *.ps files and pick
the most recently created (modified, visited, ...) one, e.g.

x = file.info(list.files(pattern = ".*\\.ps$"))
x = x[order(x$atime), ]
rownames(x)[nrow(x)]

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Mon, Mar 23, 2009 at 6:13 PM, Wacek Kusnierczyk
 wrote:
> Romain Francois wrote:
>> Yihui Xie wrote:
>>> Hi Everyone,
>>>
>>> I want to get the commands history as a character vector instead of
>>> just displaying them, but the function history() just returns NULL. I
>>> checked the source code of 'history' and could not find a solution.
>>> Anybody has an idea? Thanks!
>>>
>> history eventually calls file.show, which will use the pager option to
>> determine how to show the file, so you can do something like that:
>>
>> history <- function( ... ){
>> old.op <- options( pager = function( files, header, title, delete.file
>> ) readLines( files ) ); on.exit( options( old.op ) )
>> utils::history(...)
>> }
>> history( pattern = "png" )
>
> i think the following is an acceptable alternative:
>
>    history = function() {
>       file = tempfile()
>       on.exit(unlink(file))
>       savehistory(file)
>       readLines(file) }
>
> the output is *lines* of text, but if you need whole executable
> expressions, you can parse the output:
>
>    1 + 1
>    ph = parse(text=history())
>    as.list(ph)
>    ph[length(ph)-1]
>    # expression(1 + 1)
>    eval(ph[length(ph)-1])
>    # [1] 2
>
>
> vQ
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] new line between '}' and 'else' in function body

2009-04-02 Thread Yihui Xie
Hi list members,

?"else" tells us

 In particular, you should not have a newline between '}' and
 'else' to avoid a syntax error in entering a 'if ... else'
 construct at the keyboard or via 'source'.

but there's no syntax error when you break the line between "}" and
"else" in a function, e.g.

f = function(x) {
if (x) {
1
} # a new line here!
else {
2
}
}

> f(TRUE)
[1] 1
> f(FALSE)
[1] 2

Seems strange...

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] extract tables as data.frames from HTML source

2009-04-02 Thread Yihui Xie
Hi,

I wonder whether there is any convenient function (or package) to
extract tables from a HTML page? e.g. from
http://www.google.com/finance/historical?q=SHE:002251

I know we can readLines('URL'), gsub('...', '...', source), ...
and at last get the numbers; I'm writing to ask whether someone has
already contributed a more general function (with the package XML or
other packages). Thanks!

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] new line between '}' and 'else' in function body

2009-04-03 Thread Yihui Xie
Thanks, Romain! So I think, for consistency, the following result

> deparse(parse(text = '
+ f = function(x) {
+if (x) {
+1
+} # a new line here!
+else {
+2
+}
+ }
+ ')
+ )
[1] "structure(expression(f = function(x) {" "if (x) {"
[3] "1"  "}"
[5] "else {" "2"
[7] "}"  "}), srcfile =
)"

should be

[1] "structure(expression(f = function(x) {" "if (x) {"
[3] "1"  "} else {"
[5] "2" "}"
[7] "}), srcfile = )"

instead.

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Fri, Apr 3, 2009 at 2:48 PM, Romain Francois
 wrote:
> Hi,
>
> That's because the parser knows how to deal with that stuff. However, when
> you type the same if/else at the command line, it will be parsed line by
> line, and the evaluator will not wait for the else to evaluate the if. Try
> to copy and paste your if/else to the command line.
>
> Romain
>
>
> Yihui Xie wrote:
>>
>> Hi list members,
>>
>> ?"else" tells us
>>
>>     In particular, you should not have a newline between '}' and
>>     'else' to avoid a syntax error in entering a 'if ... else'
>>     construct at the keyboard or via 'source'.
>>
>> but there's no syntax error when you break the line between "}" and
>> "else" in a function, e.g.
>>
>> f = function(x) {
>>    if (x) {
>>        1
>>    } # a new line here!
>>    else {
>>        2
>>    }
>> }
>>
>>
>>>
>>> f(TRUE)
>>>
>>
>> [1] 1
>>
>>>
>>> f(FALSE)
>>>
>>
>> [1] 2
>>
>> Seems strange...
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
>> Mobile: +86-15810805877
>> Homepage: http://www.yihui.name
>> School of Statistics, Room 1037, Mingde Main Building,
>> Renmin University of China, Beijing, 100872, China
>>
>
>
> --
> Romain Francois
> Independent R Consultant
> +33(0) 6 28 91 30 30
> http://romainfrancois.blog.free.fr
>
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dynamic visualisation of R data using Adobe FLEX

2009-05-02 Thread Yihui Xie
Hi Harsh,

If your project is so specific on the regression model, my suggestion
is to use tcl/tk or Gtk2 interface instead of FLEX, because your
requirement on interaction is simple (e.g. you don't need to
drag-and-drop points).

I think the example 'run.cor2.examp()' in 'TeachingDemos' package can
give you enough inspiration.

Or if you want to do the job (to change the slope) automatically, you
may want to see the example in the 'animation' package:

##
install.packages("animation")
library(animation)

# default animation in R: with slope changing
least.squares()

# animation in an HTML page
oopt = ani.options(ani.height = 450, ani.width = 600,
outdir = tempdir(), nmax = 50, title = "Demonstration of Least Squares",
description = "We want to find an estimate for the slope
 in 50 candidate slopes, so we just compute the RSS one by one. ")
ani.start()
par(mar = c(4, 4, 0.5, 0.1), mgp = c(2, 0.5, 0), tcl = -0.3)
least.squares()
ani.stop()
ani.options(oopt)
##

P. S. I'm quite interested in interactive visualization using R and
Flash (you may also want to know Flare and SWF Tools!), so please let
me know if there's any progress in your project.

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Thu, Apr 30, 2009 at 2:54 AM, Harsh  wrote:
> Hi useRs,
>
> I had posted about Adobe FLEX talking to R for rich visualisation.
> Reply from Jeffery Horner contained links to the
> revolution-computing.com webpage which had information pertaining to
> the Bay Users R group Meetup on Web Dashboards with R.
>
> I have a very specific project that I need to implement.
> I wish to use the graphics capabilities provided by Adobe FLEX to
> visualise outputs from R.
> For example:
> I would like to fit a regression model to a dataset in R and provide a
> FLEX interface wherein, a user may manipulate a slider which would
> increase or decrease
> a parameter estimate (between the confidence intervals of the
> estimate) of a variable to see the effect on the predicted values.
>
> I necessarily have to use FLEX for the interface.
> In trying to make sense of how to go about this task, I have
> speculated on the following technologies:
> 1) Using RSOAP which requires a Python client. I am not sure how I can
> implement this in Flex.
> 2) Using RSOAP provided by the Biocep project. This is a java
> implementation and maybe this would suit my requirements.
> 3) The StatDataML package in R provides the creation of xml files of R
> objects. Maybe I can use these XML files as encapsulators of R object
> data and pass it on to FLEX.
> 4) Since R has interfaces that connect to most SQL database servers, I
> can convert results of lm objects (summary(lmobject)) to data frames
> and push them into the SQL database. FLEX can
> then read the table and extract the relevant fields for output.
>
> I am aware that I not a computer programmer which is why I may not be
> making a whole lot of sense in describing the above scenarios, but I
> am trying to gain as much information and programming skills to
> 'decipher'
> the secret behind using FLEX and R.
>
> I have looked at Jeffery Horner's  BBPLOT project
> (http://data.vanderbilt.edu/rapache/bbplot) and honestly I'm amazed.
> Replicating this with a FLEX interface is the closest I can get in
> describing my requirements.
>
> Any information/technical sources/tutorials etc in this regard will be
> much appreciated.
>
> Thank you for your time.
>
> Regards
> Harsh Singhal
> Decision Systems
> Mu Sigma Inc.
> Chicago, IL
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Is SEM package of R suitable for sem analysis

2009-12-27 Thread Yihui Xie
Well, I guess it will be extremely difficult to persuade your teacher
to use the sem package in R. AFAIK, AMOS and LISREL have become the
golden standard for SEM in China, and SEM has become a golden model
for analysis in social science and psychology. I have been a cynic to
SEM for a long time, because I strongly believe this model has been
completely abused, and perhaps the "easy-to-use" AMOS has been helping
people abuse SEM. A common phenomenon I see is, people do not care
about the model at all - all they care about is whether AMOS can
successfully compute the coefficients; if AMOS failed, they will try
to (randomly) set constraints to the model, i.e. add/remove this
arrow, drag some variables into/out of the model, set this
coefficient/variance to 1.

Anyway, I encourage you to ask your teacher why AMOS is "more
suitable". I have a couple of very ridiculous stories about the SEM
software, in which I can only feel the blind faith in software.
Sigh...

The good thing is, R is open source, so is the sem package. You can
see everything in it, and you can extend it as you wish (in case your
teacher think it is less suitable).

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Sat, Dec 26, 2009 at 8:26 PM, Reeyarn_李智洋_10928113  wrote:
> Dear Bruno and Joe,
>
> Thanks for advising!
>
>
> Reeyarn
>
> On Sat, Dec 26, 2009 at 9:32 PM, Bruno Falissard  
> wrote:
>
>> A few years ago it could have been true, but now the package has improved
>> (especially with the bootstrap procedure).
>> At the moment there is no argument to recommend AMOS.
>
> On Sun, Dec 27, 2009 at 12:30 AM, Joe King  wrote:
>
>> I am going to take SEM this next quarter in my doctoral program. My
>> suggestion is to use the program your professor suggests and try to
>> re-create your models in R using the SEM package.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problems in building R with libpng/cairo/jpeg

2009-12-27 Thread Yihui Xie
Hi,

I'm installing R 2.10.1 under Linux but I don't know why my
installation does not support png/cairo/jpeg:

> capabilities()
jpeg  png tifftcltk  X11 aqua http/ftp  sockets
   FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE
  libxml fifo   clediticonv  NLS  profmemcairo
TRUE TRUE TRUE TRUE TRUEFALSEFALSE

Here is some system information:

*...@*** [~]# uname -srvmo
Linux 2.6.28-10.7.intel.IGB.BHsmp #1 SMP Thu Aug 13 21:52:24 MDT 2009
x86_64 GNU/Linux

*...@*** [~]# rpm -qa | grep -E 'libpng|cairo|pango|libjpeg'
libjpeg-devel-6b-37
libjpeg-6b-37
pycairo-1.2.0-1.1
libpng-devel-1.2.10-7.1.el5_3.2
pango-1.14.9-6.el5.centos
cairo-1.2.4-5.el5
libjpeg-devel-6b-37
libpng-1.2.10-7.1.el5_3.2
libpng-1.2.10-7.1.el5_3.2
pango-1.14.9-6.el5.centos
cairo-devel-1.2.4-5.el5
pango-devel-1.14.9-6.el5.centos
cairo-1.2.4-5.el5
libjpeg-6b-37
libpng-devel-1.2.10-7.1.el5_3.2

It seems that all necessary libraries have been installed, and the
configure script can find libpng and jpeglib but cannot find pango and
cairo (even using --with-cairo):

*...@*** [~/etc/R]# ./configure --prefix=$HOME/bin/R
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
loading site script './config.site'
loading build-specific script './config.site'


checking whether pkg-config knows about cairo and pango... no
checking whether pkg-config knows about cairo... no


checking if jpeglib version >= 6b... yes
checking for jpeg_destroy_compress in -ljpeg... yes
checking for main in -lz... yes
checking if libpng version >= 1.0.5... yes
checking for png_create_write_struct in -lpng... yes


R is now configured for x86_64-unknown-linux-gnu

  Source directory:  .
  Installation directory:/***/bin/R

  C compiler:gcc -std=gnu99  -g -O2
  Fortran 77 compiler:   gfortran  -g -O

  C++ compiler:  g++  -g -O2
  Fortran 90/95 compiler:gfortran -g -O
  Obj-C compiler:

  Interfaces supported:  X11
  External libraries:readline
  Additional capabilities:   PNG, JPEG, TIFF, NLS
  Options enabled:   shared BLAS, R profiling, Java

  Recommended packages:  yes

configure: WARNING: you cannot build DVI versions of the R manuals
configure: WARNING: you cannot build DVI versions of all the help pages
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of all the help pages

After I make & make install, jpeg, png and cairo are not supported.
I'm a Linux novice. Any hints for my installation? Thanks!

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] rmarkdown and source call to R file.

2021-01-22 Thread Yihui Xie
I don't know the answer (there are multiple possible reasons for the
file not being found), but as the first step to debug the problem, you
may replace this chunk

```{r, echo=FALSE}
   library(knitr)
   source("helper.R", local = knitr::knit_global())
   summarized_table<-give_table(params$ldf_summary)
   kable(summarized_table,"simple")
```

with

```{r}
getwd()
list.files()
```

and see what the working directory is, and which files are available.

Regards,
Yihui


On Fri, Jan 22, 2021 at 1:02 AM Georgios via R-help
 wrote:
>
> Hi!
> I'm new in R and this list.
> I made a shiny app using R studio.
> my files are:
>-server.R
>-ui.R
>-helper.R
>-Report.Rmd.
>
> All the files are on the same directory and helper.R is a file that
> contains a lot of functions used in Report.Rmd and server.R
>
> for some reason I cant call from Report.Rmd the file helper.R
>
> My code in Report.Rmd is
>
>## Summarize table
>```{r, echo=FALSE}
>library(knitr)
>source("helper.R", local = knitr::knit_global())
>summarized_table<-give_table(params$ldf_summary)
>kable(summarized_table,"simple")
>```
> If I use absolute path it works but since I want to upload it to
> https://www.shinyapps.io/ I must make it work with relative path.
>
> The message I get is:
>
>processing file: Report.Rmd
>
>|..
> |  25%
>  ordinary text without R code
>
>
>|
> |  50%
>label: unnamed-chunk-1 (with options)
>List of 1
> $ echo: logi FALSE
>
>Quitting from lines 13-17 (Report.Rmd)
>
>Warning: Error in file: cannot open the connection
>  [No stack trace available]
>
>
> The funny thing is that if I put the cursor inside "" at the beginning
> and I press tab I get the option to choose helper.R. So Im guessing
> that I'm on the right directory.
> Any ideas what I'm missing?
>
> I'm stuck on this lines of code 2 days now.
> I would really appreciate
> any ideas.
>
>
> Thanks in advance for your help!!!
>
>
> ps. I tried all the combinations in Tools->Global Options-> "Evaluate
> chunks in directory" with no luck.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problems in knitting to html

2021-04-20 Thread Yihui Xie
Could you provide a minimal reproducible example along with your
xfun::session_info('rmarkdown')? Thanks!

Regards,
Yihui
--
https://yihui.org

On Tue, Apr 20, 2021 at 11:06 AM Troels Ring  wrote:
>
> Dear friends - newly installed windows 10 and R version 4.0.5
> (2021-03-31) -- "Shake and Throw" and newest version of RStudio I tend
> to get an error when knitting to html.
>
> The message I get is ("applications-of-charge-balance-160421.rmd" is my
> file name)
>
> /output file: applications-of-charge-balance-160421.knit.md//
> /
>
> /then (in my translated Danish) //
> /
>
> /Error in file(con,   "w") : cannot open connection/
>
> /call:  ... extract_preserve_chunks -> write_utf8 ->
> writeLines -> file//
> /
>
> /In file(con, "w") ://
> //  cannot open file 'applications-of-charge-balance-160421.utf8.md':
> Invalid argument//
> //run aborted/
>
> But when I then simply try again it works well with no troubles.
>
> I wonder what error I have done?
>
> All best wishes
>
> Troels Ring,
> Aalborg, Denmark
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problems in knitting to html

2021-04-20 Thread Yihui Xie
It's hard to tell what's going on without a reproducible example.
Perhaps it was because of ant-virus software or a network drive as
Jeff guessed.

The development version of rmarkdown
(https://github.com/rstudio/rmarkdown) will no longer generate the
intermediate *.utf8.md file. I'm not sure if that would help. You may
try remotes::install_github('rstudio/rmarkdown').

Regards,
Yihui
--
https://yihui.org

On Tue, Apr 20, 2021 at 11:42 AM Troels Ring  wrote:
>
> Thanks a lot - the error is not constant so I  have not tried a minimal 
> example yet but  the info is below, thanks a lot
>
> Troels
>
> xfun::session_info('rmarkdown')
> R version 4.0.5 (2021-03-31)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 19042), RStudio 1.4.1106
>
> Locale:
>   LC_COLLATE=Danish_Denmark.1252  LC_CTYPE=Danish_Denmark.1252
> LC_MONETARY=Danish_Denmark.1252
> LC_NUMERIC=CLC_TIME=Danish_Denmark.1252
>
> Package version:
>   base64enc_0.1.3   digest_0.6.27 evaluate_0.14 glue_1.4.2
> graphics_4.0.5grDevices_4.0.5
> highr_0.8 htmltools_0.5.1.1 jsonlite_1.7.2knitr_1.31
> magrittr_2.0.1markdown_1.1
> methods_4.0.5 mime_0.10 rlang_0.4.10  rmarkdown_2.7 
> stats_4.0.5   stringi_1.5.3
> stringr_1.4.0 tinytex_0.31  tools_4.0.5   utils_4.0.5       
> xfun_0.22 yaml_2.2.1
>
> Pandoc version: 2.11.4
>
>
>
> Den 20-04-2021 kl. 18:08 skrev Yihui Xie:
>
> Could you provide a minimal reproducible example along with your
> xfun::session_info('rmarkdown')? Thanks!
>
> Regards,
> Yihui
> --
> https://yihui.org
>
> On Tue, Apr 20, 2021 at 11:06 AM Troels Ring  wrote:
>
> Dear friends - newly installed windows 10 and R version 4.0.5
> (2021-03-31) -- "Shake and Throw" and newest version of RStudio I tend
> to get an error when knitting to html.
>
> The message I get is ("applications-of-charge-balance-160421.rmd" is my
> file name)
>
> /output file: applications-of-charge-balance-160421.knit.md//
> /
>
> /then (in my translated Danish) //
> /
>
> /Error in file(con,   "w") : cannot open connection/
>
> /call:  ... extract_preserve_chunks -> write_utf8 ->
> writeLines -> file//
> /
>
> /In file(con, "w") ://
> //  cannot open file 'applications-of-charge-balance-160421.utf8.md':
> Invalid argument//
> //run aborted/
>
> But when I then simply try again it works well with no troubles.
>
> I wonder what error I have done?
>
> All best wishes
>
> Troels Ring,
> Aalborg, Denmark
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] traceback performs differently in "interactive-mode" then in "script-mode"

2022-12-21 Thread Yihui Xie
Hi Malte,

I think I asked the same question on Stack Overflow ten years ago:
https://stackoverflow.com/q/13116099/559676 I hope you'll find the answer
helpful there.

Regards,
Yihui
--
https://yihui.org


On Wed, Dec 21, 2022 at 6:19 AM Flender, Malte 
wrote:

> Hello,
>
> a few days ago I encountered a strange behavior of base R.
> I'm not really sure if it is a bug or not.
> Thus I am somewhat hesitant to write a bug report.
> Instead I write to R-Help to ask you if this behavior can be considered a
> bug or not.
> I started with a question at stackoverflow (
> https://stackoverflow.com/questions/74796994/r-traceback-performs-differently-in-interactive-mode-then-in-script-mode),
> but got no response there.
>
> The strange behavior of base R lies in how it acts differently in an
> interactive R-Session then the execution of an R-Script.
> As you see in the MWE below the traceback()-function returns NULL in
> script mode (first call) and an actual traceback in interactive mode
> (second call).
>
> Can you reproduce this behavior?
>
> Here is MWE, which contains a small test-script and the calls to it in an
> interactive and script mode:
>
> user@server:~/folder> cat test.r
>
> options(error = NULL)
>
> onexit <- function() {
> error.msg <- geterrmessage()
> traceback <- traceback()
>
> print(paste("error.msg: ", nchar(error.msg), sep = ""))
> print(paste("traceback: ", is.null(traceback), " : ", traceback, sep =
> ""))
>
> if (nchar(error.msg) != 0 && !is.null(traceback)) {
>   print("Uncaught Error")
> } else if (nchar(error.msg) != 0 && is.null(traceback)) {
>  print("Caught Error")
> } else if (nchar(error.msg) == 0 && is.null(traceback)) {
>  print("No Error")
> } else {
> stop("ERROR in on.exit: bad traceback error.msg combination")
> }
> }
>
> fail <- function() {
>   on.exit(
>   onexit(),
>   add = TRUE,
>   after = TRUE)
>
>   print("SOMETHING")
>   stop("BAD")
> }
>
> fail()
>
> user@server:~/folder> docker run -it --rm -v /home/user/folder/:/data/R/
> r-base:4.2.2 R -e 'source("/data/R/test.r")'
>
> R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
> Copyright (C) 2022 The R Foundation for Statistical Computing
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
>   Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> > source("/data/R/test.r")
> [1] "SOMETHING"
> Error in fail() : BAD
> Calls: source -> withVisible -> eval -> eval -> fail
> No traceback available
> [1] "error.msg: 75"
> [1] "traceback: TRUE : "
> [1] "Caught Error"
> Execution halted
> user@server:~/folder> docker run -it --rm -v /home/user/folder/:/data/R/
> r-base:4.2.2 R
>
> R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
> Copyright (C) 2022 The R Foundation for Statistical Computing
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
>   Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> > source("/data/R/test.r")
> [1] "SOMETHING"
> Error in fail() : BAD
> 6: stop("BAD") at test.r#30
> 5: fail() at test.r#33
> 4: eval(ei, envir)
> 3: eval(ei, envir)
> 2: withVisible(eval(ei, envir))
> 1: source("/data/R/test.r")
> [1] "error.msg: 22"
> [1] "traceback: FALSE : stop(\"BAD\")"
> [2] "traceback: FALSE : fail()"
> [3] "traceback: FALSE : eval(ei, envir)"
> [4] "traceback: FALSE : eval(ei, envir)"
> [5] "traceback: FALSE : withVisible(eval(ei, envir))"
> [6] "traceback: FALSE : source(\"/data/R/test.r\")"
> [1] "Uncaught Error"
> >
>
>
> Mit freundlichem Gruß / Best regards
> WAGO GmbH & Co. KG
>
> Malte Flender
> Komplexitätsmanagement / Data Science
> phone: +49 571 887-49779
> fax: +49 571 887-849779
> mailto: malte.flen...@wago.com
>
> WAGO GmbH & Co.KG
> Hansastraße 27
> 32423 Minden
> Deutschland
> http://www.wago.com
>
>
>
> Internal
>
>
>
>
>
>  Diese E-Mail einschließlich ihrer Anhänge ist vertraulich und daher
> allein für den Gebrauch durch den vorgesehenen Empfänger bestimmt. Dritten
> ist 

Re: [R] TOC in vignette (knitr::rmarkdown)

2019-08-26 Thread Yihui Xie
output:
  rmarkdown::html_vignette:
toc: true

The syntax is the same for all R Markdown output formats:
https://bookdown.org/yihui/rmarkdown/html-document.html#table-of-contents

Regards,
Yihui
--
https://yihui.name

On Mon, Aug 26, 2019 at 9:32 AM Helmut Schütz  wrote:
>
> Dear all,
>
> I can't figure out how to include a table of contents in a vignette.
>
> What I have now:
> ---
> title: "myPackage"
> subtitle: mySubtitle"
> author: "Me"
> date: "`r Sys.Date()`"
> output: rmarkdown::html_vignette
> vignette: >
>%\VignetteIndexEntry{replicateBE}
>%\VignetteEngine{knitr::rmarkdown}
>%\VignetteEncoding{UTF-8}
> ---
>
> ```{r, include = FALSE}
> knitr::opts_chunk$set(
>collapse = TRUE,
>comment = "#>"
> )
> ```
>
> This one works fine in my README.Rdm:
> ---
> title: "myPackage"
> output:
>github_document:
>  toc: true
>  toc_depth: 4
> ---
>
> Cheers,
> Helmut

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Double / single backticks for inline R code in an Rmarkdown file

2019-10-14 Thread Yihui Xie
params$data is "hawaii" in this case, so the output of

  ``r params$data``

is

  `hawaii`

The double backticks don't have any special meaning here. Only the
inside pair of backticks (i.e. `r `) makes sense to R Markdown (or
precisely speaking, knitr). The outside pair will be left untouched
after knitr evaluates the inline R expression `r params$data`. After
evaluation, there won't be double backticks. This has nothing to do
with the left curly double quote LaTeX. The result `hawaii` will be
converted to hawaii if the output format is HTML (or
\texttt{hawaii} if the output format is LaTeX), but the extra
backticks in the original Rmd document is completely optional. It all
depends on whether you want to place the result in a code tag or
command.

Regards,
Yihui
--
https://yihui.name

On Mon, Oct 14, 2019 at 8:42 AM Jeff Newmiller  wrote:
>
> No, you don't misunderstand. But you might want to be aware that targeting 
> PDF output uses LaTeX which regards double backticks as a method of encoding 
> a left curly double quote mark, so this error could derive from an incomplete 
> adaptation of the Rmd file for HTML output even though such a symbol doesn't 
> make sense there in PDF either.
>
> On October 14, 2019 4:35:26 AM PDT, Ashim Kapoor  
> wrote:
> >Dear All,
> >
> >I am reading this file :-
> >
> >https://rmarkdown.rstudio.com/lesson-6.html
> >
> >My query is : In line 14 of the above file, ie.
> >
> >The [marmap](https://cran.r-project.org/web/packages/marmap/index.html)
> >package provides tools and data for visualizing the ocean floor. Here
> >is an
> >example contour plot of marmap's ``r params$data`` dataset.
> >
> >Should not the phrase rparams$data be within SINGLE backticks ?
> >
> >Do I misunderstand?
> >
> >Thank you,
> >Ashim
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Markdown & chunk extraction in R

2020-04-08 Thread Yihui Xie
And please note that knitr::knit_code$get() only works (i.e. returns a
named list of code chunks) inside a knitr document when the document
_is being knitted_. It doesn't work outside the document. Ideally, you
should use the document parser of knitr, but it is not exported.

Regards,
Yihui
--
https://yihui.org

On Wed, Apr 8, 2020 at 2:54 AM Ashim Kapoor  wrote:
>
> Dear Sigbert,
>
> Also see this :-
>
> https://www.rdocumentation.org/packages/knitr/versions/1.28/topics/knit_code
>
> Best,
> Ashim
>
> On Wed, Apr 8, 2020 at 1:13 PM Ashim Kapoor  wrote:
>
> > Dear Sigbert,
> >
> > Please see this.
> >
> > https://bookdown.org/yihui/rmarkdown-cookbook/purl.html
> >
> > Best,
> > Ashim
> >
> > On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke 
> > wrote:
> >
> >> Hi,
> >>
> >> exists a possibility to extract chunks from a R Markdown file and to
> >> return them as (named) list in R?
> >>
> >> Thanks Sigbert
> >>
> >> --
> >> https://hu.berlin/sk
> >> https://hu.berlin/mmstat3
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Markdown & chunk extraction in R

2020-04-08 Thread Yihui Xie
Hi Ashim,

read_chunk() can only read R scripts.

Regards,
Yihui
--
https://yihui.org

On Wed, Apr 8, 2020 at 10:24 AM Ashim Kapoor  wrote:
>
> Dear Yihui,
>
> Can we not 1st use read_chunk to import an Rmd and then do knit_code()$get ? 
> I could be mistaken. Please correct me if I am wrong.
>
> Best,
> Ashim
>
> On Wed, Apr 8, 2020 at 8:47 PM Yihui Xie  wrote:
>>
>> And please note that knitr::knit_code$get() only works (i.e. returns a
>> named list of code chunks) inside a knitr document when the document
>> _is being knitted_. It doesn't work outside the document. Ideally, you
>> should use the document parser of knitr, but it is not exported.
>>
>> Regards,
>> Yihui
>> --
>> https://yihui.org
>>
>> On Wed, Apr 8, 2020 at 2:54 AM Ashim Kapoor  wrote:
>> >
>> > Dear Sigbert,
>> >
>> > Also see this :-
>> >
>> > https://www.rdocumentation.org/packages/knitr/versions/1.28/topics/knit_code
>> >
>> > Best,
>> > Ashim
>> >
>> > On Wed, Apr 8, 2020 at 1:13 PM Ashim Kapoor  wrote:
>> >
>> > > Dear Sigbert,
>> > >
>> > > Please see this.
>> > >
>> > > https://bookdown.org/yihui/rmarkdown-cookbook/purl.html
>> > >
>> > > Best,
>> > > Ashim
>> > >
>> > > On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke 
>> > > wrote:
>> > >
>> > >> Hi,
>> > >>
>> > >> exists a possibility to extract chunks from a R Markdown file and to
>> > >> return them as (named) list in R?
>> > >>
>> > >> Thanks Sigbert
>> > >>
>> > >> --
>> > >> https://hu.berlin/sk
>> > >> https://hu.berlin/mmstat3
>> > >>
>> > >> __
>> > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > >> https://stat.ethz.ch/mailman/listinfo/r-help
>> > >> PLEASE do read the posting guide
>> > >> http://www.R-project.org/posting-guide.html
>> > >> and provide commented, minimal, self-contained, reproducible code.
>> > >>
>> > >
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Yihui Xie
I'm not sure what your question really is. You do not have to use
RStudio, but it will be much easier to get started with RStudio,
because it does a lot of automatic conversion behind the scenes (e.g.
tex to PDF, markdown to HTML, ...). If you want a "pure" solution
without any text editor support, the answer is

library(knitr)
knit('your_input_file')

For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
with LaTeX, you can mess with this foo.tex now (outside of R).

Minimal examples for different document formats are at
http://yihui.name/knitr/demo/minimal/ (you must have read this page),
and more examples at https://github.com/yihui/knitr-examples

If you are asking about the internals of knitr, "Luke, use the
source": https://github.com/yihui/knitr Or for a more comprehensive
introduction, see http://www.crcpress.com/product/isbn/9781482203530

Regards,
Yihui
--
Yihui Xie 
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
> Hi everyone,
>
> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>
> Read through Yihui's page, didn't find it helpful.  Stuck on terms
> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
> reference is not helping.
>
> Is there a simple step-by-step example WITHOUT RStudio?
>
> My question:
> What is the procedure?  The documentation explains the functions, but
> does not say how to operate between R and LaTex.
>
> Mike
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   3   4   >