{"id":3927,"date":"2023-07-14T17:12:50","date_gmt":"2023-07-14T17:12:50","guid":{"rendered":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/"},"modified":"2023-07-14T17:12:50","modified_gmt":"2023-07-14T17:12:50","slug":"r-kumulative-summe-pro-gruppe","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/","title":{"rendered":"So berechnen sie die kumulative summe pro gruppe in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Sie k\u00f6nnen die folgenden Methoden verwenden, um eine kumulative Summe pro Gruppe in R zu berechnen:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: Verwenden Sie Base R<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df$cum_sum &lt;- ave(df$values_var, df$group_var, FUN=cumsum)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 2: dplyr verwenden<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (dplyr)\n\ndf %&gt;% group_by(group_var) %&gt;% mutate(cum_sum = cumsum(values_var))\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 3: Verwenden Sie data.table<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (data.table)\n\nsetDT(df)[, cum_sum := cumsum(values_var), group_var] \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Die folgenden Beispiele zeigen, wie jede Methode in der Praxis mit dem folgenden Datenrahmen in R verwendet wird:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (store=rep(c(' <span style=\"color: #ff0000;\">A<\/span> ', ' <span style=\"color: #ff0000;\">B<\/span> ', ' <span style=\"color: #ff0000;\">C<\/span> '), each= <span style=\"color: #008000;\">4<\/span> ),\n                 sales=c(3, 4, 4, 2, 5, 8, 9, 7, 6, 8, 3, 2))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   blind sales\n1 to 3\n2 to 4\n3 to 4\n4 to 2\n5 B 5\n6 B 8\n7 B 9\n8 B 7\n9 C 6\n10 C 8\n11 C 3\n12 C 2\n<\/strong><\/pre>\n<h2> <span style=\"color: #000000;\"><strong>Beispiel 1: Berechnen Sie die kumulative Summe pro Gruppe mithilfe der R-Basis<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie die R-Datenbankfunktion <strong>ave()<\/strong> verwendet wird, um die kumulative Summe der <strong>Verk\u00e4ufe<\/strong> , gruppiert nach <strong>Filiale,<\/strong> zu berechnen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#add column to show cumulative sales by store\n<\/span>df$cum_sales &lt;- ave(df$sales, df$store, FUN=cumsum)\n\n<span style=\"color: #008080;\">#view updated data frame\n<\/span>df\n\n   store sales cum_sales\n1 to 3 3\n2 to 4 7\n3 to 4 11\n4 to 2 13\n5 B 5 5\n6 B 8 13\n7 B 9 22\n8 B 7 29\n9 C 6 6\n10 C 8 14\n11 C 3 17\n12 C 2 19<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Die neue Spalte \u201e <strong>cum_sales\u201c<\/strong> zeigt die kumulierte Summe der <strong>Verk\u00e4ufe<\/strong> , gruppiert nach <strong>Filiale,<\/strong> an.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Beispiel 2: Berechnen Sie die kumulative Summe pro Gruppe mit dplyr<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie verschiedene Funktionen aus dem dplyr-Paket in R verwendet werden, um die kumulative Summe der <strong>Verk\u00e4ufe<\/strong> , gruppiert nach <strong>Gesch\u00e4ft,<\/strong> zu berechnen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (dplyr)\n\n<span style=\"color: #008080;\">#add column to show cumulative sales by store\n<\/span>df %&gt;% group_by(store) %&gt;% mutate(cum_sales = cumsum(sales))\n\n<span style=\"color: #008080;\">#view updated data frame\n<\/span>df\n\n# A tibble: 12 x 3\n# Groups: store [3]\n   store sales cum_sales\n         \n 1 to 3 3\n 2 to 4 7\n 3 to 4 11\n 4 to 2 13\n 5 B 5 5\n 6 B 8 13\n 7 B 9 22\n 8 B 7 29\n 9 C 6 6\n10 C 8 14\n11 C 3 17\n12 C 2 19\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Die neue Spalte \u201e <strong>cum_sales\u201c<\/strong> zeigt die kumulierte Summe der <strong>Verk\u00e4ufe<\/strong> , gruppiert nach <strong>Filiale,<\/strong> an.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Beispiel 3: Berechnen Sie die kumulative Summe nach Gruppe mithilfe von data.table<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie verschiedene Funktionen aus dem data.table-Paket in R verwendet werden, um die kumulative Summe der <strong>Verk\u00e4ufe<\/strong> , gruppiert nach <strong>Filiale,<\/strong> zu berechnen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (data.table)\n\n<span style=\"color: #008080;\">#add column to show cumulative sales by store\n<\/span>setDT(df)[, cum_sales := cumsum(sales), store] \n\n<span style=\"color: #008080;\">#view updated data frame\n<\/span>df\n\n    store sales cum_sales\n 1: A 3 3\n 2: A 4 7\n 3: A 4 11\n 4: A 2 13\n 5: B 5 5\n 6: B 8 13\n 7: B 9 22\n 8: B 7 29\n 9: C 6 6\n10: C 8 14\n11: C 3 17\n12: C 2 19<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Die neue Spalte \u201e <strong>cum_sales\u201c<\/strong> zeigt die kumulierte Summe der <strong>Verk\u00e4ufe<\/strong> , gruppiert nach <strong>Filiale,<\/strong> an.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Hinweis<\/strong> : Alle drei Methoden f\u00fchren zum gleichen Ergebnis. Allerdings sind die Methoden dplyr und data.table tendenziell schneller, wenn mit extrem gro\u00dfen Datenrahmen gearbeitet wird.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In den folgenden Tutorials wird erl\u00e4utert, wie Sie andere g\u00e4ngige Berechnungen in R durchf\u00fchren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/summe-nach-gruppe-in-r\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie die Summe nach Gruppe in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/r-durchschnitt-pro-gruppe\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie den Mittelwert pro Gruppe in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/standardabweichung-nach-gruppe-in-r\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie die Standardabweichung nach Gruppe in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sie k\u00f6nnen die folgenden Methoden verwenden, um eine kumulative Summe pro Gruppe in R zu berechnen: Methode 1: Verwenden Sie Base R df$cum_sum &lt;- ave(df$values_var, df$group_var, FUN=cumsum) Methode 2: dplyr verwenden library (dplyr) df %&gt;% group_by(group_var) %&gt;% mutate(cum_sum = cumsum(values_var)) Methode 3: Verwenden Sie data.table library (data.table) setDT(df)[, cum_sum := cumsum(values_var), group_var] Die folgenden Beispiele [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>So berechnen Sie die kumulative Summe pro Gruppe in R - Statorials<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine kumulative Summe pro Gruppe in R berechnet wird.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So berechnen Sie die kumulative Summe pro Gruppe in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine kumulative Summe pro Gruppe in R berechnet wird.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-14T17:12:50+00:00\" \/>\n<meta name=\"author\" content=\"Dr. Benjamin Anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. Benjamin Anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/\",\"url\":\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/\",\"name\":\"So berechnen Sie die kumulative Summe pro Gruppe in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-14T17:12:50+00:00\",\"dateModified\":\"2023-07-14T17:12:50+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine kumulative Summe pro Gruppe in R berechnet wird.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So berechnen sie die kumulative summe pro gruppe in r\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/de\/#website\",\"url\":\"https:\/\/statorials.org\/de\/\",\"name\":\"Statorials\",\"description\":\"Ihr Leitfaden f\u00fcr statistische Kompetenz !\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de-DE\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\",\"name\":\"Dr. Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-DE\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. Benjamin Anderson\"},\"description\":\"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen\",\"sameAs\":[\"https:\/\/statorials.org\/de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"So berechnen Sie die kumulative Summe pro Gruppe in R - Statorials","description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine kumulative Summe pro Gruppe in R berechnet wird.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/","og_locale":"de_DE","og_type":"article","og_title":"So berechnen Sie die kumulative Summe pro Gruppe in R - Statorials","og_description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine kumulative Summe pro Gruppe in R berechnet wird.","og_url":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/","og_site_name":"Statorials","article_published_time":"2023-07-14T17:12:50+00:00","author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"2 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/","url":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/","name":"So berechnen Sie die kumulative Summe pro Gruppe in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-14T17:12:50+00:00","dateModified":"2023-07-14T17:12:50+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine kumulative Summe pro Gruppe in R berechnet wird.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/r-kumulative-summe-pro-gruppe\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So berechnen sie die kumulative summe pro gruppe in r"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/de\/#website","url":"https:\/\/statorials.org\/de\/","name":"Statorials","description":"Ihr Leitfaden f\u00fcr statistische Kompetenz !","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de-DE"},{"@type":"Person","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0","name":"Dr. Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"de-DE","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Dr. Benjamin Anderson"},"description":"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen","sameAs":["https:\/\/statorials.org\/de"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3927"}],"collection":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/comments?post=3927"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3927\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=3927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=3927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=3927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}