1

I was wondering if there are any simple ways to implement user interaction in executing a script in R?

For example if I have a simple function that adds data to an existing dataframe. I would like to let the user decide if additional data should be added or not. Is there a way I could implement this decision process as a command prompt in the console? For example if the user types 'yes' in the console, the adding of data or just a function is executed and if the user types 'no' it is not executed?

Here some example code which adds data_add to data

Input <- file.choose()
data_add <- read.csv(Input, sep=";", header=TRUE, stringsAsFactors=FALSE)
data_new <- rbind(data, data_add)

Has anyone of you implemented such user action in a script and maybe has an easy approach to handling this?

1 Answer 1

1

A quick Google search pointed me to the svDialogs package. Try

library(svDialogs)
okCancelBox("Hello")

it returns TRUE / FALSE and you can use that

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.