Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about relocate

Read more about relocate

python (65.2k questions)

javascript (44.3k questions)

reactjs (22.7k questions)

java (20.8k questions)

c# (17.4k questions)

html (16.3k questions)

r (13.7k questions)

android (13k questions)

Questions - relocate

How can I relocate mutated columns next to the original colums?

I have made a function which mutates across columns and creates new named columns from each of them. The new colums are put to the right side of the dataframe whereas I would like to have them adjacen...
test-img

Mico Hamlyn

r

function

dplyr

across

relocate

Votes: 0

Answers: 3

Latest Answer

I typically sort the columns with select(sort(names(.))) afterwards: library(dplyr) test_data %>% perc_funct(columns = starts_with("data"), numerator = 1) %>% select(sort(names(...
test-img

jpiversen

Move several chunks of columns dynamically to another position

My data is: df <- data.frame(a = 1:2, x = 1:2, b = 1:2, y = 3:4, x_2 = 1:2, y_2 = 3:4, ...
test-img

deschen

r

tidyverse

relocate

Votes: 0

Answers: 4

Latest Answer

In base R: df[match(c('a', 'x', 'x_2', 'x_3', 'b', 'y', 'y_2', 'y_3', 'c'), names(df))] #> a x x_2 x_3 b y y_2 y_3 c #> 1 1 1 1 5 1 3 3 1 1 #> 2 2 2 2 6 2 4 4 2 2
test-img

Allan Cameron

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved