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 7691711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:41:15+00:00 2026-05-31T20:41:15+00:00

I am wondering if it is possible in R to use a value that

  • 0

I am wondering if it is possible in R to use a value that is declared in a function call as a “variable” part of the function itself, similar to the functionality that is available in SAS IML.

Given something like this:

put.together <- function(suffix, numbers) {
new.suffix <<- as.data.frame(numbers)
return(new.suffix)
}

x <- c(seq(1000,1012, 1))
put.together(part.a, x)

new.part.a   ##### does not exist!!

new.suffix   ##### does exist

As it is written, the function returns a dataframe called new.suffix, as it should because that is what I’m asking it to do.

I would like to get a dataframe returned that is called new.part.a.


EDIT: Additional information was requested regarding the purpose of the analysis

The purpose of the question is to produce dataframes that will be sent to another function for analysis.

There exists a data bank where elements are organized into groups by number, and other people organize the groups
into a meaningful set.

Each group has an id number. I use the information supplied by others to put the groups together as they are specified.

For example, I would be given a set of id numbers like: part-1 = 102263, 102338, 202236, 302342, 902273, 102337, 402233.

So, part-1 has seven groups, each group having several elements.

I use the id numbers in a merge so that only the groups of interest are extracted from the large data bank.

The following is what I have for one set:

### all.possible.elements.bank <- .csv file from large database ###

id.part.1 <- as.data.frame(c(102263, 102338, 202236, 302342, 902273, 102337, 402233))
bank.names <- c("bank.id")
colnames(id.part.1) <- bank.names
part.sort <- matrix(seq(1,nrow(id.part.1),1)) 
sort.part.1 <- cbind(id.part.1, part.sort)

final.part.1 <- as.data.frame(merge(sort.part.1, all.possible.elements.bank, 
by="bank.id", all.x=TRUE))

The process above is repeated many, many times.

I know that I could do this for all of the collections that I would pull together, but I thought I would be able to wrap the selection process into a function. The only things that would change would be the part numbers (part-1, part-2, etc..) and the groups that are selected out.

  • 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-31T20:41:16+00:00Added an answer on May 31, 2026 at 8:41 pm

    It is possible using the assign function (and possibly deparse and substitute), but it is strongly discouraged to do things like this. Why can’t you just return the data frame and call the function like:

    new.part.a <- put.together(x)
    

    Which is the generally better approach.

    If you really want to change things in the global environment then you may want a macro, see the defmacro function in the gtools package and most importantly read the document in the refrences section on the help page.

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

Sidebar

Related Questions

I was wondering if its possible to use Javascript to change the function/method that
I am wondering if it is possible to use Linq functionality to connect to
I was wondering if its possible to use the Google maps IFRAME code to
Just wondering if it's possible to use an XMLHTTPReq to login to a website,
I am wondering if it is possible to use an if statement or a
I'm currently wondering how it is possible to use the Groovy ORM Layer from
I'm wondering if it's possible to use a wildcard to select multiple cookies. I'm
first time use JTree. Just wondering is it possible to have more than one
I'm wondering if it's possible (recommended might be the better word) to use sed
I am trying to use Karaf and I was wondering if it is possible

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.