Hello World Agent
1
2
Use a Node.js client to call the R code
const { VrpcRemote } = require('vrpc')
if (process.argv.length < 3) {
console.log('Usage: node index.js <agentName>')
process.exit(1)
}
// retrieve agent name from command line
const agent = process.argv[2]
async function main () {
// create and connect VRPC client
const client = new VrpcRemote({ agent, domain: 'public.vrpc' })
await client.connect()
// call the R function as static function of the Session class
const ret = await client.callStatic({
className: 'Session',
functionName: 'greet',
args: ['world!']
})
// print the result
console.log(ret) // Hello, world!
}
main()npm installnode index.js <yourAgent>Last updated