create new variable using assign variable

I want to create a new variable using assign variable value in r just like a macro using in SAS.

For example:-



It should be written as my_RC090015_code<-xyz.

so my requirement is i want to use ID variable for creating new variable for code generalization purpose. Means suppose i just change the ID variable value so it should be change in all further variable where i used ID variable.

So please help me is there any function in r to include that ID variable for creating new variable including ID value.

Thanks in Advance.


We can use assign

assign(paste("my", ID, "code", sep="_"), xyz)
#[1] 24

It should work also for the subset datasets


#   Terminal_ID val
#1:    RC090015  24
#2:    RC090015  22
xyz <- 24
SUBSET_DATA_MAIN <- data.table(Terminal_ID= c("RC090015",
       "RC090017", "RC090015"), val= c(24, 23, 22))

Need Your Help

Disable or Remove 'Create Account' option from one drive authentication page

ios onedrive

I am trying to integrate onedrive for my ios app. I am using onedrive ios sdk for that. I am calling ODClient.authenticatedClientWithCompletion for launching authentication screen. This does launch

Custom validation Not Working in yii

php validation yii

I am new to Yii. I have a view which inputs host_start_date and host_end_date. While entering these dates, it must be validated. Validation Rules are as follows: