Secure way to accept user input for shiny apps

August 31, 2018 @Mathematics John

@Mathematics wrote:

Hello ...
I am using R shiny to develop mathematics APPS where I use the function eval() to convert string numbers from user to numeric inputs in R. For example, to accept the vector: v = (3, 4/11, pi/2, sqrt(13)), I use the textInput function then convert it to numeric values using .the following code.

_v = as.character(input$v)_
_v = strsplit(v,",")_
_v = v[[1]]_
_vv = v_
_vi = rep(0,times = length(v))_
_for (i in 1:length(vv)){_
_  vi[i] = eval(parse(text = vv[i])) # convert to numeric ***_
_v = vi_

My problem is that I read on Stackflow that eval() function should never be used if an R shiny app is to be hosted online. Is there a secure way to capture this input.

I also use the same to accept mathematical functions. For example, a user enters a function like exp(x) * sin(x) in the input field, then I convert it to an R function using the line below.

_f = function(x) {eval(parse(text = input$func))}_

Thank you for any help or suggestion.

Posts: 3

Participants: 2

Read full topic

Previous Article
[Video] Reproducible Examples and the `reprex` package
[Video] Reproducible Examples and the `reprex` package

@jennybryan wrote: Reproducible Examples and the reprex package. IntroBasic usa...

Next Article
Suggestions for pointing out bad statistical practice
Suggestions for pointing out bad statistical practice

@jrlewi wrote: Hello - Occasionally, I will see questions pop up that indicates...