I have two data frames. One is called dfnew15 and the other one is called dfnew22. I did some easy data cleaning with the dfnew15 data frame with about 100 lines of code. Each line of code features the name "dfnew15$column1" "dfnew15$colum2".
Is there a way to change all of those dfnew15 to dfnew22 without clicking in and changing them manually? If so, how would that work? I want to make sure I would not miss anything from 15 in the 22 data frame, but doing what I want manually is a pain.
The line of code I would like to change on mass is a variation of:
dfnew15$Town <- ifelse(dfnew15$Town == "Manhattan", "New York City", dfnew15$Town)
dfnew15$Town <- ifelse(dfnew15$Town == "Bay Area", "San Francisco", dfnew15$Town)
etc.
I thought I might just be able to copy the R-script text, paste it into a txt file, import that into my global environment and then do
txtfileAsDataFrame <- gsub('dfnew15', 'dfnew22', txtfileAsDataFrame)
export the txtfileAsDataFrame and then just copy the changed document into a fresh script with all my data frames being called dfnew22.
But unfortunately I only get the changed data as a value, not as a data frame. Also I would guess there to be a more elegant option to do this than importing and exporting txtfiles.
Thank you for any help, hint or tip!