Running examples in ‘inline-Ex.R’ failed
The error most likely occurred in:

> ### Name: cfunction
> ### Title: Inline C, C++, Fortran function calls from R
> ### Aliases: cfunction setCMethod
> ### Keywords: file
> 
> ### ** Examples
> 
> 
> x <- as.numeric(1:10)
> n <- as.integer(10)
> 
> ## Not run: 
> ##D ## A simple Fortran example - n and x: assumed-size vector
> ##D code <- "
> ##D       integer i
> ##D       do 1 i=1, n(1)
> ##D     1 x(i) = x(i)**3
> ##D "
> ##D cubefn <- cfunction(signature(n="integer", x="numeric"), code, convention=".Fortran")
> ##D print(cubefn)
> ##D 
> ##D cubefn(n, x)$x
> ##D 
> ##D ## Same Fortran example - now n is one number
> ##D code2 <- "
> ##D       integer i
> ##D       do 1 i=1, n 
> ##D     1 x(i) = x(i)**3
> ##D "
> ##D cubefn2 <- cfunction(signature(n="integer", x="numeric"), implicit = "none", 
> ##D   dim = c("", "(*)"), code2, convention=".Fortran")
> ##D 
> ##D cubefn2(n, x)$x
> ##D 
> ##D ## Same in F95, now x is fixed-size vector (length = n)
> ##D code3 <- "x = x*x*x"
> ##D cubefn3 <- cfunction(sig = signature(n="integer", x="numeric"), implicit = "none", 
> ##D   dim = c("", "(n)"), code3, language="F95")
> ##D cubefn3(20, 1:20)
> ##D print(cubefn3)
> ##D 
> ##D ## Same example in C
> ##D code4 <- "
> ##D       int i;
> ##D       for (i = 0; i < *n; i++) 
> ##D         x[i] = x[i]*x[i]*x[i];
> ##D "
> ##D cubefn4 <- cfunction(signature(n="integer", x="numeric"), code4, language = "C", convention = ".C")
> ##D cubefn4(20, 1:20)
> ##D 
> ## End(Not run)
> 
>  ## use of a module in F95
> modct <- "module modcts
+ double precision, parameter :: pi = 3.14159265358979
+ double precision, parameter :: e = 2.71828182845905
+ end"
> 
> getconstants <- "x(1) = pi
+ x(2) = e"
> 
> cgetcts <- cfunction(getconstants, module = "modcts", implicit = "none",
+   includes = modct, sig = c(x = "double"), dim = c("(2)"), language = "F95")
> 
> cgetcts(x = 1:2)  
$x
[1] 3.141593 2.718282

> print(cgetcts)
An object of class 'CFunc'
function (x) 
.Primitive(".Fortran")(<pointer: fe1a0560>, x = as.double(x))
<environment: 897a448>
code:
  1: module modcts
  2: double precision, parameter :: pi = 3.14159265358979
  3: double precision, parameter :: e = 2.71828182845905
  4: end
  5:  SUBROUTINE file1ab5771c39b8 ( x )
  6: USE modcts
  7: IMPLICIT none
  8: DOUBLE PRECISION x(2)
  9: x(1) = pi
 10: x(2) = e
 11: RETURN
 12: END
 13: 
> 
> ## Use of .C convention with C code
> ## Defining two functions, one of which calls the other
> sigSq <- signature(n="integer", x="numeric")
> codeSq <- "
+   for (int i=0; i < *n; i++) {
+     x[i] = x[i]*x[i];
+   }"
> sigQd <- signature(n="integer", x="numeric")
> codeQd <- "
+   squarefn(n, x);
+   squarefn(n, x);
+ "
> 
> fns <- cfunction( list(squarefn=sigSq, quadfn=sigQd), 
+                   list(codeSq, codeQd), 
+                   convention=".C")
> 
> squarefn <- fns[["squarefn"]]
> quadfn <- fns[["quadfn"]]
> 
> squarefn(n, x)$x

 *** caught segfault ***
address fd610760, cause 'memory not mapped'

Traceback:
 1: .Primitive(".C")(<pointer: fd610760>, n = as.integer(n), x = as.double(x))
 2: squarefn(n, x)
An irrecoverable exception occurred. R is aborting now ...