javascript-to-r function wrapping working