Home Comments Thread
New Thread

24 Comments

giscus-bot giscus-bot 2022-12-16 20:24:42
Guest *Melanie Bacou* @ 2011-05-27 06:02:47 originally posted:

In the past few years I have seen a trend in the scientific community with folks moving away from Latex to Wiki-based markup for preparing documents. This likely stems from the need or the realization that scientific writing is becoming more of a live and collaborative activity -- probably too because wiki markups are widely easier to learn than Latex constructs.

Lately I have been wondering how to weave R code and wiki markup. I would be curious to understand what it'd take to create such a module and if other readers think this might be worthwhile to pursue.

yihui yihui 2022-12-16 20:25:06

I do not think this is closely related to LyX, but I think the R package brew might worth looking at.

Originally posted on 2011-05-28 01:16:34

giscus-bot giscus-bot 2022-12-16 20:25:35
Guest *human mathematics* @ 2011-09-12 06:15:57 originally posted:

Worthwhile: yes.

yihui yihui 2022-12-16 20:25:40

Melanoe -

You may consider the knitr package now, which I released recently to CRAN. A simple example for the markdown format can be found in http://yihui.github.com/knitr/demo/minimal/; since wiki is pure text, it is easy for knitr to handle it.

Originally posted on 2012-01-29 09:57:18

giscus-bot giscus-bot 2022-12-16 20:24:43
Guest *Giuseppe* @ 2011-05-28 11:44:23 originally posted:

it seems great....but I cannot compile lyx (mac version). nothing to do with your patch, something about the spellchecker.

yihui yihui 2022-12-16 20:25:08

Sorry, I do not have a Macbook available for building LyX, so I guess I won't be able to help. You probably need to wait for LyX 2.0.1...

Originally posted on 2011-05-29 02:58:46

giscus-bot giscus-bot 2022-12-16 20:24:44
Guest *MartinInFrankfurtaM* @ 2011-05-28 22:52:47 originally posted:

Hi Yihui,
Thank you for your work.
I had just managed to compile and run lyx-2.0.0 (together with R and TeXLive 2010 on an openSuSE 11.3 x86_64 HP625 8Gb) when I saw your post.

Unfortunately, following your specifications I run into the following error:

soft@LookingGlas:~> cd lyx-devel/
soft@LookingGlas:~/lyx-devel> patch -p0 -i /home/soft/pgfSweave/sweave-patch.diff patching file lib/scripts/lyxsweave.R
patching file lib/scripts/lyx-pgfsweave.R
patching file lib/scripts/lyx-sweave.R
patching file lib/scripts/lyx-pgfstangle.R
patching file lib/CREDITS
patching file lib/layouts/sweave.module
patching file lib/layouts/pgfsweave.module
patching file lib/configure.py
patching file lib/Makefile.am
soft@LookingGlas:~/lyx-devel> ./autogen.sh
Using automake (GNU automake) 1.11.1
Using autoconf (GNU Autoconf) 2.65
Building macros...
Building config header template...
Building Makefile templates...
Building configure...
Building po/POTFILES.in...

run "./configure ; make"

soft@LookingGlas:~/lyx-devel> ./configure
configuring LyX version 2.1.0svn
checking for build type... development
checking for version suffix...
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking what packaging should be used... posix
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for a Python interpreter with version >= 2.3.4... python
checking for python... /usr/bin/python
checking for python version... 2.6
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.6/site-packages
checking for python extension module directory... ${exec_prefix}/lib64/python2.6/site-packages
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking what frontend should be used for the GUI... qt4
checking for a good enough C++ compiler... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for gcc... gcc
checking whether we are using the GNU Objective C compiler... no
checking whether gcc accepts -g... no
checking dependency style of gcc... gcc3
checking dependency style of gcc... (cached) gcc3
checking for extra library directory... NONE
checking for extra include directory... NONE
checking for extra lib+include directory... NONE
checking for main in -lshlwapi... no
checking for main in -lpsapi... no
checking for main in -lgdi32... no
checking whether to use included boost library... yes
checking whether to use included MyThes library... yes
checking size of wchar_t... 4
checking for ld used by GCC... /usr/x86_64-suse-linux/bin/ld
checking if the linker (/usr/x86_64-suse-linux/bin/ld) is GNU ld... yes
checking for shared library run path origin... done
checking for iconv... yes
checking for iconv declaration... install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for gzopen in -lz... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for QT4_CORE... yes
checking for QT4_FRONTEND... yes
checking for moc-qt4... no
checking for moc... /usr/bin/moc
checking for uic-qt4... no
checking for uic... /usr/bin/uic
checking for rcc-qt4... no
checking for rcc... /usr/bin/rcc
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... no
checking for msgmerge... no
checking whether we are using the GNU C Library 2 or newer... yes
checking for ranlib... ranlib
checking for simple visibility declarations... yes
checking for inline... inline
checking for size_t... yes
checking for stdint.h... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether integer division by zero raises SIGFPE... yes
checking for inttypes.h... yes
checking for unsigned long long int... yes
checking for inttypes.h... (cached) yes
checking whether the inttypes.h PRIxNN macros are broken... no
checking whether imported symbols can be declared weak... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_kill in -lpthread... yes
checking for pthread_rwlock_t... yes
checking for multithread API to use... posix
checking argz.h usability... yes
checking argz.h presence... yes
checking for argz.h... yes
checking for inttypes.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for unistd.h... (cached) yes
checking for sys/param.h... (cached) yes
checking for getcwd... yes
checking for getegid... yes
checking for geteuid... yes
checking for getgid... yes
checking for getuid... yes
checking for mempcpy... yes
checking for munmap... yes
checking for stpcpy... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strtoul... yes
checking for tsearch... yes
checking for argz_count... yes
checking for argz_stringify... yes
checking for argz_next... yes
checking for __fsetlocking... yes
checking whether feof_unlocked is declared... yes
checking whether fgets_unlocked is declared... no
checking for iconv... (cached) yes
checking for iconv declaration... (cached) install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for NL_LOCALE_NAME macro... yes
checking for bison... no
checking for long long int... yes
checking for long double... yes
checking for wchar_t... yes
checking for wint_t... yes
checking for intmax_t... yes
checking whether printf() supports POSIX/XSI format strings... yes
checking whether we are using the GNU C Library 2.1 or newer... yes
checking for stdint.h... (cached) yes
checking for SIZE_MAX... yes
checking for stdint.h... (cached) yes
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for ptrdiff_t... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for asprintf... yes
checking for fwprintf... yes
checking for putenv... yes
checking for setenv... yes
checking for setlocale... yes
checking for snprintf... yes
checking for wcslen... yes
checking whether _snprintf is declared... no
checking whether _snwprintf is declared... no
checking whether getc_unlocked is declared... yes
checking for nl_langinfo and CODESET... yes
checking for LC_MESSAGES... yes
checking for CFPreferencesCopyAppValue... (cached) no
checking for CFLocaleCopyCurrent... (cached) no
checking whether included gettext is requested... no
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking whether sys/types.h defines makedev... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for sys/types.h... (cached) yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking sys/utime.h usability... no
checking sys/utime.h presence... no
checking for sys/utime.h... no
checking whether stat file-mode macros are broken... no
checking whether time.h and sys/time.h may both be included... yes
checking for mode_t... yes
checking for off_t... yes
checking for pid_t... yes
checking return type of signal handlers... void
checking for size_t... (cached) yes
checking for uid_t in sys/types.h... yes
checking whether PATH_MAX is defined by header limits.h... yes
checking for chmod... yes
checking for close... yes
checking for _close... no
checking for fork... yes
checking for getpid... yes
checking for _getpid... no
checking for lstat... yes
checking for mkfifo... yes
checking for open... yes
checking for _open... no
checking for pclose... yes
checking for _pclose... no
checking for popen... yes
checking for _popen... no
checking for readlink... yes
checking for strerror... yes
checking for mkdir... yes
checking for _mkdir... no
checking whether mkdir takes one argument... no
checking for sys/select.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking aspell.h usability... no
checking aspell.h presence... no
checking for aspell.h... no
checking for new_aspell_config in -laspell... no
checking whether to use aspell... no
checking for ENCHANT... checking whether to use enchant... no
checking hunspell/hunspell.hxx usability... no
checking hunspell/hunspell.hxx presence... no
checking for hunspell/hunspell.hxx... no
checking whether to use hunspell... no
checking for fcntl... yes
checking for library containing gethostbyname... none required
checking for library containing socket... none required
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lyx.1
config.status: creating boost/Makefile
config.status: creating config/Makefile
config.status: creating development/Makefile
config.status: creating development/MacOSX/Makefile
config.status: creating development/MacOSX/Info.plist
config.status: creating development/MacOSX/lyxrc.dist
config.status: creating development/MacOSX/spotlight/Makefile
config.status: creating development/cygwin/Makefile
config.status: creating development/cygwin/lyxrc.dist
config.status: creating development/lyx.spec
config.status: creating intl/Makefile
config.status: creating lib/Makefile
config.status: creating lib/doc/Makefile
config.status: creating lib/lyx2lyx/lyx2lyx_version.py
config.status: creating lib/lyx2lyx/Makefile
config.status: creating m4/Makefile
config.status: creating po/Makefile.in
config.status: creating sourcedoc/Doxyfile
config.status: creating sourcedoc/Makefile
config.status: creating src/client/Makefile
config.status: creating src/client/lyxclient.1
config.status: creating src/Makefile
config.status: creating src/tex2lyx/Makefile
config.status: creating src/tex2lyx/tex2lyx.1
config.status: creating src/support/Makefile
config.status: creating src/frontends/Makefile
config.status: creating src/frontends/qt4/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile

Configuration
Host type: x86_64-unknown-linux-gnu
Special build flags: build=development warnings assertions stdlib-debug concept-checks
C Compiler: gcc
C Compiler LyX flags:
C Compiler flags: -Wextra -Wall -g -O
C++ Compiler: g++ (4.5)
C++ Compiler LyX flags:
C++ Compiler flags: -Wextra -Wall -g -O
Linker flags:
Linker user flags:
Qt 4 Frontend:
Qt 4 version:4.6.3
Packaging: posix
LyX binary dir: /usr/local/bin
LyX files dir: /usr/local/share/lyx

Configuration of LyX was successful.
Type 'make' to compile the program,
and then 'make install' to install it.
soft@LookingGlas:~/lyx-devel> make
make all-recursive
make[1]: Entering directory /home/soft/lyx-devel' Making all in config make[2]: Entering directory /home/soft/lyx-devel/config'
make[2]: Nothing to be done for all'. make[2]: Leaving directory /home/soft/lyx-devel/config'
Making all in development
make[2]: Entering directory /home/soft/lyx-devel/development' make[3]: Entering directory /home/soft/lyx-devel/development'
make[3]: Nothing to be done for all-am'. make[3]: Leaving directory /home/soft/lyx-devel/development'
make[2]: Leaving directory /home/soft/lyx-devel/development' Making all in intl make[2]: Entering directory /home/soft/lyx-devel/intl'
make[2]: Nothing to be done for all'. make[2]: Leaving directory /home/soft/lyx-devel/intl'
Making all in po
make[2]: Entering directory /home/soft/lyx-devel/po' make lyx.pot-update make[3]: Entering directory /home/soft/lyx-devel/po'
sed -e '/^#/d' remove-potcdate.sin > t-remove-potcdate.sed
mv t-remove-potcdate.sed remove-potcdate.sed
LC_ALL=C ; export LC_ALL ;
python ./lyx_pot.py -b .. -o qt4_l10n.pot -t qt4 ../src/frontends/qt4/ui/.ui
LC_ALL=C ; export LC_ALL ;
python ./lyx_pot.py -b .. -o layouts_l10n.pot -t layouts ../lib/layouts/
.layout ../lib/layouts/.inc ../lib/layouts/.module
python ./lyx_pot.py -b .. -o languages_l10n.pot -t languages ../lib/languages
python ./lyx_pot.py -b .. -o encodings_l10n.pot -t encodings ../lib/encodings
LC_ALL=C ; export LC_ALL ;
python ./lyx_pot.py -b .. -o ui_l10n.pot -t ui ../lib/ui/.ui ../lib/ui/.inc
python ./lyx_pot.py -b .. -o external_l10n.pot -t external ../lib/external_templates
python ./lyx_pot.py -b .. -o formats_l10n.pot -t formats ../lib/configure.py
cat qt4_l10n.pot layouts_l10n.pot languages_l10n.pot encodings_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot |
msguniq -o lyx.po && rm -f qt4_l10n.pot layouts_l10n.pot languages_l10n.pot encodings_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot
/bin/sh: line 1: msguniq: command not found
make[3]: *** [l10n_pots] Error 127
make[3]: Leaving directory /home/soft/lyx-devel/po' make[2]: *** [lyx.pot] Error 2 make[2]: Leaving directory /home/soft/lyx-devel/po'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/soft/lyx-devel'
make: *** [all] Error 2
soft@LookingGlas:~/lyx-devel>

Any ideas? Please.

giscus-bot giscus-bot 2022-12-16 20:25:07
Guest *MartinInFrankfurtaM* @ 2011-05-28 23:04:37 originally posted:

After installing gettext-tools, the make command does run

giscus-bot giscus-bot 2022-12-16 20:24:45
Guest *Giuseppe* @ 2011-05-30 03:48:04 originally posted:

Yihui

I was able to compile lyx with your patch on a linux machine. Everything works fine with your patch and your demo file pgfsweave.lyx. However, if i add the external=TRUE on the lm-demo chunk in the file i get an error as lyx is not able to find the file.

yihui yihui 2022-12-16 20:25:09

Sounds weird. It works for me. Does the file Rfig-lm-demo.tikz exist? What is the error message in Rfig-lm-demo.log? The error message you provided means tikz was not compiled to PDF. Are you using pgf 2.10? If so, you should be able to see this in R:

> library(pgfSweave)
Loading required package: stashR
Loading required package: filehash
filehash: Simple key-value database (2.1-1 2010-10-04)
A Set of Tools for Administering SHared Repositories (0.3-3 2009-03-26)
Loading required package: highlight
Loading required package: tools
Loading required package: codetools
Loading required package: parser
Loading required package: Rcpp
Loading required package: optparse
Loading required package: getopt
Loading required package: formatR
tikzDevice: A Device for R Graphics Output in PGF/TikZ Format (v0.6.1)
Checking for a LaTeX compiler...


A working LaTeX compiler was found by checking:
A pre-existing value of the global option tikzLatex

Global option tikzLatex set to:
/usr/local/bin/pdflatex

pdfTeX 3.1415926-1.40.11-2.2 (TeX Live 2010)
kpathsea version 6.0.0



A working XeLaTeX compiler was found by checking:
The PATH using the command xelatex

Global option tikzXelatex set to:
/usr/local/bin/xelatex

XeTeX 3.1415926-2.2-0.9997.4 (TeX Live 2010)
kpathsea version 6.0.0


pgfSweave: Using PGF Version 2.10

Originally posted on 2011-05-30 23:26:30

giscus-bot giscus-bot 2022-12-16 20:25:10
Guest *nanu* @ 2011-05-31 22:38:05 originally posted:

For me compiling produced to many errors. So I patched my Lyx.app on Mac by inserting the files and code lines manually. It works great! Thanks for your patch!

But same for me: with external=TRUE I get the "file not found" error, but only if I try to use external=TRUE in my own documents:


! LaTeX Error: File `Rfig-GWAmpab1999' not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.538 includegraphics{Rfig-GWAmpab1999}

I could not locate the file with any of these extensions:
.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2,.eps
Try typing to proceed.
If that doesn't work, type X to quit.

The demo file "demo_LyX-pgfSweave-demo-Yihui-Xie.lyx" I can generate without errors.

yihui yihui 2022-12-16 20:25:11

See my previous comment above. Does the file Rfig-GWAmpab1999.tikz exist? What is the error message in Rfig-GWAmpab1999.log?

This looks like a common problem for a few people, but I have not figured out the reason why the tikz plots are not compiled to PDF's yet. Anyway, first you need to keep everything up-to-date, e.g. update pgf (2.1) in your LaTeX distribution and R (2.13.0) / pgfSweave (1.2.1). Please let me know if the problem still exists.

Originally posted on 2011-06-01 00:04:36

giscus-bot giscus-bot 2022-12-16 20:24:47
Guest *Steve Sidney* @ 2011-06-02 16:15:53 originally posted:

Hi Yihui

Thanks for the post.

I am battling to get Sweave working with Lyx Ver2 and then ran across Rob Oakes's post http://blog.oak-tree.us/index.php/2010/10/08/sweave-lyx2 but have still found that as a newbie I am unclear with regard to how to get this working.

After reading Rob's post which I thought I understood; these are the questions that I have.

I have loaded Lyx 2, R 2.13 and MiKTex 2.9 on Win 7

  1. Looking at the RTools I was not sure what you meant by ‘appropriate’ Rtools
  2. In the MiKTex path is there a preferred folder where I should put the Sweave.sty file
  3. Do I have to look for a package before re-building the database or how does it know that something has changed

Any ideas
Regards
Steve

yihui yihui 2022-12-16 20:25:41

Steve,

Almost all instructions should be ignored now. I recommend you to read the official manual: https://github.com/downloads/yihui/lyx/sweave.pdf (you will be able to find it under Help-->Specific Manuals-->Sweave). Those old instructions were too complicated; the support for Sweave in LyX has become much better since 2.0.2.

Originally posted on 2012-01-29 10:00:29

giscus-bot giscus-bot 2022-12-16 20:25:43
Guest *Steve Sidney* @ 2012-01-30 13:55:56 originally posted:

Yihui

Thanks for the update. I'll give it try when I get a moment.

Regards

giscus-bot giscus-bot 2022-12-16 20:24:48
Guest *tim* @ 2011-06-16 10:44:46 originally posted:

At first, everything was working well for me, but now when I load the example pgfsweave.lyx file, I get the following message:

'The module pgfsweave requires a package that is not available in your LaTeX installation, or a converter that you have not installed. LaTeX output may not be possible.
Missing prerequisites:
pgfsweave->latex
See section 3.1.2.3 (Modules) of the User's Guide for more information.'

The thing that's odd is that I manually went and defined a pgfsweave->LaTeX(pdflatex) converter!

yihui yihui 2022-12-16 20:25:13

You need the LaTeX packages pgf and tikz in order to use pgfSweave (and also the fancyvrb package). Please refer to the vignette of the R package pgfSweave to see if your system satisfies all the requirements.

Originally posted on 2011-06-19 01:23:14

giscus-bot giscus-bot 2022-12-16 20:25:13
Guest *tim* @ 2011-06-19 01:32:45 originally posted:

That's what's so odd -- I can use pgfSweave() from R without any problems, and I use tikzDevice all the time (for e.g. Venn diagrams and such). But once it's in LyX, it stops working. What's even more bizarre is that, when I first installed the patch and compiled the example document, it worked fine!

The most up to date versions of pgf, tikz, and fancyvrb are in ~/texmf/tex/latex/ instead of the (abominably out-of-date, Ubuntu-standard-issue) /usr/share/texmf/. Could this be causing it?

yihui yihui 2022-12-16 20:25:14

The availability of the pgfsweave module only depends on the LaTeX packages, and I do not see any problems in what you did. Did you try to reconfigure LyX? Can you see graphicx.sty, fancyvrb.sty and tikz.sty in Tools-->TeX Information?

If there is nothing wrong with the above settings, I would suggest you disable your current preferences first to diagnose the problem. For example, mv ~/.lyx ~/.lyx_bak, then start LyX and see if the pgfsweave module works; if it does, there must be something wrong in your preferences file.

Originally posted on 2011-06-19 04:26:42

giscus-bot giscus-bot 2022-12-16 20:25:15
Guest *tim* @ 2011-06-21 19:16:09 originally posted:

OK, did both of the suggested actions (rescanned LaTeX styles, verified that all of the required .sty files were present, then moved .lyx to .lyx_bak and restarted LyX) but I still get:

Missing prerequisites:
pgfsweave->latex
See section 3.1.2.3 (Modules) of the User’s Guide for more information.

Any further ideas? This is a new development, previously LyX+pgfSweave was working.

yihui yihui 2022-12-16 20:25:16

So weird... Does the file format pgfsweave exist in your LyX? Tools-->Preferences-->File Handling-->File Formats-->Format; is pgfSweave listed there?

Originally posted on 2011-06-22 00:53:19

giscus-bot giscus-bot 2022-12-16 20:25:28
Guest *Matthieu* @ 2011-08-11 16:29:55 originally posted:

Hi

I have exactly the same problem! I have Lyx 2.0 from mirros on Ubuntu 11.04. I just followed the instructions, get also:
The module pgfsweave requires a package that is not
available in your LaTeX installation, or a converter that
you have not installed. LaTeX output may not be possible.
Missing prerequisites:
pgfsweave->latex
See section 3.1.2.3 (Modules) of the User's Guide for more information.

I reconfigured few times, tried to move .lyx, checked versions... everything seems to work! How had you solved the problem Tim? Thanks!!!

giscus-bot giscus-bot 2022-12-16 20:25:31
Guest *jo* @ 2011-09-08 21:05:59 originally posted:

I'm having the same problem, I've followed everything posted here, and I'm still getting the same error message about
Missing prerequisites:
pgfsweave->latex
See section 3.1.2.3(modules)...etc

Has anyone figured out what to do yet? Any help would be greatly appreciated.

yihui yihui 2022-12-16 20:25:32

You have to put the bin path of R into your PATH variable (see R.home('bin') in R), so that the command Rscript can be called without a full path.

Originally posted on 2011-09-09 05:22:28

giscus-bot giscus-bot 2022-12-16 20:25:34
Guest *human mathematics* @ 2011-09-10 02:41:55 originally posted:

I'm working on the same problem ... see here. I think what's necessary — at least for me in Ubuntu 10.04 — is to install TeX Live 2010, which is not included in Synaptic's default package. I'm downloading a major iso from here: http://ftp.ctex.org/mirrors/CTAN/systems/texlive/Images/

giscus-bot giscus-bot 2022-12-16 20:25:36
Guest *human mathematics* @ 2011-09-12 08:58:17 originally posted:

Yihui, I appended PATH=/usr/lib/R/bin:$PATH; export PATH to /etc/bash.bashrc and sourced the bashrc. Still getting the same error as everyone else. fancyvrb, tikz, and graphicx are all showing in the LyX menu.

yihui yihui 2022-12-16 20:25:37

If you installed R via sudo apt-get install r-base-core, you do not need to manually set PATH.

Originally posted on 2011-10-04 05:47:24

giscus-bot giscus-bot 2022-12-16 20:24:49
Guest *Subramanian* @ 2011-06-21 08:42:54 originally posted:

Yihui, Any luck on how to use pgfsweave in Lyx 2.0 in Windows? Awaiting you to throw light on that..

yihui yihui 2022-12-16 20:25:17

It works for me under Windows, but the LyX developers are still thinking on my patch. I'll try my best to persuade them incorporating the pgfsweave module in LyX 2.0.1.

Originally posted on 2011-06-22 00:56:20

yihui yihui 2022-12-16 20:25:42

LyX 2.0.3 will add knitr support: http://yihui.github.com/knitr/demo/lyx/ FYI: knitr is an R package that covers the features of pgfSweave.

Originally posted on 2012-01-29 10:02:38

giscus-bot giscus-bot 2022-12-16 20:25:43
Guest *subramanian* @ 2012-02-01 22:07:16 originally posted:

Thats great Yihui.. i'm very excited about it..Thanks a tonne for remembering to post this reply! i'm going to try it out in lyx 2.0.2.. if i've understood it right, i've to download lyxknit.r and rename it tolyxsweave.r and put it in the the scripts directory of my user directory. and then i should be able to use it in lyx, right?

giscus-bot giscus-bot 2022-12-16 20:25:45
Guest *subramanian* @ 2012-02-01 22:30:12 originally posted:

And hey, by the way, if i were on the jury of the Applications of R in Business competition, i would have given u the first prize.. anyway, hearty congrats on the honorable mention, man!

yihui yihui 2022-12-16 20:25:46

Overriding lyxsweave.R is a dirty trick. The release of LyX 2.0.3 is currently scheduled to be half a month later. By then, everything will be natural, and no hacking needed.

I started writing the package two months before the deadline of the contest, so there was not much business flavor in it. Hopefully next year I can find better business applications :)

Originally posted on 2012-02-01 23:06:15

giscus-bot giscus-bot 2022-12-16 20:24:50
Guest *subramanian* @ 2011-06-22 05:50:41 originally posted:

Yihui, i would be glad if you could share how do i go about setting it up in Lyx 2.0.

yihui yihui 2022-12-16 20:25:18

I'd love to, but I don't think I will be able to do this until the end of next week. Please remind me then if you don't mind waiting for two weeks.

It is not terribly hard anyway -- the main things you need to do is to define a module, a converter and a corresponding R script.

Originally posted on 2011-06-27 22:55:57

giscus-bot giscus-bot 2022-12-16 20:24:51
Guest *subramanian* @ 2011-06-28 06:40:54 originally posted:

Many thanks for the help Yihui. i will wait for your directions.

giscus-bot giscus-bot 2022-12-16 20:24:52
Guest *subramanian* @ 2011-07-07 08:58:39 originally posted:

Yihui, just wanted to remind you about sending me instructions on how to configure pgfsweave in Lyx 2.0 in WINDOWS 7.

Thanks in advance,

yihui yihui 2022-12-16 20:25:19

Hi, I tried to write the steps of manual configuration under Windows. I'm not sure if it is clear enough (feel free to ask me). See the last section in the above post.

Note the R script may be subject to future changes. Hopefully in the next version of LyX you do not have to mess up with all these details.

Originally posted on 2011-07-12 01:41:11

giscus-bot giscus-bot 2022-12-16 20:24:53
Guest *Subramanian* @ 2011-07-12 09:05:13 originally posted:

Yihui
Many thanks for the instructions.. i followed the instructions, i defined the 4 converters in the image in your post : pgfSweave -> Latex (LuaTex), pgfSweave -> Latex (plain), pgfSweave -> Latex (pdflatex), pgfSweave -> Latex (XeTex), While adding each of these converters, i left the converter field the same: Rscript $$s/scripts/lyx-pgfsweave.R $$p $$i $$o $$r $$e
But i was not able to find "R/S code" in the drop down box on right side- in order to choose pgfSweave -> R/S code. Please guide.

yihui yihui 2022-12-16 20:25:20

R/S code is not necessary for you to use pgfSweave; I use this format to export R code from a LyX/Sweave document. If you want to add it as well, see the screenshot below:

After defining this format, you also need to define a converter like this (it is for Sweave --> R/S code but you can define the same converter from pgfSweave to R/S code):

R CMD Stangle is enough to export R code, although my own converter is slightly different (I wrote another R script to do this).

Originally posted on 2011-07-12 22:40:37

giscus-bot giscus-bot 2022-12-16 20:25:21
Guest *Subramanian* @ 2011-07-13 09:32:31 originally posted:

Thank you for taking all the trouble Yihui. Really appreciate your effforts.
i configured exactly as per your instructions. Ensured the File formats and converters were exactly done. Then i reconfigured Lyx and restarted. Miktex installed the required packages. But on clicking View PDF icon in the demo file pgfsweave.lyx, i get this message:

An error occured while running:
R script: “C:/Program Files/lyx20/bin/../Resources/scripts/lyx-pgfsweave.R” ″ “C:/Users/SS/Appdata/Local/Temp/lyx_tmpdir.gq3652/lyx_tmpbuf2/” “pgfsweave.Rnw” "pgfsweave.tex" "C:/Users/SS/Desktop/Miktex-Lyx-R/pgfconfigLyx2.0/" ISO-8859-15

So, to see what the problem could be, i just tried running the lyx-pgfsweave.R file (given by you) in R. Here is the error message:

source("C:UsersSSDesktopMiktex-Lyx-RpgfconfigLyx2.0lyx-pgfsweave.R")
options passed from LyX:
character(0)
Error in setwd(.cmdargs[4]) : missing value is invalid

So apparently there is some error in lyx-pgfsweave.R. Hope that helps you.

yihui yihui 2022-12-16 20:25:22

No no, you should not source() the script. It will definitely fail since it was supposed to run with LyX (the converter in LyX will pass a few arguments to R).

The best approach to diagnose your problem is to turn on the messages: View --> View Messages. You can see all the details during the compilation, and usually it is easy to see what really goes wrong there.

Originally posted on 2011-07-13 19:20:30

giscus-bot giscus-bot 2022-12-16 20:24:54
Guest *Subramanian* @ 2011-07-19 13:06:01 originally posted:

This is the message i get:

14:30:37.481: Previewing ...
14:30:37.521: (buffer-view: Ctrl+R)
14:30:37.792: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.......lyx-2.0.0srcsupportSystemcall.cpp(217): Systemcall: 'Rscript "C:/Program Files/LyX20/bin/../Resources/scripts/lyx-pgfsweave.R" "C:/Users/SS/AppData/Local/Temp/lyx_tmpdir.Hp5328/lyx_tmpbuf2/" "pgfsweave.Rnw" "pgfsweave.tex" "C:/Users/SS/Desktop/Miktex-Lyx-R/pgfconfigLyx2.0/" ISO-8859-15' did not start!
......lyx-2.0.0srcsupportSystemcall.cpp(218): error The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.
Error: Cannot convert file

An error occurred while running:
Rscript "C:/Program Files/LyX20/bin/../Resources/scripts/lyx-pgfsweave.R"
"C:/Users/SS/AppData/Local/Temp/lyx_tmpdir.Hp5328/lyx_tmpbuf2/"
"pgfsweave.Rnw" "pgfsweave.tex"
"C:/Users/SS/Desktop/Miktex-Lyx-R/pgfconfigLyx2.0/" ISO-8859-15
14:30:44.174: Error while previewing format: pdf2

yihui yihui 2022-12-16 20:25:25

Did you add R's bin path to the PATH variable of your system? If you do not understand what is PATH variable, you may google it.

You can find out R's bin path via the R command R.home('bin').

Originally posted on 2011-07-21 07:53:20

giscus-bot giscus-bot 2022-12-16 20:24:55
Guest *Martin* @ 2011-07-20 10:29:09 originally posted:

I am getting some errors using your windows instructions.
Firstly I got an error similar to Subramanian, which is caused by the System call not knowing where Rscript is, you can fix this by putting the full path to Rscript.exe into the converter*.

Now the error I get is:

16:24:12.810: Rscript "D:/Documents/LyX20/bin/../Resources/scripts/lyx-pgfsweave.R" "C:/Users/themartinmcfly/AppData/Local/Temp/lyx_tmpdir.Hp6380/lyx_tmpbuf2/" "pgfsweave.Rnw" "pgfsweave.tex" "C:/Users/themartinmcfly/Downloads/" ISO-8859-15
16:24:13.780: [1] "C:/Users/themartinmcfly/AppData/Local/Temp/lyx_tmpdir.Hp6380/lyx_tmpbuf2/"
16:24:13.783: [2] "pgfsweave.Rnw"
16:24:13.784: [3] "pgfsweave.tex"
16:24:13.786: [4] "C:/Users/themartinmcfly/Downloads/"
16:24:13.788: [5] "ISO-8859-15"
16:24:13.790: options passed from LyX:
16:24:13.792: Error in file.copy(list.files(file.path(R.home("share"), "texmf", "tex", :
16:24:13.796: more 'from' files than 'to' files
16:24:13.798: Execution halted

Any Ideas? Does file.copy allow more than one file if list.files returns more than one file?

  • P.S. You can add you R bin directory to your PATH variable and that will save you putting in the full path to R.exe and Rscript.exe on your machine.
giscus-bot giscus-bot 2022-12-16 20:25:23
Guest *Martin* @ 2011-07-20 10:43:38 originally posted:

Continued.
I modified your script so that file.copy would run the copy function once per line.

Here is the changed bit:

copy Sweave.sty and friends to $$p if kpsewhich cannot find it

if (length(system("kpsewhich Sweave.sty", intern = TRUE, ignore.stderr = TRUE)) == 0) {
file.copy(file.path(R.home('share'), full.names = TRUE), .cmdargs[1])
file.copy(file.path('texmf', full.names = TRUE), .cmdargs[1])
file.copy(file.path('tex', full.names = TRUE), .cmdargs[1])
file.copy(file.path('latex', full.names = TRUE), .cmdargs[1])
}

Now everything is working for me.

Any ideas on how to get the vanilla script to work?

giscus-bot giscus-bot 2022-12-16 20:25:24
Guest *Martin* @ 2011-07-20 11:12:42 originally posted:

I have also encountered a problem with the last section of lyx-pgfsweave.R trying again to do a file.copy with multiple files at once. I can work around this by moving the file to a path with no spaces in it, but surprisingly everything still works with this logic totally remove.

This happening again suggests to me that maybe my file.copy is a different version to yours, is there a way for me to find its package version and reinstall it.

yihui yihui 2022-12-16 20:25:26

I'm using the latest R 2.13.1 and I remember I used R 2.13.0 when I wrote the above script. I know there have been a few changes in the function file.copy over the last versions of R, but I'm not sure if they caused your problem.

For the problem of spaces in file paths, this (I mean to copy all the files) is going to be unnecessary since LyX will introduce a new feature in 2.0.1 which can solve this problem perfectly. I need to adjust my script as well. Thanks for the feedback!

Originally posted on 2011-07-22 01:22:29

giscus-bot giscus-bot 2022-12-16 20:24:56
Guest *zubin* @ 2011-08-07 11:38:27 originally posted:

Hello, thanks for this post, very helpful.

Running Win7, Lyx2.0, and R 2.12

Able to get simple Sexpr to work with no problems:

begin{document}
R test using Lyx 2.0
We know the value of $pi$=Sexpr{pi}
end{document}

This outputs into a pdf successfully upon build.

However, i can't seem to get anything more complicated other than a simple R expression to execute.

Are there any examples or instructions for using lyx 2.0 and Sweave that your aware of, creating plots or such? I see many examples with 1.6 but not 2.0.

Example:

I use the menu and Insert / Custom Insets / S/R expression

Sexpr{<>=
xvals<-seq(0,5,by=0.05)
gammaxvals <- gamma(xvals)
plot(xvals,gammaxvals,type="l",xlab="x", ylab=expression(Gamma(x)), main="The Gamma Function")
@}

error i get:

 Sexpr
 {<>=
The control sequence at the end of the top line
of your error message was never def'ed. If you have
misspelled it (e.g., `hobx'), type `I' and the correct
spelling (e.g., `Ihbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

log file: 


This is pdfTeX, Version 3.1415926-1.40.11 (MiKTeX 2.9) (preloaded format=pdflatex 2011.8.7)  7 AUG 2011 13:06
entering extended mode
**newfile2.tex

(C:UsersAdministratorAppDataLocalTemplyx_tmpdir.Hp3348lyx_tmpbuf4newfil
e2.tex
LaTeX2e 
Babel  and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic, 
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat
vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm
an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese, 
romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis
sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u
senglishmax, welsh, loaded.

("C:Program Files (x86)MiKTeX 2.9texlatexbasearticle.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:Program Files (x86)MiKTeX 2.9texlatexbasesize10.clo"
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
c@part=count79
c@section=count80
c@subsection=count81
c@subsubsection=count82
c@paragraph=count83
c@subparagraph=count84
c@figure=count85
c@table=count86
abovecaptionskip=skip41
belowcaptionskip=skip42
bibindent=dimen102
) ("C:Program Files (x86)MiKTeX 2.9texlatexbasefontenc.sty"
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package
("C:Program Files (x86)MiKTeX 2.9texlatexbaset1enc.def"
File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 43.
)) ("C:Program Files (x86)MiKTeX 2.9texlatexbaseinputenc.sty"
Package: inputenc 2008/03/30 v1.1d Input encoding file
inpenc@prehook=toks14
inpenc@posthook=toks15
("C:Program Files (x86)MiKTeX 2.9texlatexbaselatin9.def"
File: latin9.def 2008/03/30 v1.1d Input encoding file
)) ("C:Program Files (x86)MiKTeX 2.9texgenericbabelbabel.sty"
Package: babel 2008/07/06 v3.8l The Babel package
*************************************
* Local config file bblopts.cfg used
*
(C:UsersAdministratorAppDataRoamingMiKTeX2.9texlatexarabibblopts.cfg
File: bblopts.cfg 2005/09/08 v0.1 add Arabic and Farsi to "declared" options of
 babel
) ("C:Program Files (x86)MiKTeX 2.9texgenericbabelenglish.ldf"
Language: english 2005/03/30 v3.3o English support from the babel system
("C:Program Files (x86)MiKTeX 2.9texgenericbabelbabel.def"
File: babel.def 2008/07/06 v3.8l Babel common definitions
babel@savecnt=count87
U@D=dimen103
)
l@canadian = a dialect from languagel@american 
l@australian = a dialect from languagel@british 
l@newzealand = a dialect from languagel@british 
)) (C:UsersAdministratorAppDataRoamingMiKTeX2.9texlatexSweave.sty
Package: Sweave 
("C:Program Files (x86)MiKTeX 2.9texlatexbaseifthen.sty"
Package: ifthen 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
) ("C:Program Files (x86)MiKTeX 2.9texlatexgraphicsgraphicx.sty"
Package: graphicx 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
("C:Program Files (x86)MiKTeX 2.9texlatexgraphicskeyval.sty"
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
KV@toks@=toks16
) ("C:Program Files (x86)MiKTeX 2.9texlatexgraphicsgraphics.sty"
Package: graphics 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
("C:Program Files (x86)MiKTeX 2.9texlatexgraphicstrig.sty"
Package: trig 1999/03/16 v1.09 sin cos tan (DPC)
) ("C:Program Files (x86)MiKTeX 2.9texlatex0miktexgraphics.cfg"
File: graphics.cfg 2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
)
Package graphics Info: Driver file: pdftex.def on input line 91.
("C:Program Files (x86)MiKTeX 2.9texlatexpdftex-defpdftex.def"
File: pdftex.def 2010/09/14 v0.05b Graphics/color for pdfTeX
Gread@gobject=count88
))
Gin@req@height=dimen104
Gin@req@width=dimen105
)
(C:UsersAdministratorAppDataRoamingMiKTeX2.9texlatexfancyvrbfancyvrb.
sty
Package: fancyvrb 2008/02/07

Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
 (tvz)
FV@CodeLineNo=count89
FV@InFile=read1
FV@TabBox=box26
c@FancyVerbLine=count90
FV@StepNumber=count91
FV@OutFile=write3
)
(C:UsersAdministratorAppDataRoamingMiKTeX2.9texlatexupquoteupquote.st
y
Package: upquote 2003/08/11 v1.1 Covington's upright-quote modification to verb
atim and verb
("C:Program Files (x86)MiKTeX 2.9texlatexbasetextcomp.sty"
Package: textcomp 2005/09/27 v1.99g Standard LaTeX package
Package textcomp Info: Sub-encoding information:
(textcomp)               5 = only ISO-Adobe without textcurrency
(textcomp)               4 = 5 + texteuro
(textcomp)               3 = 4 + textohm
(textcomp)               2 = 3 + textestimated + textcurrency
(textcomp)               1 = TS1 - textcircled - t
(textcomp)               0 = TS1 (full)
(textcomp)             Font families with sub-encoding setting implement
(textcomp)             only a restricted character set as indicated.
(textcomp)             Family '?' is the default used for unknown fonts.
(textcomp)             See the documentation for details.
Package textcomp Info: Setting ? sub-encoding to TS1/1 on input line 71.
("C:Program Files (x86)MiKTeX 2.9texlatexbasets1enc.def"
File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
)
LaTeX Info: Redefining oldstylenums on input line 266.
Package textcomp Info: Setting cmr sub-encoding to TS1/0 on input line 281.
Package textcomp Info: Setting cmss sub-encoding to TS1/0 on input line 282.
Package textcomp Info: Setting cmtt sub-encoding to TS1/0 on input line 283.
Package textcomp Info: Setting cmvtt sub-encoding to TS1/0 on input line 284.
Package textcomp Info: Setting cmbr sub-encoding to TS1/0 on input line 285.
Package textcomp Info: Setting cmtl sub-encoding to TS1/0 on input line 286.
Package textcomp Info: Setting ccr sub-encoding to TS1/0 on input line 287.
Package textcomp Info: Setting ptm sub-encoding to TS1/4 on input line 288.
Package textcomp Info: Setting pcr sub-encoding to TS1/4 on input line 289.
Package textcomp Info: Setting phv sub-encoding to TS1/4 on input line 290.
Package textcomp Info: Setting ppl sub-encoding to TS1/3 on input line 291.
Package textcomp Info: Setting pag sub-encoding to TS1/4 on input line 292.
Package textcomp Info: Setting pbk sub-encoding to TS1/4 on input line 293.
Package textcomp Info: Setting pnc sub-encoding to TS1/4 on input line 294.
Package textcomp Info: Setting pzc sub-encoding to TS1/4 on input line 295.
Package textcomp Info: Setting bch sub-encoding to TS1/4 on input line 296.
Package textcomp Info: Setting put sub-encoding to TS1/5 on input line 297.
Package textcomp Info: Setting uag sub-encoding to TS1/5 on input line 298.
Package textcomp Info: Setting ugq sub-encoding to TS1/5 on input line 299.
Package textcomp Info: Setting ul8 sub-encoding to TS1/4 on input line 300.
Package textcomp Info: Setting ul9 sub-encoding to TS1/4 on input line 301.
Package textcomp Info: Setting augie sub-encoding to TS1/5 on input line 302.
Package textcomp Info: Setting dayrom sub-encoding to TS1/3 on input line 303.
Package textcomp Info: Setting dayroms sub-encoding to TS1/3 on input line 304.

Package textcomp Info: Setting pxr sub-encoding to TS1/0 on input line 305.
Package textcomp Info: Setting pxss sub-encoding to TS1/0 on input line 306.
Package textcomp Info: Setting pxtt sub-encoding to TS1/0 on input line 307.
Package textcomp Info: Setting txr sub-encoding to TS1/0 on input line 308.
Package textcomp Info: Setting txss sub-encoding to TS1/0 on input line 309.
Package textcomp Info: Setting txtt sub-encoding to TS1/0 on input line 310.
Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 311.
Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 312.
Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 313.
Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 314.
Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 315.
Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 316.
Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 317.
Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 318.
Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 319.
Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 320.
Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 321.
Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 322.
Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 323.
Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 324.
Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 325.
Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 326.
)))
No file newfile2.aux.
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 16.
LaTeX Font Info:    Try loading font information for TS1+cmr on input line 16.
("C:Program Files (x86)MiKTeX 2.9texlatexbasets1cmr.fd"
File: ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info:    ... okay on input line 16.

(C:UsersAdministratorAppDataRoamingMiKTeX2.9texcontextbasesupp-pdf.mk
ii
[Loading MPS to PDF converter (version 2006.09.02).]
scratchcounter=count92
scratchdimen=dimen106
scratchbox=box27
nofMPsegments=count93
nofMParguments=count94
everyMPshowfont=toks17
MPscratchCnt=count95
MPscratchDim=dimen107
MPnumerator=count96
everyMPtoPDFconversion=toks18
)
! Undefined control sequence.
l.17 Sexpr
           {<>=
The control sequence at the end of the top line
of your error message was never def'ed. If you have
misspelled it (e.g., `hobx'), type `I' and the correct
spelling (e.g., `Ihbox'). Otherwise just continue,
and I'll forget about whatever was undefined.


Overfull hbox (44.56131pt too wide) in paragraph at lines 22--23
[]T1/cmr/m/n/10 plot(xvals,gammaxvals,type="l",xlab="x", ylab=expression(Gamma
(x)), main="The
 []

[1

{C:/Users/Administrator/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
(C:UsersAdministratorAppDataLocalTemplyx_tmpdir.Hp3348lyx_tmpbuf4newfil
e2.aux) )
(end occurred inside a group at level 1)

### simple group (level 1) entered at line 17 ({)
### bottom level 
Here is how much of TeX's memory you used:
 2373 strings out of 494019
 32286 string characters out of 3143859
 79833 words of memory out of 3000000
 5674 multiletter control sequences out of 15000+200000
 4403 words of font info for 15 fonts, out of 3000000 for 9000
 714 hyphenation exceptions out of 8191
 32i,4n,21p,256b,119s stack positions out of 5000i,500n,10000p,200000b,50000s
 
Output written on newfile2.pdf (1 page, 12750 bytes).
PDF statistics:
 47 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)
giscus-bot giscus-bot 2022-12-16 20:24:57
Guest *zubin* @ 2011-08-07 11:39:05 originally posted:

email address was mis-typed, corrected above

yihui yihui 2022-12-16 20:25:27

You should not put such code in Sexpr{} -- it was designed to output a character string rather than plots, and you must write legal R code inside it (e.g. should not write <<>>= in it).

Originally posted on 2011-08-10 02:09:51

giscus-bot giscus-bot 2022-12-16 20:24:58
Guest *zubin* @ 2011-08-07 16:55:25 originally posted:

okay, figured out you need to use sweave chunks under the environment menu. I can now process R chunks and it works fine with table output (tex or verbatim), but not with plots.

Any idea what's going on with graphic devices? Sample below:

<>= 
xvals<-seq(0,5,by=0.05) 
gammaxvals <- gamma(xvals) 
plot(xvals,gammaxvals,type="l", xlab="x", ylab=expression(Gamma(x)), main="The Gamma Function") 
@

error messages:
17:58:51.213: 
17:58:51.216: Error:  chunk 3 (label=testplot) 
17:58:51.218: Error in title(...) : Metric information not available for this device
yihui yihui 2022-12-16 20:25:26

Yes, this problem was reported since LyX 2.0 was released and explained here: http://www.lyx.org/trac/ticket/7552

In short, it was caused by the use of the null graphics device. To avoid it, put options(device = pdf) in the first R code chunk in your Sweave document.

No tricks need to be done in LyX 2.0.1 or after R 2.14 -- updating either LyX or R will solve this problem.

Originally posted on 2011-08-10 02:05:26

giscus-bot giscus-bot 2022-12-16 20:24:59
Guest *Andrey* @ 2011-08-14 22:02:47 originally posted:

Hi!
When I try to apply the patch, I get following errors:
~/lyx-devel $ patch -p0 -i ~/Downloads/sweave-patch.diff
patching file lib/scripts/lyxsweave.R
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n] y
Hunk #1 FAILED at 1.
File lib/scripts/lyxsweave.R is not empty after patch, as expected
1 out of 1 hunk FAILED -- saving rejects to file lib/scripts/lyxsweave.R.rej
patching file lib/scripts/lyx-pgfsweave.R
patching file lib/scripts/lyx-sweave.R
patching file lib/scripts/lyx-pgfstangle.R
patching file lib/CREDITS
Hunk #1 FAILED at 540.
1 out of 1 hunk FAILED -- saving rejects to file lib/CREDITS.rej
patching file lib/layouts/sweave.module
Hunk #1 FAILED at 1.
Hunk #2 succeeded at 14 (offset -5 lines).
Hunk #3 succeeded at 63 (offset -5 lines).
Hunk #4 succeeded at 132 (offset -5 lines).
1 out of 4 hunks FAILED -- saving rejects to file lib/layouts/sweave.module.rej
patching file lib/layouts/pgfsweave.module
patching file lib/configure.py
Hunk #1 succeeded at 513 (offset -26 lines).
Hunk #2 succeeded at 635 (offset -25 lines).
patching file lib/Makefile.am
Hunk #1 succeeded at 1451 (offset -3 lines).
Hunk #2 succeeded at 1485 (offset -2 lines).

giscus-bot giscus-bot 2022-12-16 20:25:29
Guest *Andrey* @ 2011-08-14 23:11:04 originally posted:

despite the errors, lyx compiled, and it seems that sweave.lyx and pgfsweave.lyx work fine

yihui yihui 2022-12-16 20:25:30

Actually I'm surprised that it still works. There have been a couple of changes (in the svn repository) to the files I modified, so I thought it would not work any more. Anyway, remember this is highly experimental and likely to subject to future changes.

Originally posted on 2011-08-17 06:23:56

giscus-bot giscus-bot 2022-12-16 20:25:00
Guest *Matthieu* @ 2011-08-16 20:54:20 originally posted:

Hi!

I tried on another computer, where I compiled Lyx from source (ver 2.0.0 29 april) on Ubuntu 10.10. I tried to follow the guidelines, but have again the problem of missing pre-requisite:
Missing prerequisites:
pgfsweave->latex

Was the step of applying your patch necessary to use pgfsweave? Any idea what is going wrong? Thanks so much!!

Matthieu

giscus-bot giscus-bot 2022-12-16 20:25:01
Guest *human mathematics* @ 2011-09-09 20:39:17 originally posted:

A brutal way is to delete ~/.lyx/: rm -r ~/.lyx/

Why not just mv ~/.lyx ~/.lyx.bak.1.6? Less scary.

yihui yihui 2022-12-16 20:25:33

Completely agree! Thanks for reminding me.

Originally posted on 2011-09-09 20:46:03

giscus-bot giscus-bot 2022-12-16 20:25:02
Guest *human mathematics* @ 2011-09-09 23:32:56 originally posted:

pgfSweave is faster: it uses the GNU make utility to compile graphics, and you can use multi cores if you like

How?

yihui yihui 2022-12-16 20:25:35

By default, pgfSweave uses 2 cores; see the np argument in the function pgfSweave().

Originally posted on 2011-09-10 05:07:05

giscus-bot giscus-bot 2022-12-16 20:25:03
Guest *human mathematics* @ 2011-09-12 06:15:04 originally posted:

How does one create a Chunk in Lyx 2.0.1.patch ? Your test document compiles successfully (hooray!) but the dropdown on the file I was editing doesn't have a Sweave: Chunk option.

giscus-bot giscus-bot 2022-12-16 20:25:04
Guest *human mathematics* @ 2011-10-04 09:16:37 originally posted:

Yihui, do we still need to apply your patch (Oct 2011) if we are building lyx-devel from subversion?

yihui yihui 2022-12-16 20:25:38

No, I do not recommend you to. I'm still hesitating on how pgfSweave should be included in LyX; in my patch, I guess only I know how.

Originally posted on 2011-10-04 18:41:51

giscus-bot giscus-bot 2022-12-16 20:25:05
Guest *Shyam* @ 2011-12-07 20:59:13 originally posted:

After reading your blog, I have also determined to use LyX and Sweave program. Could you please tell me how to install 'pgfSweave' package in LyX ? I did not find 'article (pgfSweave noweb)' in Document > setting path as you shown in your Video.

Thank,

Shyam

yihui yihui 2022-12-16 20:25:39

Sorry, but unfortunately I do not plan to add this layout to LyX any more, so it is not going to happen. I have been developing a way better package than Sweave called knitr, which will hopefully go into LyX in the future. The support to Sweave and related packages has been changed dramatically since LyX 2.0: instead of using layouts, we are using modules now. See the manual for details: https://github.com/downloads/yihui/lyx/sweave.pdf

Originally posted on 2011-12-09 23:41:00

Sign in to join the discussion

Sign in with GitHub