In R how to get an object s name after it is sent to a function

0 votes
I'm trying to find the opposite of obtain ().

I want to immediately extract the character string that corresponds to an item based on its name.

Simple illustration using foo as a stand-in for the function I'm looking for.

Z is equal to data.frame(x=1:10, y=1:10).

function(a) test

Mean(a$x) = mean.x

print(foo(a))

return(mean.x)}

test(z)

If printed:

"z"

My solution, which is more difficult to put into practise in my current issue, is:

function(a="z") test

Mean(get(a)$x) = mean.x

print(a)

return(mean.x)}

test("z")
Jul 5, 2022 in Data Science by avinash
• 1,840 points
172 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Data Science

0 votes
0 answers

How to read a csv-file from an url in R?

I'm not very experienced with R, so ...READ MORE

Jul 22, 2022 in Data Science by avinash
• 1,840 points
380 views
0 votes
1 answer

How to make loop for one-at-a time logistic regression in R?

You're probably looking for something similar to ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
771 views
0 votes
1 answer

Why is it not advisable to use attach() in R, and what should I use instead?

There is one more option that applies ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
281 views
0 votes
1 answer

How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
267 views
0 votes
0 answers

To speed up the tapply function in R, or another function to convert data frame into a matrix

I must turn a sizable dataset into ...READ MORE

Jun 24, 2022 in Data Science by Sohail
• 3,040 points
201 views
0 votes
0 answers

How to manually find the minors of a matrix in R programming?

I have to write a function that ...READ MORE

Jul 5, 2022 in Data Science by avinash
• 1,840 points
302 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
756 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
829 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,536 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
849 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP