Questions tagged [rename]

For anything regarding renaming. Could be applicable to a wide range of subjects. Should be replaced by a more domain-specific tag if applicable.

Questions regarding renaming one or many files, directories, projects, variables, users, data cells, and version control conflicts arising from renaming should be tagged with rename.

To rename a file means to give an existing file a new name without changing any of its content. In UNIX systems, this is done with the mv command.

Renaming a variable will usually require a find-and-replace edit in existing code.

5438 questions
1
vote
2 answers

Pandas - Rename columns by removing text before delimiter

Given below are the column names of my Dataframe ['user_id', 'Week 36~Sep-05 - Sep-11', 'Week 35~Aug-29 - Sep-04', 'Week 34~Aug-22 - Aug-28'] I would like remove the text before the delimiter (~) if it is there in the column label and get the…
Kevin Nash
  • 1,511
  • 3
  • 18
  • 37
1
vote
3 answers

Dplyr: Conditionally rename multiple variables with regex by name

I need to rename multiple variables using a replacement dataframe. This replacement dataframe also includes regex. I would like to use a similar solution proposed here, .e.g df %>% rename_with(~ newnames, all_of(oldnames)) MWE: df <- mtcars[,…
Julian
  • 6,586
  • 2
  • 9
  • 33
1
vote
0 answers

How to automatically replace a special character in the installation path on Inno Setup?

I am making a mod for a game. My problem is that in the windows registry the path of the game has a character that is different from the path that it should be. Windows Registry: D:\SteamLibrary\steamapps\common[NINJA GAIDEN Master Collection] NINJA…
Hunter_ARG
  • 11
  • 3
1
vote
2 answers

How could one rename a batch of column names in R and change only one digit, leaving the rest of the name the same?

I have data from one survey with 30 items collected over two waves (i.e., time points). Items are labeled as follows: item1w1, item2w1, item3w1, etc., where w1 = wave 1. How can I rename all items by only changing the w1 to w2, leaving the rest of…
cory
  • 49
  • 4
1
vote
3 answers

How to iteratively rename a file if it already exists (Python)

I have a list of image URLs which I would like to retrieve iteratively with urllib. The issue I am finding is that once I nominate the file path of the image to be saved, I cannot iteratively change the file path to reflect the fact that a new file…
1
vote
3 answers

How do I create a variable from database inquiry to change photo name

I Hope someone can help me solve this problem I have. I have been working on it for days and so many similar questions and answers are over my head. I'm trying my best to figure it out. So far, I am getting close. I am totally new to some of this. I…
Mark
  • 11
  • 1
1
vote
1 answer

R purrr rename columns using multiple str_replace

I have the following tibble tib <- tibble(AAA111 = rnorm(3), AAA222 = rnorm(3), BBB5 = rnorm(3), BBB3456=rnorm(3)) I want to change the component of column names such that "AAA" becomes "M" and…
Andrew
  • 111
  • 4
1
vote
2 answers

Check conditions in two columns in R and print letter into another column

I would like to calculate in R: if in my df in column 2 the value is 1 for example and in column 3 the value is 1, then write in a new column 4 "TP". col1 <- c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4) col2 <-…
timtams
  • 101
  • 6
1
vote
1 answer

rename files in a folder based on a text file ordering

I have a ton of files but they are ordered randomly as they were generated all at the same time. I have a text file with the names of the files in the correct order. I want to rename the files in the folder to follow the text file like this: if the…
sourlemonaid
  • 504
  • 2
  • 6
  • 19
1
vote
0 answers

Rename files with different suffixes with only one new suffix

I am trying to modify a pipeline for viral taxonomy analysis. In this pipeline, the variables R1 and R2 are the two input paired-end fastq files. But theses files can be .fastq.gz or .fq.gz. After trimming of these fastq files with the program…
ltalignani
  • 11
  • 2
1
vote
1 answer

Is it possible to use multiple functions within rename_with()?

If I had a dataframe: df <- tribble( ~col_A_new, ~col_B_old, ~var_A_new, ~var_B_old, ~ID, 1, 2, 3, 4, "A", 2, 3, NA, 4, "B", 3, NA, NA, NA, "C", 4, NA, NA, 5, "D") A tibble: 4 × 5 col_A_new col_B_old var_A_new var_B_old ID
Tom
  • 279
  • 1
  • 12
1
vote
0 answers

Go: How to Rename Interface Functions and Affect Implementations?

I'm using Visual Studio Code with the official Go extension and the official Go tools. My Go version is go1.19. When I rename an interface's function, it doesn't affect its implementations which leads to to compiler errors. Sample Code: package…
Floating Sunfish
  • 4,920
  • 5
  • 29
  • 48
1
vote
1 answer

change rownames in a list of data.frames using a master data.frame

I have a bunch of lists, and I want to rename the rows using a master data.frame. Here's an example list I created: df <- data.frame(Value = c(1, 0, 6, 3, 4)) rownames(df) <- c("B144","B211","B678","B111", "B7090") df2 <- data.frame(Value = c(0, 0,…
E Norton
  • 83
  • 4
1
vote
2 answers

How to rename local files on machine in R?

I am trying to rename 90 PDF files on my machine to a specific format. My current files are named as such: file_name…
Jaskeil
  • 1,044
  • 12
  • 33
1
vote
1 answer

How rename specific columns in PySpark?

I have a dataframe in PySpark, result of a groupBy with agg. Like this: df1 = df.groupBy(['data', 'id']).pivot('type').agg(F.sum('value').alias("Values"), F.count('value').alias("Quantity")) But I need to put the alias ("Values" and "Quantity) as…