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?
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
add a comment |
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
2
Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (usedput
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
add a comment |
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
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
r for-loop dplyr left-join
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 (usedput
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
add a comment |
2
Please include a Minimal, Complete, and Verifiable example of your problem with toy versions of each data set (usedput
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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