Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4254398
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:04:43+00:00 2026-05-21T05:04:43+00:00

I’m currently calling rp.slider from the tkrplot library with multiple arguments in a loop,

  • 0

I’m currently calling rp.slider from the tkrplot library with multiple arguments in a loop, for example:

rp.slider(rpplot, param1)
rp.slider(rpplot, param2)

etc.

Ideally, I’d like to do this within a loop, e.g.

for(i in 1:10) 
  rp.slider(rpplot, foo(paste(param,i,sep="")))

Where foo will encode the string to a variable name (symbol?). rp.slider converts the argument into a string using deparse(substitute(var)). Is there a foo function that will let me do this? I’ve tried as.symbol, as.name, and parse (among others) without success.

Any help would be much appreciated!


To clarify, deparse(substitute(x)) returns [1] "x" – I’d like a way of returning the same output from a string, i.e. which foo outputs [1] "x" for input deparse(substitute(foo("x")))? Is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:04:44+00:00Added an answer on May 21, 2026 at 5:04 am

    Tryeval(parse(text=...)) or eval(substitute(...)).

    parse(text=...) turns the string in an expression, eval evaluates the expression. Be sure to use the text argument, as parse normally looks for a file. Forgetting that is a common mistake. See also ?parse and ?eval.

    > a <- 10
    > x <- deparse(substitute(a))
    > eval(parse(text=x))
    [1] 10
    

    To show how to use it, your adjusted code :

    for(i in 1:10)
      eval(parse(text=paste("rp.slider(rpplot,param",i,")",sep="")))
    

    substitute substitutes values in a language object by the strings given in the second argument :

    for(i in 1:10)
      eval(
        substitute(
          rp.slider(rpplot,x),
          list(x=as.name(paste("param",i,sep="")))
        )
      )
    

    Or, using the example in the help files :

    library(rpanel)
    rpplot <- rp.control(title = "Demonstration of rp.tkrplot", h = 1,j=1)
    
    redraw <- function(panel) {
      rp.tkrreplot(panel, tkrp)
    }
    x <- c('h','j')
    rp.tkrplot(rpplot, tkrp, function(panel) plot((1:20)^panel$j, (1:20)^panel$h))
    
    eval(parse(text=paste("rp.slider(rpplot, ",x[1]," , action = redraw,
        from = 0.05, to = 2.00, resolution = 0.05)")))
    
    eval(
      substitute(
        rp.slider(rpplot, x, action=redraw, from=0.05, to=2.00, resolution=0.05),
        list(x = as.name(x[2]))
      )
    )
    

    The explanation why this is necessary, can be found within the source code of rp.slider. The construct to get the varname inside the function is not the standard used in R. In fact, the use of ‘deparse(substitute())’ is strongly discouraged, exactly for this reason. With most functions, as.expression("x") works to get the variable in using a variable name. Alas, the author of the rpanel package made this impossible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.