[R] Course: Introduction to Linear mixed effects models, GLMM and MCMC with R

2013-11-21 Thread Highland Statistics Ltd
We would like to announce the following statistics course; Course: Introduction to Linear mixed effects models, GLMM and MCMC with R When: 10-14 February, 2014 Where: Pousada de juventude parque das nacoes. Rua de Moscavide, Lt 47 – 101, 1998- 011. Lisbon, Portugal Info:

Re: [R] Percentiles for unequal probability sample

2013-11-21 Thread Thomas Lumley
On Thu, Nov 21, 2013 at 8:35 AM, Trevor Walker trevordaviswal...@gmail.comwrote: I often work with tree data that is sampled with probability proportional to size, which presents a special challenge when describing the frequency distribution. The survey package does lots of calculations

Re: [R] RStudio and R.app segmentation fault errors

2013-11-21 Thread Duncan Murdoch
On 13-11-20 10:45 PM, Earl Brown wrote: R-helpers, I'm using system() to run a shell script that uses a library written in C++ to analyze natural language (FreeLing: http://nlp.lsi.upc.edu/freeling). When I run the following code in RStudio (0.97.248) and R.app (1.62) on Max OSX (10.7.5):

[R] Plotting multiple confidence intervals in the same graph

2013-11-21 Thread Preetam Pal
Hi, I have 100 observations X1,X2,..,X100 and the confidence interval limits for the mean at 5% level of significance. I wanted to repeat this procedure say 50 times and see how many times the hypothetical mean is included in the confidence intervals. Analytically I have done this, but I am

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Jim Holtman
you need to show the statement in context with the rest of the script. you need to tell us what you want to do, not how you want to do it. Sent from my iPad On Nov 20, 2013, at 15:16, Noah Silverman noahsilver...@g.ucla.edu wrote: Hello, I have a fairly large data.frame. (About 150,000

Re: [R] frequency of numbers

2013-11-21 Thread b. alzahrani
Thanks, got it. ** Bander Alzahrani, r * Date: Thu, 21 Nov 2013 09:14:11 -0600 Subject: Re: [R] frequency of numbers From: deter...@umn.edu To: cs_2...@hotmail.com CC: r-help@r-project.org If

Re: [R] frequency of numbers

2013-11-21 Thread Charles Determan Jr
If you just need a count of how many of each number you can just use table(). tmp - c(111,106,117,108,120,108,108,116,113) table(tmp) tmp 106 108 111 113 116 117 120 1 3 1 1 1 1 1 On Thu, Nov 21, 2013 at 9:10 AM, b. alzahrani cs_2...@hotmail.com wrote: hi guys Assume I

[R] Repeated measures ANOVA for unbalanc

2013-11-21 Thread John Sorkin
R 3.0.1 Windows 7 Rstudio 0.97.551 Colleagues, The last time I thought about using lmer to run an unbalanced repeated measures ANOVA, I found that the package did not return p values or SEs. I believe this was because Professor Bates had important questions about the theory behind the

[R] metafor escalc(measure=SMCC)

2013-11-21 Thread petretta
Many thanks to Wolfgang Viechtbauer for the prompt and clear answer. However, I'm unable to understand what .cmicalc mathematically does in the code line: cmi - .cmicalc(mi) I look in the metafor documentation and in R (?.cmical and ??.cmicalc) but I have no result. Please, can I have further

[R] How to get a nested list of lists of data.frames into a data.frame or nested dataframe for easy viewing

2013-11-21 Thread Beckstrand, Janis, NCOD
I have data in a list of the form: list(list(dataframe())). It have attached some random data with this structure called l.Rdata. The structures in l.Rdata are as follows: a list of 4 groups: a list of 12 statistics: (and for each statistic, a dataframe contains (1row,3cols) of values named

[R] Is there a way to optimize a function that has the dot-dot-dot (...) argument using optim()

2013-11-21 Thread Nan Wang
Hi everyone, If the function I am trying to optimize have the ... argument, how to pass it to optim()? For example, we want to minimize this very simple function: foo - function(a, ...) { var=list(...) (a-1)^2+do.call(sum,var) } Although the ... in this function doesn't make any

Re: [R] about the integrate

2013-11-21 Thread Rolf Turner
Think about what you are actually getting from pnorm(). For each scalar s you want to get pnorm(s,mu[2],sigma[2])pnorm(s,mu[3],sigma[3]) pnorm(s,mu[4],sigma[4]) (and then take products of things). But when s is a vector you get pnorm(s[1],mu[2],sigma[2])

Re: [R] How to stop Kaplan-Meier curve at a time point

2013-11-21 Thread Terry Therneau
Here is the simplest answer that I know. outcome6 - ifelse(Survival_days 2190, 0, Outcome) survfit(Surv(Survival_days, outcome6) ~ Gender) This assumes that the variable Outcome is coded as 0/1. If it were instead FALSE/TRUE then change the 0 to FALSE in the first line. The logrank

Re: [R] Repeated measures ANOVA for unbalanc

2013-11-21 Thread John Fox
Dear John, The Anova() function in the car package will perform a traditional unbalanced repeated-measures ANOVA (or MANOVA). See the R Journal article at http://journal.r-project.org/archive/2013-1/fox-friendly-weisberg.pdf. I hope this helps, John -Original Message- From:

Re: [R] Repeated measures ANOVA for unbalanc

2013-11-21 Thread Toth, Denes
Hi, The new lme4 package has a bootMer function, so it is fairly easy to compute bootstrap statistics. The following packages could be what you are looking for: 1) lmerTest (see ?lmerTest:::lmer) 2) car (see Anova) 3) afex (see mixed) 4) LMERConvenienceFunctions (see pamer.fnc) HTH, Denes

Re: [R] Repeated measures ANOVA for unbalanc

2013-11-21 Thread Bert Gunter
Well ... 1. Try the latest version of lmer/lme4 and see for yourself. I think the answer is still no. 2. If 1 is true, then I think you need to ask whether you **want** to use a package that returns p values and se's, whether it exists or not. Cheers, Bert On Thu, Nov 21, 2013 at 2:07 PM,

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Neal Fultz
Noah, If N is # of rows, k is # of unique IDs Using which() is O(N), using which() in a loop is going to be O(Nk); sorting the entire data is O(N ln N) and then you can process it in contiguous blocks, no which required. -Neal On Thu, Nov 21, 2013 at 8:48 AM, William Dunlap

Re: [R] Is there a way to optimize a function that has the dot-dot-dot (...) argument using optim()

2013-11-21 Thread Rui Barradas
Hello, ?optim has a dots argument, so just pass whatever you want after 'gr'. Something like the following. optim(-3, foo, NULL, 1, 2) Hope this helps, Rui Barradas Em 21-11-2013 22:05, Nan Wang escreveu: Hi everyone, If the function I am trying to optimize have the ... argument, how to

Re: [R] Plotting multiple confidence intervals in the same graph

2013-11-21 Thread PIKAL Petr
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Preetam Pal Sent: Thursday, November 21, 2013 12:10 PM To: r-help@r-project.org Subject: [R] Plotting multiple confidence intervals in the same graph Hi, I have 100

[R] changing the surface coloring (using lattice::wireframe)

2013-11-21 Thread Smilyanov Georgi
Hi all, I am using lattice::wireframe to create a surface. I need to change the coloring so that it depends on the x or y variable (instead of on z). How should this be done? The documentation says that the color is automatically chosen to depend on the height (e.g. z). Thanks! Georgi

Re: [R] overlaying 2D grid on randomly distributed points

2013-11-21 Thread Thomas Stewart
How about this? require(FNN) #FOR DEMONSTRATION PURPOSES, GENERATE 2D DATA set.seed(3242) X - matrix(runif(50),ncol=2) plot(X,pch=16,cex=1.5, asp=1) #PLOT GRID grid - as.matrix(expand.grid(seq(0,1,by=.1),seq(0,1,by=.1)) ) abline(v=unique(grid[,1]),col=#FF30)

Re: [R] Question on xyplot

2013-11-21 Thread Duncan Mackay
Hi I missed the original posting I think to get the full picture we need to a reproducible example eg by dput of the data. To keep all the information about a plot you can use the par.settings argument which is an alternative to trellis.par.set(). Try names(trellis.par.get()) to get a list of

Re: [R] integrate

2013-11-21 Thread dan wang
That works. Thanks a lot! On Wed, Nov 20, 2013 at 11:52 PM, David Winsemius dwinsem...@comcast.netwrote: On Nov 20, 2013, at 8:39 PM, David Winsemius wrote: On Nov 20, 2013, at 7:12 PM, dan wang wrote: Hi all, Can anyone help me with below integrate function? Basically, I

Re: [R] The profile log-likelihood problem

2013-11-21 Thread Duncan Mackay
Hi Without knowing anything about the data and the warning messages, however the p.vec value seems a little strange. try p.vec= seq(1.35, 1.75, by = 0.1) It could be that you have run out of memory to do 50 sets of calculations If ok with the result then repeat with a narrower focus. Most

Re: [R] How to stop Kaplan-Meier curve at a time point

2013-11-21 Thread David Winsemius
there would be an over-estimate of risk in proportion to the ratio of such cases to the entire population. -- David. Chris library(survival) set.seed(20131121) ngroup - 100 xxx - rep(0:1, e=ngroup) ttt - rexp(length(xxx), rate=xxx+.5) plot(survfit(Surv(ttt) ~ xxx)) survdiff(Surv

[R] How do I identify non-sequential data?

2013-11-21 Thread Lopez, Dan
Hi R Experts, About the data: My data consists of people (ID) with years of service (Yos) for each year. An ID can appear multiple times. The data is sorted by ID then by Year. Problem: I need to extract ID data with non-sequential YoS rows. For example below that would be all rows for ID 33

[R] Functions in formulae ??

2013-11-21 Thread Jeremy Clark
Dear All, In the following simple case I can't seem to get an improved fit, despite trying all of the control possibilities. As there seem to be no examples anywhere which show use of functions such as dnorm within a formula, and as I am not confident at all that my formula is correctly

Re: [R] Thoughts for faster indexing

2013-11-21 Thread William Dunlap
The line with the slow process (According to Rprof) is: j - which( d$id == person ) (I then process all the records indexed by j, which seems fast enough.) Using split() once (and using its output in a loop) instead of == applied to a long vector many times, as in for(j in

[R] Regression model

2013-11-21 Thread srecko joksimovic
Hi, I'm trying to fit regression model, but there is something wrong with it. The dataset contains 85 observations for 85 students.Those observations are counts of several actions, and dependent variable is final score. More precisely, I have 5 IV and one DV. I'm trying to build regression model

Re: [R] How do I identify non-sequential data?

2013-11-21 Thread MacQueen, Don
Dan, Does this do it? ## where dt is the data tmp - split(dt, dt$ID) foo - lapply(tmp, function(x) any(diff(x$YoS) 1)) foo - data.frame( ID=names(foo), gap=unlist(foo)) Note that I ignored dept. Little hard to see how YoS can increase by more than one when the year increases by only one ...

Re: [R] How do I identify non-sequential data?

2013-11-21 Thread arun
Hi, You may try:  with(testSeq,ave(YoS,ID,FUN=function(x) c(0,diff(x # [1] 0.0 1.0 0.0 1.0 1.0 0.0 2.1 0.0 1.0 3.0 1.0  testSeq[!!(with(testSeq,ave(YoS,ID,FUN=function(x) any(c(0,diff(x))1,] A.K. On Thursday, November 21, 2013 6:55 PM, Lopez, Dan lopez...@llnl.gov wrote: Hi R

Re: [R] overlaying 2D grid on randomly distributed points

2013-11-21 Thread Adams, Jean
Gonçalo, Interesting question. You can use the optim() function to optimize a function over two dimensions. Here's an example. # some clumpy cloud data myx - c(0.3 + rnorm(50, 0, 0.05), 0.7 + rnorm(50, 0, 0.05)) myy - c(0.45 + rnorm(50, 0, 0.05), 0.65 + rnorm(50, 0, 0.05)) # size of the fixed

Re: [R] Does function read.sas7bdat() have some memory limitations?

2013-11-21 Thread peter dalgaard
This certainly looks like a bug, and there are many ways of inducing bugs that only show up with large datasets - buffer overruns, fields that are too small to hold the number of rows, etc. Remember that there is NO official documentation of the .sas7bdat format, everything has been reverse

Re: [R] how can I import a number of datsets in a folder in my working directory to a list in R

2013-11-21 Thread arun
Hi, Try: 1st part: res3 - vector() for(i in 1:length(D)){  res3 - rbind(res3, read.table(paste0(getwd(),/IR/,D[i]),header=TRUE)[,2])  res3  }  dim(res3) #[1]   15 1686  identical(res2,res3) #[1] TRUE 2nd part: vec1 - unlist(lapply(D,function(x) {x1 -

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Bert Gunter
or use tapply(seq_len(nrow(d),d$id,...) or a wrapper version thereof (by, aggregate,...) However, it would not surprise me if this does not help. I suspect that the problem is not what you think but in the code and context you omitted, as others have already noted. -- Bert On Thu, Nov 21,

Re: [R] Regression model

2013-11-21 Thread Rolf Turner
(1) Is this homework? (This list doesn't do homework for people!) (Animals maybe, but not people! :-) ) (2) Your question isn't really an R question but rather a statistics/linear modelling question. It is possible that you might get some insight from Frank Harrel's book Regression

Re: [R] Regression model

2013-11-21 Thread srecko joksimovic
No, it's not homework, it's just some initial analysis, but still... and thanks for recommendation. On Thu, Nov 21, 2013 at 4:42 PM, Rolf Turner r.tur...@auckland.ac.nzwrote: (1) Is this homework? (This list doesn't do homework for people!) (Animals maybe, but not people! :-) ) (2) Your

[R] How to add unique occasions based on date within a subject in R?

2013-11-21 Thread Andrzej Bienczak
Hi All, I'm trying to figure out how in my data set to add a column including a count of unique events based on date. Here is a part of my data set: trialno event date time 3 11301pm_intake 2010-11-24

[R] overlaying 2D grid on randomly distributed points

2013-11-21 Thread Gonçalo Ferraz
Hi, I have a cloud of randomly distributed points in 2-dimensional space and want to set up a grid, with a given grid-cell size, that minimizes the distance between my points and the grid nodes. Does anyone know of an R function or toolbox that somehow addresses this problem? This is a problem

Re: [R] Question on xyplot

2013-11-21 Thread Carl Witthoft
you didn't show us the code you used to generate the legend. I'm guessing you want to add to the legend list something like lty=0:7 . KB wrote I recently started using R, so I'm not really experienced with it. My question is on adjusting xyplots to get lty lines instead of coloured lines.

Re: [R] Does function read.sas7bdat() have some memory limitations?

2013-11-21 Thread Li, Xiaochun
Thank you, Peter. I'll generate a self-contained example and contact the maintainer. Xiaochun -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Thursday, November 21, 2013 9:19 AM To: Li, Xiaochun Cc: r-help@R-project.org Subject: Re: [R] Does function

[R] about the integrate

2013-11-21 Thread dan wang
Hi all, I tried below two methods to calculate the integrate of a same function. Two different results are given. The first one should be the right answer. Can any one help to explain why? Another issue is, the first one is not convenient as I have to update the mu and sigma outside the function.

Re: [R] frequency of numbers

2013-11-21 Thread arun
Hi, From the dscription, looks like you need ?rle() vec1 - c(111, 106, 117, 108, 120, 108, 108, 116, 116, 113)  res - rle(vec1)$lengths  names(res) - rle(vec1)$values  res[res1] #108 116 #  2   2 length(res[res1]) A.K. On Thursday, November 21, 2013 10:12 AM, b. alzahrani

Re: [R] error in install

2013-11-21 Thread Ista Zahn
Hi Dawn, unix is kind vague, what exactly is the OS you are using? Do you really need to build from source? Best, Ista On Wed, Nov 20, 2013 at 4:13 PM, Dawn dawn1...@gmail.com wrote: Hi, I am trying to install R on the Unix system. When I type './configure', it seems many not installed on

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/21/13, 12:34 , Jim Holtman wrote: you need to show the statement in context with the rest of the script. you need to tell us what you want to do, not how you want to do it. Agreed - a few details will result in guesses (see my guess

Re: [R] How to stop Kaplan-Meier curve at a time point

2013-11-21 Thread Andrews, Chris
That subset will give you right truncation, not right censoring. See code below. Use Thomas's solution. Chris library(survival) set.seed(20131121) ngroup - 100 xxx - rep(0:1, e=ngroup) ttt - rexp(length(xxx), rate=xxx+.5) plot(survfit(Surv(ttt) ~ xxx)) survdiff(Surv(ttt) ~ xxx) # impose

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Ben Bolker
Neal Fultz nfultz at gmail.com writes: Noah, If N is # of rows, k is # of unique IDs Using which() is O(N), using which() in a loop is going to be O(Nk); sorting the entire data is O(N ln N) and then you can process it in contiguous blocks, no which required. -Neal You might

Re: [R] How to add unique occasions based on date within a subject in R?

2013-11-21 Thread arun
Hi, May be you can try: ###Use dput() dat1 - structure(list(trialno = c(11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L), event = c(pm_intake, am_intake, pk1, pm_intake, am_intake,

Re: [R] metafor escalc(measure=SMCC)

2013-11-21 Thread Viechtbauer Wolfgang (STAT)
.cmicalc is a non-exported function. You can see the code with: getAnywhere(.cmicalc) Best, Wolfgang -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of petre...@unina.it Sent: Thursday, November 21, 2013 13:39 To:

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Ben Tupper
Hi, On Nov 21, 2013, at 10:42 AM, MacQueen, Don macque...@llnl.gov wrote: I have some processes where I do the same thing, iterate over subsets of a data frame. My data frame has ~250,000 rows, 30 variables, and the subsets are such that there are about 6000 of them. Performing a which()

Re: [R] Thoughts for faster indexing

2013-11-21 Thread MacQueen, Don
I have some processes where I do the same thing, iterate over subsets of a data frame. My data frame has ~250,000 rows, 30 variables, and the subsets are such that there are about 6000 of them. Performing a which() statement like yours seems quite fast. For example, wrapping unix.time() around

Re: [R] How to add unique occasions based on date within a subject in R?

2013-11-21 Thread arun
Hi, May be you can try: ###Use dput() dat1 - structure(list(trialno = c(11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11301L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L, 11302L), event = c(pm_intake, am_intake, pk1, pm_intake, am_intake,

[R] multiple pages with ggplot2 possible?

2013-11-21 Thread Jun Shen
Dear all, This question was asked a few years ago. Back then, the answer was NO. Just wonder if the package has been updated to make it possible. An example (Theoph is a dataset coming with R) ggplot(data=Theoph, aes(x=Time, y=conc)) + geom_point() + facet_wrap(~Subject) gives me all 12

Re: [R] Thoughts for faster indexing

2013-11-21 Thread Carl Witthoft
What the Data Munger Guru said. Plus: this is almost certainly a job for ddply or data.table. Noah Silverman-2 wrote Hello, I have a fairly large data.frame. (About 150,000 rows of 100 variables.) There are case IDs, and multiple entries for each ID, with a date stamp. (i.e. records of

Re: [R] How do I identify non-sequential data?

2013-11-21 Thread Lopez, Dan
Hi Don, Yes, I am error checking a dataset produced by a query. Most likely a problem with the query but wanted to assess the problem first. BTW Arun provided another solution which is similar to yours but uses the function ave instead: testSeq[!!(with(testSeq,ave(YoS,ID,FUN=function(x)

Re: [R] Fwd: Datatable manipulation

2013-11-21 Thread arun
Hi, Try: dat1 - read.table(text=a     b     c     d   e 1     2     3     4     5 10     9     8     7     6,sep=,header=TRUE) Names1- read.table(text=Original      New    e     ee b     bb    a     aa c     cc d     dd,sep=,header=TRUE,stringsAsFactors=FALSE) It is better to dput()

Re: [R] Plotting multiple confidence intervals in the same graph

2013-11-21 Thread Thomas Stewart
I'd recommend something along these lines: set.seed(32438786) plot.new() plot.window(xlim=c(-.5,.5),ylim=c(1,50)) for(i in 1:50){ X - rnorm(100) CI - confint(lm(X~1)) ifelse( sum(0 CI) == 2 | sum(0CI)==2 , line.col - red, line.col - black ) lines(CI,c(i,i),lwd=2, col=line.col) } box()

Re: [R] how can I import a number of datsets in a folder in my working directory to a list in R

2013-11-21 Thread arun
Hi, Try: #Generating the files fileList1 - paste0(rep(LETTERS[1:5],each=3),1:3,.txt) set.seed(48) lapply(fileList1,function(x) {m1 - matrix(sample(1:20,1686*2,replace=TRUE),nrow=1686,ncol=2); write.table(m1,paste0(/home/arunksa111/Trial6/IR/,x),row.names=FALSE,quote=FALSE)}) dir() #[1]

Re: [R] Thoughts for faster indexing

2013-11-21 Thread jlh.membership
Not sure this helps but... ## # data frame with 30,000 ID's, each with 5 dates, plus some random data... df - data.frame(id=rep(1:3, each=5), date=rep(1:5, each=3), x=rnorm(15), y=rnorm(15,

Re: [R] Plotting multiple confidence intervals in the same graph

2013-11-21 Thread David Carlson
Maybe something like this, assuming mean=0: samsize - 100 replicates - 50 pval - .05 samples - replicate(replicates, rnorm(samsize)) confint - t(apply(samples, 2, function(x) c(mean(x)-qt(1-pval/2, df=samsize-1)*sd(x)/sqrt(samsize), mean(x)+qt(1-pval/2,

[R] frequency of numbers

2013-11-21 Thread b. alzahrani
hi guys Assume I have this dataframe: v3$number_of_ones [1] 111 106 117 108 120 108 108 116 116 113 Is there any command in r that gives me the frequency of these numbers (how many each number is repeated e.g. the number 108 repeated 2 and 111 repeated one an so on) I have around 10^6

[R] xyz-contour plot (irregular grid)

2013-11-21 Thread ivo welch
Dear R users: before I try to undertake my own rewrite, has anyone already written a contour function that does not require a regularly spaced grid, preferably plot.contour(x,y,z,...)? (it would be nice if it were based on loess() and plot()? further annotations, changes, etc., would then be

[R] use of bquote

2013-11-21 Thread Richard M. Heiberger
When I use run this expression a - 2; b - 3; xyplot(1:10 ~ a*(1:10), sub = c(bquote(a == .(a) ~ b==.(b the subtitle contains three copies of the a = 2 b = 3 phrase. Why does it do that? How do I tell it to give me only one copy? Rich __

Re: [R] use of bquote

2013-11-21 Thread William Dunlap
a - 2; b - 3; xyplot(1:10 ~ a*(1:10), sub = c(bquote(a == .(a) ~ b==.(b the subtitle contains three copies of the a = 2 b = 3 phrase. Why does it do that? How do I tell it to give me only one copy? To avoid it don't wrap bquote() with c(). The following does what you asked for: a

Re: [R] use of bquote

2013-11-21 Thread Rolf Turner
On 11/22/13 18:47, William Dunlap wrote: a - 2; b - 3; xyplot(1:10 ~ a*(1:10), sub = c(bquote(a == .(a) ~ b==.(b the subtitle contains three copies of the a = 2 b = 3 phrase. Why does it do that? How do I tell it to give me only one copy? To avoid it don't wrap bquote() with c(). The

Re: [R] multiple pages with ggplot2 possible?

2013-11-21 Thread Jeff Newmiller
I don't think anything has changed in the fundamental design of ggplot2, so the answer is still no. But you can use some kind of loop (for, or *apply) to generate them sequentially. What do you plan to do with them? Save as jpeg? Append into a pdf? Embed in an Sweave or knitr file?