# NOT RUN {
x <- as.numeric(1:10)
n <- as.integer(10)
code <- "
integer i
do 1 i=1, n(1)
1 x(i) = x(i)**3
"
cubefn <- cfunction(signature(n="integer", x="numeric"), code, convention=".Fortran")
code(cubefn)
cubefn(n, x)$x
# }
# NOT RUN {
fname <- tempfile()
writeDynLib(cubefn, file = fname)
# load and assign different name to object
cfn <- readDynLib(fname)
print(cfn)
cfn(2, 1:2)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab