hello_world: Calling a Function Written with R's C API

Description Usage Examples

View source: R/c-api-call.R

Description

This function provides an example of how to call a function written using R's C API. The function itself redirects output from the printf() stream to R's Rprintf() so that it can be captured and manipulated.

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Gregor's suggestion
captured_data = capture.output(hello_world())

# Using sink around multiple function calls to redirect output
# to a single file
sink("sink-examp.txt")
hello_world()
sink()

input_data = readLines("sink-examp.txt")

all.equal(input_data, captured_data)

coatless/printf2Rprintf documentation built on May 16, 2019, 6:58 p.m.