yihui/knitr — Issue #138: cache of generic objects?
Author: syoh
Created: 2012-02-15 23:26:20+00:00
State: open

Hi Yihui,

Thank you for such great work. knitr is so useful and much better than any of "sweave" variations.

Following is the problem I am having.
I have an external source file (extsource.R) with some function definitions.
One of the functions is a generic object (setGeneric)

The steps I have tried:
1. Delete "cache" directory
2. All functions work with "<>="
3. fext3 not found in cached version: "<>=",
4. fext3 found again if not cached "<>="
5. fext3 not found again: "<>="

It seems to me that the cache does not save generic objects.

######## knit.test.Rnw

\documentclass{article}

\begin{document}
<<>>=
read_chunk('extsource.R')
@

<>=
@

<>=
@

Run functions:
<<>>=
fext1('a')
fext2('b')
fext3('c')
@

\end{document}

############# extsource.R

## @knitr ext1
fext1 <- function(x){
str <- paste("I am in ext1",x)
print(str)
}

setGeneric("fext3",
function(x, ...){
standardGeneric("fext3")
})

setMethod("fext3", "character",
function(x){
str <- paste("I am in ext3 cf",x)
print(str)
})

## @knitr ext2
fext2 <- function(x){
str <- paste("I am in ext2",x)
print(str)
fext1(x)
}