{"id":1142,"date":"2023-07-27T12:44:55","date_gmt":"2023-07-27T12:44:55","guid":{"rendered":"https:\/\/statorials.org\/nl\/xtabs-in-r\/"},"modified":"2023-07-27T12:44:55","modified_gmt":"2023-07-27T12:44:55","slug":"xtabs-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/xtabs-in-r\/","title":{"rendered":"Hoe xtabs() in r te gebruiken om frequenties te berekenen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Met de functie <strong>xtabs()<\/strong> in R kunt u snel de frequenties van een of meer variabelen berekenen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het gebruikt de volgende basissyntaxis:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>xtabs(~variabele_naam, data=data)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Goud:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>variabele_naam:<\/strong> De variabele waarvoor u frequenties wilt berekenen.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>data:<\/strong> De naam van het datablok waaruit de variabele afkomstig is.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Deze tutorial toont verschillende voorbeelden van praktisch gebruik van deze functie.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld 1: Gebruik xtabs() voor unidirectionele frequenties<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u <strong>xtabs()<\/strong> gebruikt om frequenties voor de <em>teamvariabele<\/em> te berekenen:<\/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= <span style=\"color: #3366ff;\">rep<\/span> (c(' <span style=\"color: #008000;\">A<\/span> ', ' <span style=\"color: #008000;\">B<\/span> ', ' <span style=\"color: #008000;\">C<\/span> '), <span style=\"color: #3366ff;\">times<\/span> =c(27, 33, 40)),\n                 position= <span style=\"color: #3366ff;\">rep<\/span> (c(' <span style=\"color: #008000;\">Guard<\/span> ', ' <span style=\"color: #008000;\">Forward<\/span> ', ' <span style=\"color: #008000;\">Center<\/span> '), <span style=\"color: #3366ff;\">times<\/span> =c(20, 50, 30)),\n                 points= <span style=\"color: #3366ff;\">runif<\/span> (100, 1, 50))\n\n<span style=\"color: #008080;\">#view first six rows of data frame\n<\/span>head(df)\n\n  team position points\n1A Guard 14.00992\n2 A Guard 19.23407\n3A Guard 29.06981\n4A Guard 45.50218\n5A Guard 10.88241\n6A Guard 45.02109\n\n<span style=\"color: #008080;\">#calculate frequencies of <em>team<\/em> variable\n<\/span>xtabs(~team, data=df)\n\nteam\n ABC\n27 33 40<\/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 verschijnt <strong>27<\/strong> keer in het dataframe.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Team A verschijnt <strong>33<\/strong> keer in het dataframe.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Team A verschijnt <strong>40<\/strong> keer in het dataframe.<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld 2: Gebruik xtabs() voor bidirectionele frequenties<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u <strong>xtabs()<\/strong> gebruikt om bidirectionele frequenties voor de <em>team-<\/em> en <em>positievariabelen<\/em> te berekenen:<\/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= <span style=\"color: #3366ff;\">rep<\/span> (c(' <span style=\"color: #008000;\">A<\/span> ', ' <span style=\"color: #008000;\">B<\/span> ', ' <span style=\"color: #008000;\">C<\/span> '), <span style=\"color: #3366ff;\">times<\/span> =c(27, 33, 40)),\n                 position= <span style=\"color: #3366ff;\">rep<\/span> (c(' <span style=\"color: #008000;\">Guard<\/span> ', ' <span style=\"color: #008000;\">Forward<\/span> ', ' <span style=\"color: #008000;\">Center<\/span> '), <span style=\"color: #3366ff;\">times<\/span> =c(20, 50, 30)),\n                 points= <span style=\"color: #3366ff;\">runif<\/span> (100, 1, 50))\n\n<span style=\"color: #008080;\">#calculate frequencies of <em>team<\/em> and <em>position<\/em> variables\n<\/span>xtabs(~team+position, data=df)\n\n    position\nteam Center Forward Guard\n   A 0 7 20\n   B 0 33 0\n   C 30 10 0<\/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;\">Er zijn <strong>0<\/strong> Centers in Team A.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Er zijn <strong>7<\/strong> aanvallers in team A.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Er zijn <strong>20<\/strong> bewakers in team A.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Enzovoort.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Gebruik xtabs() voor n-wegfrequenties<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De functie <strong>xtabs()<\/strong> kan feitelijk worden gebruikt om de frequenties van een willekeurig aantal variabelen te berekenen, eenvoudigweg met behulp van de volgende syntaxis:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>xtabs(~variable1+variable2+variable3+...+variable <em>n<\/em> , data=df)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">In de praktijk wordt deze functie meestal gebruikt om unidirectionele en bidirectionele frequenties te berekenen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/nl\/dplyr-relatieve-frequenties\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe relatieve frequenties te berekenen met behulp van dplyr<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/tel-als-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe een AANTAL.ALS-functie uit te voeren in R<\/a><br \/><a href=\"https:\/\/statorials.org\/nl\/cumulatieve-som-in-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe cumulatieve bedragen in R te berekenen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Met de functie xtabs() in R kunt u snel de frequenties van een of meer variabelen berekenen. Het gebruikt de volgende basissyntaxis: xtabs(~variabele_naam, data=data) Goud: variabele_naam: De variabele waarvoor u frequenties wilt berekenen. data: De naam van het datablok waaruit de variabele afkomstig is. Deze tutorial toont verschillende voorbeelden van praktisch gebruik van deze functie. [&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-1142","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 xtabs() in R te gebruiken om frequenties te berekenen \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe je de functie xtabs() in R gebruikt om frequenties te berekenen, met verschillende voorbeelden.\" \/>\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\/xtabs-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe xtabs() in R te gebruiken om frequenties te berekenen \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe je de functie xtabs() in R gebruikt om frequenties te berekenen, met verschillende voorbeelden.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/xtabs-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T12:44:55+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\/xtabs-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/xtabs-in-r\/\",\"name\":\"Hoe xtabs() in R te gebruiken om frequenties te berekenen \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-27T12:44:55+00:00\",\"dateModified\":\"2023-07-27T12:44:55+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe je de functie xtabs() in R gebruikt om frequenties te berekenen, met verschillende voorbeelden.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/xtabs-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/xtabs-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/xtabs-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe xtabs() in r te gebruiken om frequenties te berekenen\"}]},{\"@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 xtabs() in R te gebruiken om frequenties te berekenen \u2013 Statorials","description":"In deze tutorial wordt uitgelegd hoe je de functie xtabs() in R gebruikt om frequenties te berekenen, met verschillende voorbeelden.","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\/xtabs-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe xtabs() in R te gebruiken om frequenties te berekenen \u2013 Statorials","og_description":"In deze tutorial wordt uitgelegd hoe je de functie xtabs() in R gebruikt om frequenties te berekenen, met verschillende voorbeelden.","og_url":"https:\/\/statorials.org\/nl\/xtabs-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-27T12:44:55+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\/xtabs-in-r\/","url":"https:\/\/statorials.org\/nl\/xtabs-in-r\/","name":"Hoe xtabs() in R te gebruiken om frequenties te berekenen \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-27T12:44:55+00:00","dateModified":"2023-07-27T12:44:55+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe je de functie xtabs() in R gebruikt om frequenties te berekenen, met verschillende voorbeelden.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/xtabs-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/xtabs-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/xtabs-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe xtabs() in r te gebruiken om frequenties te berekenen"}]},{"@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\/1142","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=1142"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1142\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}