{"id":943,"date":"2023-07-28T05:52:17","date_gmt":"2023-07-28T05:52:17","guid":{"rendered":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/"},"modified":"2023-07-28T05:52:17","modified_gmt":"2023-07-28T05:52:17","slug":"tellen-per-groep-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/","title":{"rendered":"Hoe observaties per groep te tellen in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Vaak ben je misschien ge\u00efnteresseerd in het tellen van het aantal <a href=\"https:\/\/statorials.org\/nl\/observatie-in-de-statistiek\/\" target=\"_blank\" rel=\"noopener noreferrer\">observaties<\/a> per groep in R.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Gelukkig is dit eenvoudig te doen met behulp van de <a href=\"https:\/\/dplyr.tidyverse.org\/reference\/count.html\" target=\"_blank\" rel=\"noopener noreferrer\">count()<\/a> -functie van de <a href=\"https:\/\/dplyr.tidyverse.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">dplyr-<\/a> bibliotheek.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial worden verschillende voorbeelden van praktisch gebruik van deze functie uitgelegd met behulp van het volgende dataframe:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data frame<\/span>\ndf &lt;- data.frame(team = c('A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'C', 'C' , 'CC'),\n                 position = c('G', 'G', 'F', 'G', 'F', 'F', 'F', 'G', 'G', 'F', 'F', 'F '),\n                 points = c(4, 13, 7, 8, 15, 15, 17, 9, 21, 22, 25, 31))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   team position points\n1 GA 4\n2 AG 13\n3AF 7\n4 BG 8\n5 BF 15\n6 BF 15\n7 BF 17\n8 BG 9\n9 GC 21\n10 CF 22\n11 CF 25\n12 CF 31\n<\/strong><\/pre>\n<h3> <strong>Voorbeeld 1: tellen met een variabele<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe je het totale aantal spelers per team telt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #993300;\">library<\/span> (dplyr)<\/span>\n\n#count total observations by variable 'team'<\/span>\ndf %&gt;% count(team)\n\n# A tibble: 3 x 2\n  team n\n   \n1 to 3\n2 B 5\n3 C 4\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we zien dat:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Team A bestaat uit 3 spelers<\/span><\/li>\n<li> <span style=\"color: #000000;\">Team B bestaat uit 5 spelers<\/span><\/li>\n<li> <span style=\"color: #000000;\">Team C bestaat uit 4 spelers<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Deze single count() functie geeft ons een mooi beeld van de verdeling van spelers per team.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Merk op dat we de tellingen ook kunnen <strong>sorteren<\/strong> als we dat willen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#count total observations by variable 'team'<\/span>\ndf %&gt;% count(team, sort= <span style=\"color: #008000;\">TRUE<\/span> )\n\n# A tibble: 3 x 2\n  team n\n   \n1 B 5\n2 C 4\n3 to 3<\/strong><\/pre>\n<h3> <strong>Voorbeeld 2: Tellen met meerdere variabelen<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">We kunnen ook op verschillende variabelen sorteren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#count total observations by 'team' and 'position'\n<\/span>df %&gt;% count(team, position)\n\n# A tibble: 6 x 3\n  team position n\n       \n1 AF 1\n2 AG 2\n3 BF 3\n4 BG 2\n5 CF 3\n6 GC 1\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we zien dat:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Team A heeft 1 speler in de \u201cF\u201d (voorwaartse) positie en 2 spelers in de \u201cG\u201d (bewaker) positie.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Team B heeft 3 spelers in de \u201cF\u201d (vooruit) positie en 2 spelers in de \u201cG\u201d (bewaker) positie.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Team C heeft 3 spelers in de \u201cF\u201d (voorwaartse) positie en 1 speler in de \u201cG\u201d (bewaker) positie.<\/span><\/li>\n<\/ul>\n<h3> <strong>Voorbeeld 3: gewogen getal<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">We kunnen de tellingen van de ene variabele ook \u2018wegen\u2019 met een andere variabele. De volgende code laat bijvoorbeeld zien hoe het totale aantal observaties per team moet worden geteld, waarbij de variabele &#8218;punten&#8216; als gewicht wordt gebruikt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df %&gt;% count(team, wt= <span style=\"color: #008000;\">points<\/span> )\n\n# A tibble: 3 x 2\n  team n\n   \n1 to 24\n2 B 64\n3 C 99\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><em>U kunt de volledige documentatie voor de functie <strong>count()<\/strong> <a href=\"https:\/\/dplyr.tidyverse.org\/reference\/count.html\" target=\"_blank\" rel=\"noopener noreferrer\">hier<\/a> vinden.<\/em><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vaak ben je misschien ge\u00efnteresseerd in het tellen van het aantal observaties per groep in R. Gelukkig is dit eenvoudig te doen met behulp van de count() -functie van de dplyr- bibliotheek. In deze tutorial worden verschillende voorbeelden van praktisch gebruik van deze functie uitgelegd met behulp van het volgende dataframe: #create data frame df [&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":[],"class_list":["post-943","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe waarnemingen per groep te tellen in R - Statorials<\/title>\n<meta name=\"description\" content=\"Een eenvoudige uitleg over hoe je het totale aantal observaties per groep in R kunt tellen.\" \/>\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\/nl\/tellen-per-groep-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe waarnemingen per groep te tellen in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"Een eenvoudige uitleg over hoe je het totale aantal observaties per groep in R kunt tellen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T05:52:17+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\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/\",\"name\":\"Hoe waarnemingen per groep te tellen in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-28T05:52:17+00:00\",\"dateModified\":\"2023-07-28T05:52:17+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"Een eenvoudige uitleg over hoe je het totale aantal observaties per groep in R kunt tellen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe observaties per groep te tellen in r\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe waarnemingen per groep te tellen in R - Statorials","description":"Een eenvoudige uitleg over hoe je het totale aantal observaties per groep in R kunt tellen.","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\/nl\/tellen-per-groep-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe waarnemingen per groep te tellen in R - Statorials","og_description":"Een eenvoudige uitleg over hoe je het totale aantal observaties per groep in R kunt tellen.","og_url":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/","og_site_name":"Statorials","article_published_time":"2023-07-28T05:52:17+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/","url":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/","name":"Hoe waarnemingen per groep te tellen in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-28T05:52:17+00:00","dateModified":"2023-07-28T05:52:17+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"Een eenvoudige uitleg over hoe je het totale aantal observaties per groep in R kunt tellen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/tellen-per-groep-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/tellen-per-groep-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe observaties per groep te tellen in r"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=943"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/943\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}