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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page