Create data frame from function in R

0 votes
One function that I designed can produce a data frame is as follows: (This feature alters the entire environment!)

If y >= 11, halt abc by saying "Noooooooooooooooooooooooooope!"
value for is NA (i in 1:10) { a=2+i\s b=3
value[i] = (x + a)* (b + y)
df=data.frame(ID=(1:10),Value=(value))
View(df) assign("df",df,envir =.GlobalEnv)
abc(2,9)
A data frame created by this function looks like this:

Identifier Value 1 1 135 2 2 162 3 3 189 4 4 216 5 5 243 6 6 270 7 7 297 8 8 324 9 9 351 10 10 378
However, I now need to make a "large" data frame with extra columns. For arguments a, b, c, and d, respectively,.... abc (13,9). The updated data frame will appear as follows:

ID Number Value1 Value2 Value3... 1 1 108 135... 2 2 135... 3 3 162... 4 4 189... 216
Jul 9, 2022 in Data Analytics by avinash
• 1,840 points
780 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 Analytics

0 votes
1 answer

Create a tree model in R from data.frame?

See the below example to understand how ...READ MORE

answered Aug 30, 2019 in Data Analytics by anonymous
• 33,030 points
1,741 views
0 votes
1 answer

Drop unused levels from a data frame in R

You can use this command droplevels() y <- ...READ MORE

answered Jun 14, 2018 in Data Analytics by DataKing99
• 8,250 points
1,979 views
0 votes
1 answer

create data.frame with random numbers in R

First create a matrix with random numbers ...READ MORE

answered Sep 24, 2019 in Data Analytics by Debasmita Das
3,098 views
0 votes
1 answer

Create train and test data from dataset in R

Hi, Use sample or sample.split function to create ...READ MORE

answered Oct 14, 2019 in Data Analytics by anonymous
• 33,030 points
3,276 views
0 votes
1 answer
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,810 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,570 points
1,030 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
1,178 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,890 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
1,111 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