How do I merge objects with the same character within a column?How to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)How to sum a variable by groupGrouping functions (tapply, by, aggregate) and the *apply familyTools for making latex tables in RAdd new row to dataframe, at specific row-index, not appended?R- format a data.frame into another 'combined' data.frame based on common values within a column dependent across different columnsdata.table vs dplyr: can one do something well the other can't or does poorly?Merging columns with column names from listHow to display individual objects in a column

Has there ever been an airliner design involving reducing generator load by installing solar panels?

Arrow those variables!

Perform and show arithmetic with LuaLaTeX

How old can references or sources in a thesis be?

Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

RSA: Danger of using p to create q

Could an aircraft fly or hover using only jets of compressed air?

What's the output of a record needle playing an out-of-speed record

Can I ask the recruiters in my resume to put the reason why I am rejected?

Why do I get two different answers for this counting problem?

Convert two switches to a dual stack, and add outlet - possible here?

Can a Cauchy sequence converge for one metric while not converging for another?

I'm flying to France today and my passport expires in less than 2 months

What is the word for reserving something for yourself before others do?

Do infinite dimensional systems make sense?

Do I have a twin with permutated remainders?

How much of data wrangling is a data scientist's job?

Add text to same line using sed

Is it unprofessional to ask if a job posting on GlassDoor is real?

Does detail obscure or enhance action?

Revoked SSL certificate

How does quantile regression compare to logistic regression with the variable split at the quantile?

Is it possible to run Internet Explorer on OS X El Capitan?



How do I merge objects with the same character within a column?


How to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)How to sum a variable by groupGrouping functions (tapply, by, aggregate) and the *apply familyTools for making latex tables in RAdd new row to dataframe, at specific row-index, not appended?R- format a data.frame into another 'combined' data.frame based on common values within a column dependent across different columnsdata.table vs dplyr: can one do something well the other can't or does poorly?Merging columns with column names from listHow to display individual objects in a column






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Let's say I have a DF of just 1 column "Genre"
and within that Genre there are "Horror", "Romance", "Fiction" etc.



Genre



Horror
Horror
Romance
Fiction
Romance



How do I code so that I can combine the "Horror" objects to just one?
So basically, I want the table to show



Genre



Horror
Romance
Fiction



Thanks in advance










share|improve this question



















  • 2





    unique(DF$Genre)

    – G5W
    Mar 9 at 1:01











  • Let me revise my question sorry about that Let's say I have a DF of just 2 columns "Genre" and "score" within that Genre there are "Horror", "Romance", "Fiction" etc. Genre Score Horror 4 Horror 6 Romance 7 Fiction 3 Romance 10 How do I code so that I can combine the "Horror" objects to just one? So basically, I want the table to show Genre Score Horror mean(score) Romance mean(score) Fiction mean(score)

    – Thom JAckson
    Mar 9 at 1:11

















0















Let's say I have a DF of just 1 column "Genre"
and within that Genre there are "Horror", "Romance", "Fiction" etc.



Genre



Horror
Horror
Romance
Fiction
Romance



How do I code so that I can combine the "Horror" objects to just one?
So basically, I want the table to show



Genre



Horror
Romance
Fiction



Thanks in advance










share|improve this question



















  • 2





    unique(DF$Genre)

    – G5W
    Mar 9 at 1:01











  • Let me revise my question sorry about that Let's say I have a DF of just 2 columns "Genre" and "score" within that Genre there are "Horror", "Romance", "Fiction" etc. Genre Score Horror 4 Horror 6 Romance 7 Fiction 3 Romance 10 How do I code so that I can combine the "Horror" objects to just one? So basically, I want the table to show Genre Score Horror mean(score) Romance mean(score) Fiction mean(score)

    – Thom JAckson
    Mar 9 at 1:11













0












0








0








Let's say I have a DF of just 1 column "Genre"
and within that Genre there are "Horror", "Romance", "Fiction" etc.



Genre



Horror
Horror
Romance
Fiction
Romance



How do I code so that I can combine the "Horror" objects to just one?
So basically, I want the table to show



Genre



Horror
Romance
Fiction



Thanks in advance










share|improve this question
















Let's say I have a DF of just 1 column "Genre"
and within that Genre there are "Horror", "Romance", "Fiction" etc.



Genre



Horror
Horror
Romance
Fiction
Romance



How do I code so that I can combine the "Horror" objects to just one?
So basically, I want the table to show



Genre



Horror
Romance
Fiction



Thanks in advance







r






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 5:46









NelsonGon

3,6044834




3,6044834










asked Mar 9 at 0:57









Thom JAcksonThom JAckson

1




1







  • 2





    unique(DF$Genre)

    – G5W
    Mar 9 at 1:01











  • Let me revise my question sorry about that Let's say I have a DF of just 2 columns "Genre" and "score" within that Genre there are "Horror", "Romance", "Fiction" etc. Genre Score Horror 4 Horror 6 Romance 7 Fiction 3 Romance 10 How do I code so that I can combine the "Horror" objects to just one? So basically, I want the table to show Genre Score Horror mean(score) Romance mean(score) Fiction mean(score)

    – Thom JAckson
    Mar 9 at 1:11












  • 2





    unique(DF$Genre)

    – G5W
    Mar 9 at 1:01











  • Let me revise my question sorry about that Let's say I have a DF of just 2 columns "Genre" and "score" within that Genre there are "Horror", "Romance", "Fiction" etc. Genre Score Horror 4 Horror 6 Romance 7 Fiction 3 Romance 10 How do I code so that I can combine the "Horror" objects to just one? So basically, I want the table to show Genre Score Horror mean(score) Romance mean(score) Fiction mean(score)

    – Thom JAckson
    Mar 9 at 1:11







2




2





unique(DF$Genre)

– G5W
Mar 9 at 1:01





unique(DF$Genre)

– G5W
Mar 9 at 1:01













Let me revise my question sorry about that Let's say I have a DF of just 2 columns "Genre" and "score" within that Genre there are "Horror", "Romance", "Fiction" etc. Genre Score Horror 4 Horror 6 Romance 7 Fiction 3 Romance 10 How do I code so that I can combine the "Horror" objects to just one? So basically, I want the table to show Genre Score Horror mean(score) Romance mean(score) Fiction mean(score)

– Thom JAckson
Mar 9 at 1:11





Let me revise my question sorry about that Let's say I have a DF of just 2 columns "Genre" and "score" within that Genre there are "Horror", "Romance", "Fiction" etc. Genre Score Horror 4 Horror 6 Romance 7 Fiction 3 Romance 10 How do I code so that I can combine the "Horror" objects to just one? So basically, I want the table to show Genre Score Horror mean(score) Romance mean(score) Fiction mean(score)

– Thom JAckson
Mar 9 at 1:11












2 Answers
2






active

oldest

votes


















0














unique(DF$Genre)



or



DF %>%
distinct(Genre)





share|improve this answer























  • Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

    – Thom JAckson
    Mar 9 at 1:15











  • the distinct function in fact deletes the rest of the column (score)

    – Thom JAckson
    Mar 9 at 1:24


















0














You can get the table that you are looking for using the aggregate function.



## Your sample data
DF = read.table(text="Genre Score
Horror 4
Horror 6
Romance 7
Fiction 3
Romance 10",
header = TRUE)


Make the table



TAB = aggregate(DF$Score, list(DF$Genre), mean)
names(TAB) = c("Genre", "MeanScore")
TAB
Genre MeanScore
1 Fiction 3.0
2 Horror 5.0
3 Romance 8.5





share|improve this answer

























  • thank you so much. is there a way to change group.1 and x to another variable?

    – Thom JAckson
    Mar 9 at 1:32











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%2f55072956%2fhow-do-i-merge-objects-with-the-same-character-within-a-column%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














unique(DF$Genre)



or



DF %>%
distinct(Genre)





share|improve this answer























  • Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

    – Thom JAckson
    Mar 9 at 1:15











  • the distinct function in fact deletes the rest of the column (score)

    – Thom JAckson
    Mar 9 at 1:24















0














unique(DF$Genre)



or



DF %>%
distinct(Genre)





share|improve this answer























  • Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

    – Thom JAckson
    Mar 9 at 1:15











  • the distinct function in fact deletes the rest of the column (score)

    – Thom JAckson
    Mar 9 at 1:24













0












0








0







unique(DF$Genre)



or



DF %>%
distinct(Genre)





share|improve this answer













unique(DF$Genre)



or



DF %>%
distinct(Genre)






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 1:02









K.J.J.KK.J.J.K

12316




12316












  • Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

    – Thom JAckson
    Mar 9 at 1:15











  • the distinct function in fact deletes the rest of the column (score)

    – Thom JAckson
    Mar 9 at 1:24

















  • Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

    – Thom JAckson
    Mar 9 at 1:15











  • the distinct function in fact deletes the rest of the column (score)

    – Thom JAckson
    Mar 9 at 1:24
















Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

– Thom JAckson
Mar 9 at 1:15





Thanks a lot. If it doesnt trouble you, I want to know how I can make a summary of 2 columns genre and score. For example, "summarise(distinct(genre),mean(score))" doesn't work. The original DF contains the column genre,score.

– Thom JAckson
Mar 9 at 1:15













the distinct function in fact deletes the rest of the column (score)

– Thom JAckson
Mar 9 at 1:24





the distinct function in fact deletes the rest of the column (score)

– Thom JAckson
Mar 9 at 1:24













0














You can get the table that you are looking for using the aggregate function.



## Your sample data
DF = read.table(text="Genre Score
Horror 4
Horror 6
Romance 7
Fiction 3
Romance 10",
header = TRUE)


Make the table



TAB = aggregate(DF$Score, list(DF$Genre), mean)
names(TAB) = c("Genre", "MeanScore")
TAB
Genre MeanScore
1 Fiction 3.0
2 Horror 5.0
3 Romance 8.5





share|improve this answer

























  • thank you so much. is there a way to change group.1 and x to another variable?

    – Thom JAckson
    Mar 9 at 1:32















0














You can get the table that you are looking for using the aggregate function.



## Your sample data
DF = read.table(text="Genre Score
Horror 4
Horror 6
Romance 7
Fiction 3
Romance 10",
header = TRUE)


Make the table



TAB = aggregate(DF$Score, list(DF$Genre), mean)
names(TAB) = c("Genre", "MeanScore")
TAB
Genre MeanScore
1 Fiction 3.0
2 Horror 5.0
3 Romance 8.5





share|improve this answer

























  • thank you so much. is there a way to change group.1 and x to another variable?

    – Thom JAckson
    Mar 9 at 1:32













0












0








0







You can get the table that you are looking for using the aggregate function.



## Your sample data
DF = read.table(text="Genre Score
Horror 4
Horror 6
Romance 7
Fiction 3
Romance 10",
header = TRUE)


Make the table



TAB = aggregate(DF$Score, list(DF$Genre), mean)
names(TAB) = c("Genre", "MeanScore")
TAB
Genre MeanScore
1 Fiction 3.0
2 Horror 5.0
3 Romance 8.5





share|improve this answer















You can get the table that you are looking for using the aggregate function.



## Your sample data
DF = read.table(text="Genre Score
Horror 4
Horror 6
Romance 7
Fiction 3
Romance 10",
header = TRUE)


Make the table



TAB = aggregate(DF$Score, list(DF$Genre), mean)
names(TAB) = c("Genre", "MeanScore")
TAB
Genre MeanScore
1 Fiction 3.0
2 Horror 5.0
3 Romance 8.5






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 9 at 1:36

























answered Mar 9 at 1:22









G5WG5W

23.6k92244




23.6k92244












  • thank you so much. is there a way to change group.1 and x to another variable?

    – Thom JAckson
    Mar 9 at 1:32

















  • thank you so much. is there a way to change group.1 and x to another variable?

    – Thom JAckson
    Mar 9 at 1:32
















thank you so much. is there a way to change group.1 and x to another variable?

– Thom JAckson
Mar 9 at 1:32





thank you so much. is there a way to change group.1 and x to another variable?

– Thom JAckson
Mar 9 at 1:32

















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%2f55072956%2fhow-do-i-merge-objects-with-the-same-character-within-a-column%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

How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229