Assigning global variables from inside a function - R

0 votes
I know that i can use the global variables declared outside a function, but is there a way to declare global variables from inside a function?
May 14, 2018 in Data Analytics by DataKing99
• 8,100 points
46 views

1 answer to this question.

Your answer

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

You can assign global variables from inside the function using "<<-"  operator.

Let me demonstrate that using this example:

abc<-function(){
  num1<<-10
  print(num1)
}
num1
[1] 10
answered May 14, 2018 by Bharani
• 4,550 points

Related Questions In Data Analytics

0 votes
1 answer

R programming: How to pass variables from a r program to mysql function?

To include the R variables called start.date and end.date, you can use paste to ...READ MORE

answered Dec 28, 2018 in Data Analytics by Tyrion anex
• 8,280 points
55 views
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
338 views
0 votes
1 answer

R function for finding the index of an element in a vector?

Yes, we can find the index of ...READ MORE

answered Apr 13, 2018 in Data Analytics by zombie
• 3,690 points
88 views
0 votes
2 answers

How to remove NA values from a Vector in R?

data = data[!is.na(data)]\ READ MORE

answered Apr 5 in Data Analytics by anonymous
3,980 views
0 votes
1 answer

How to set global variables in R

To set global variables, you can use ...READ MORE

answered Apr 23, 2018 in Data Analytics by kappa3010
• 2,010 points
63 views
0 votes
1 answer

How to remove all variables except functions in R?

One line that removes all objects except for functions: rm(list ...READ MORE

answered Apr 24, 2018 in Data Analytics by DeepCoder786
• 1,700 points
91 views
0 votes
1 answer

Big Data transformations with R

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

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
28 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,550 points
31 views
0 votes
1 answer

Extracting numeric columns from a data.frame - R

You can use the select_if() function from ...READ MORE

answered May 4, 2018 in Data Analytics by Bharani
• 4,550 points
515 views
0 votes
1 answer

Discarding duplicate rows from a data.frame - R

You can use distinct() function along with ...READ MORE

answered May 4, 2018 in Data Analytics by Bharani
• 4,550 points
28 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.