The answer to your question is concordant with the answer to: Why x
is not found in the example below?
f <- function() {
x <- 10
}
f()
print(x)
## Error: object 'x' not found
Look at the env
arg of RCpp:cppFunction
. You may e.g. pass env=globalenv()
to bind func0_with_RString
in the global environment.
But this is definitely not the right way to define a function (unless you're just curious). Refer to @DirkEddelbuettel's comments on the matter.