R cbind with get paste

0 votes
How can I define column names with a function get(paste()) within cbind() or rbind() or bind_cols()? Or what would be the alternative solution?
Jun 1, 2022 in Data Science by Avinash
• 240 points
719 views

1 answer to this question.

0 votes

This is how we use column names

x <- data.frame(a, j)
colnames(x)[2] <- get(paste('var', i, sep=""))

Or we can also use tibble

tibble(a, !! b := j)
answered Jun 1, 2022 by Sohail
• 3,040 points

Related Questions In Data Science

0 votes
0 answers

Introduction to Statistical Learning with Applications in R Figure Codes

I recently bought the following book: An Introduction ...READ MORE

Jun 1, 2022 in Data Science by avinash
• 1,840 points
563 views
0 votes
0 answers

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

I'm trying to find the opposite of ...READ MORE

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

How do I get a list of built-in data sets in R?

Please advise on how to obtain the ...READ MORE

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

How does cut with breaks work in R

I've tried using?cut but haven't been able ...READ MORE

Jul 6, 2022 in Data Science by avinash
• 1,840 points
520 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,180 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,113 views
0 votes
1 answer

Creating new Functions with Linear Regression in R :

When we want to create a model ...READ MORE

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

Problem with sample function in R

The first time works, but after that, ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
485 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