Accessing a value from Server.R into .js file
javascript, r, shiny
Solution
Thanks to jdharrison, it works when I add the following code in myFile.js :
Server.R
number <- 5
observe({
session$sendCustomMessage(type='myCallbackHandler', number)
})
myFile.js
var i ;
Shiny.addCustomMessageHandler("myCallbackHandler",
function(number) {
i = number;
}
);
var i now takes the value 5 in my javascript file.
Problem
I think's it's quite an easy one but I can't find a way to solve it myself. I'd like to access the value of a variable in my Server.R file (I'm using Shiny) in my javascript file. My var "i" in myFile.js should take the value of my R variable "number". How should I proceed ? Example : Server.R ``` ... number <- 5 ... ``` myFile.js ``` ... var i = ??? // var i = number *is not working* ... ``` Thanks for your help, Matt