left_join in loop with changing conditions in RA 'for' loop to iterate over an enum in JavaLoop through an array in JavaScriptGather multiple sets of columnsmerging two dataframes creates extra rows in RSubset dataframe based on the condition in a column of another dataframeLeft Join in R (dplyr) - Too many observations?word(s) frequency scatterplot or comparing word clouds in RMerge R data frame or data table and overwrite values of multiple columnsApply column name change to a list of data frames but the changes were not reflected in the original data framesCoefficient of Divergence - how to code loop more efficiently?

How do I gain back my faith in my PhD degree?

Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?

What do you call someone who asks many questions?

What is the most common color to indicate the input-field is disabled?

Watching something be piped to a file live with tail

Am I breaking OOP practice with this architecture?

Why would the Red Woman birth a shadow if she worshipped the Lord of the Light?

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

Gatling : Performance testing tool

CAST throwing error when run in stored procedure but not when run as raw query

How do I deal with an unproductive colleague in a small company?

What is a romance in Latin?

Should I cover my bicycle overnight while bikepacking?

Is it possible to create a QR code using text?

Is it acceptable for a professor to tell male students to not think that they are smarter than female students?

Could the museum Saturn V's be refitted for one more flight?

What does “the session was packed” mean in this context?

Can a virus destroy the BIOS of a modern computer?

Do scales need to be in alphabetical order?

Is it logically or scientifically possible to artificially send energy to the body?

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

What method can I use to design a dungeon difficult enough that the PCs can't make it through without killing them?

What killed these X2 caps?



left_join in loop with changing conditions in R


A 'for' loop to iterate over an enum in JavaLoop through an array in JavaScriptGather multiple sets of columnsmerging two dataframes creates extra rows in RSubset dataframe based on the condition in a column of another dataframeLeft Join in R (dplyr) - Too many observations?word(s) frequency scatterplot or comparing word clouds in RMerge R data frame or data table and overwrite values of multiple columnsApply column name change to a list of data frames but the changes were not reflected in the original data framesCoefficient of Divergence - how to code loop more efficiently?













-1















I have a dataset of approx 15000 individual causes of death (CoD) from the 19th century, where the aim is to a) standardize each word/cause and b) apply codes for later analysis. My question relates to standardization.
I have two data frames:



I - oriCoD1. This data contains the original CoD, and 32 additional columns where each CoD is parsed into multiple columns, separated by space, and named in alphabetic order; 'a', 'b', 'c', etc.



II - standard: Standard has two columns; the original word and the standardized word, where the original words only appear once. The standardized words match any possible spelling from any column 'a' to 'ae' in oriCoD. The joint column is the original word in standard and 'a' to 'ae' in oriCoD.



I have been able to do the joint column by column, like this:




oriCoD2<-left_join(oriCoD1, standard, by=c('a'))

standard<-rename(standard, c("a"="b"))
oriCoD3<-left_join(oriCoD2, standard, by=c('b'))

standard<-rename(standard, c("b"="c"))
oriCoD4<-left_join(oriCoD3, standard, by=c('c'))

[...]


Instead of writing this out 32 times, Is there a way to do this in a loop?










share|improve this question



















  • 2





    Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (use dput to get them into a format you can paste into the text of the question. This will let us understand your problem and find a solution.

    – divibisan
    Mar 21 at 21:36















-1















I have a dataset of approx 15000 individual causes of death (CoD) from the 19th century, where the aim is to a) standardize each word/cause and b) apply codes for later analysis. My question relates to standardization.
I have two data frames:



I - oriCoD1. This data contains the original CoD, and 32 additional columns where each CoD is parsed into multiple columns, separated by space, and named in alphabetic order; 'a', 'b', 'c', etc.



II - standard: Standard has two columns; the original word and the standardized word, where the original words only appear once. The standardized words match any possible spelling from any column 'a' to 'ae' in oriCoD. The joint column is the original word in standard and 'a' to 'ae' in oriCoD.



I have been able to do the joint column by column, like this:




oriCoD2<-left_join(oriCoD1, standard, by=c('a'))

standard<-rename(standard, c("a"="b"))
oriCoD3<-left_join(oriCoD2, standard, by=c('b'))

standard<-rename(standard, c("b"="c"))
oriCoD4<-left_join(oriCoD3, standard, by=c('c'))

[...]


Instead of writing this out 32 times, Is there a way to do this in a loop?










share|improve this question



















  • 2





    Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (use dput to get them into a format you can paste into the text of the question. This will let us understand your problem and find a solution.

    – divibisan
    Mar 21 at 21:36













-1












-1








-1








I have a dataset of approx 15000 individual causes of death (CoD) from the 19th century, where the aim is to a) standardize each word/cause and b) apply codes for later analysis. My question relates to standardization.
I have two data frames:



I - oriCoD1. This data contains the original CoD, and 32 additional columns where each CoD is parsed into multiple columns, separated by space, and named in alphabetic order; 'a', 'b', 'c', etc.



II - standard: Standard has two columns; the original word and the standardized word, where the original words only appear once. The standardized words match any possible spelling from any column 'a' to 'ae' in oriCoD. The joint column is the original word in standard and 'a' to 'ae' in oriCoD.



I have been able to do the joint column by column, like this:




oriCoD2<-left_join(oriCoD1, standard, by=c('a'))

standard<-rename(standard, c("a"="b"))
oriCoD3<-left_join(oriCoD2, standard, by=c('b'))

standard<-rename(standard, c("b"="c"))
oriCoD4<-left_join(oriCoD3, standard, by=c('c'))

[...]


Instead of writing this out 32 times, Is there a way to do this in a loop?










share|improve this question
















I have a dataset of approx 15000 individual causes of death (CoD) from the 19th century, where the aim is to a) standardize each word/cause and b) apply codes for later analysis. My question relates to standardization.
I have two data frames:



I - oriCoD1. This data contains the original CoD, and 32 additional columns where each CoD is parsed into multiple columns, separated by space, and named in alphabetic order; 'a', 'b', 'c', etc.



II - standard: Standard has two columns; the original word and the standardized word, where the original words only appear once. The standardized words match any possible spelling from any column 'a' to 'ae' in oriCoD. The joint column is the original word in standard and 'a' to 'ae' in oriCoD.



I have been able to do the joint column by column, like this:




oriCoD2<-left_join(oriCoD1, standard, by=c('a'))

standard<-rename(standard, c("a"="b"))
oriCoD3<-left_join(oriCoD2, standard, by=c('b'))

standard<-rename(standard, c("b"="c"))
oriCoD4<-left_join(oriCoD3, standard, by=c('c'))

[...]


Instead of writing this out 32 times, Is there a way to do this in a loop?







r for-loop dplyr left-join






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 15:06







Sommerseth

















asked Mar 21 at 21:27









SommersethSommerseth

42




42







  • 2





    Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (use dput to get them into a format you can paste into the text of the question. This will let us understand your problem and find a solution.

    – divibisan
    Mar 21 at 21:36












  • 2





    Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (use dput to get them into a format you can paste into the text of the question. This will let us understand your problem and find a solution.

    – divibisan
    Mar 21 at 21:36







2




2





Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (use dput to get them into a format you can paste into the text of the question. This will let us understand your problem and find a solution.

– divibisan
Mar 21 at 21:36





Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (use dput to get them into a format you can paste into the text of the question. This will let us understand your problem and find a solution.

– divibisan
Mar 21 at 21:36












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289500%2fleft-join-in-loop-with-changing-conditions-in-r%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289500%2fleft-join-in-loop-with-changing-conditions-in-r%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript