Displaying 2 results from an estimated 2 matches for "barpkg".
2014 Jul 21
1
create R package include Fortran source code.
...e using Fortran source code. The Fortran code is a
subroutine. I can use "R CMD SHLIB bar.f -o bar.o" to create the shared
library. For the R package, I put the fortran file in the src/ and I use R
code as follows:
".First.lib"<-function(libname,pkgname){library.dynam("barpkg",pkgname,libname)}
barfun<-function(n,x){
.Fortran("bar",as.integer(n),as.double(x))
}
package.skeleton(name="barpkg",list=c("barfun"))
--------------------------------------------------------------------------
I can build with "R CMD build barpkg",...
2004 Jan 08
3
S3, S4, namespace
...="bar"),
printBar <- function(x,...)
{
print("barprint method for bar")
print(x@.Data,...)
}
)
#the NAMESPACE file for package bar
import(methods)
exportMethods(barprint,print)
exportClasses("bar")
#then in R:
> require(barpkg)
Loading required package: barpkg
[1] TRUE
> x <- new("bar",99)
> print(x)
[1] "print method for bar"
[1] 99
> barprint(x)
[1] "barprint method for bar"
[1] 99
Fine.
Here is the bit that I have not figured out. -------------
#the .r file for package waz...