{"id":3216,"date":"2023-07-18T15:39:28","date_gmt":"2023-07-18T15:39:28","guid":{"rendered":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/"},"modified":"2023-07-18T15:39:28","modified_gmt":"2023-07-18T15:39:28","slug":"beschrijvende-statistiek-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/","title":{"rendered":"Hoe beschrijvende statistieken in r te berekenen (met voorbeeld)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><strong>Beschrijvende statistieken<\/strong> zijn waarden die een reeks gegevens beschrijven.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ze helpen ons te begrijpen waar <a href=\"https:\/\/statorials.org\/nl\/meet-de-centrale-tendens\/\" target=\"_blank\" rel=\"noopener\">het centrum<\/a> van de dataset zich bevindt, evenals de verdeling van waarden in de dataset.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Er zijn twee functies die we kunnen gebruiken om beschrijvende statistieken in R te berekenen:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: Gebruik de functie summary().<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>summary(my_data)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De functie <strong>summary()<\/strong> berekent de volgende waarden voor elke variabele in een dataframe in R:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Minimum<\/span><\/span><\/li>\n<li> <span style=\"color: #000000;\">1e kwartiel<\/span><\/li>\n<li> <span style=\"color: #000000;\">Mediaan<\/span><\/li>\n<li> <span style=\"color: #000000;\">Gemeen<\/span><\/li>\n<li> <span style=\"color: #000000;\">3e kwartiel<\/span><\/li>\n<li> <span style=\"color: #000000;\">Maximaal<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\"><strong><span style=\"color: #000000;\">Methode 2: gebruik de functie sapply().<\/span><\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sapply(my_data, sd, na. <span style=\"color: #3366ff;\">rm<\/span> = <span style=\"color: #008000;\">TRUE<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De functie <strong>sapply()<\/strong> kan worden gebruikt om andere beschrijvende statistieken te berekenen dan die berekend door de functie <strong>summary()<\/strong> voor elke variabele in een dataframe.<\/span><\/p>\n<p> <span style=\"color: #000000;\">De bovenstaande functie <strong>sapply()<\/strong> berekent bijvoorbeeld de standaardafwijking van elke variabele in een dataframe.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze twee functies kunt gebruiken om beschrijvende statistieken te berekenen voor variabelen in een dataframe in R.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Voorbeeld: beschrijvende statistieken berekenen in R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende dataframe in R hebben dat drie variabelen bevat:<\/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> (x=c(1, 4, 4, 5, 6, 7, 10, 12),\n                 y=c(2, 2, 3, 3, 4, 5, 11, 11),\n                 z=c(8, 9, 9, 9, 10, 13, 15, 17))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   X Y Z\n1 1 2 8\n2 4 2 9\n3 4 3 9\n4 5 3 9\n5 6 4 10\n6 7 5 13\n7 10 11 15\n8 12 11 17<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de functie <strong>summary()<\/strong> gebruiken om verschillende beschrijvende statistieken voor elke variabele te berekenen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate descriptive statistics for each variable<\/span>\nsummary(df)\n\n       xyz Min. : 1,000 Min. : 2,000 Min. : 8.00  \n 1st Qu.: 4,000 1st Qu.: 2,750 1st Qu.: 9.00  \n Median: 5,500 Median: 3,500 Median: 9.50  \n Mean: 6.125 Mean: 5.125 Mean: 11.25  \n 3rd Qu.: 7,750 3rd Qu.: 6,500 3rd Qu.: 13.50  \n Max. :12,000 Max. :11,000 Max. :17.00<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen ook haakjes gebruiken om alleen beschrijvende statistieken voor specifieke variabelen in het dataframe te berekenen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate descriptive statistics for 'x' and 'z' only<\/span>\nsummary(df[, c(' <span style=\"color: #ff0000;\">x<\/span> ', ' <span style=\"color: #ff0000;\">z<\/span> ')])\n\n       xz Min. : 1,000 Min. : 8.00  \n 1st Qu.: 4.000 1st Qu.: 9.00  \n Median: 5.500 Median: 9.50  \n Mean: 6.125 Mean: 11.25  \n 3rd Qu.: 7.750 3rd Qu.: 13.50  \n Max. :12,000 Max. :17.00 \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen ook de functie <strong>sapply()<\/strong> gebruiken om voor elke variabele specifieke beschrijvende statistieken te berekenen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">De volgende code laat bijvoorbeeld zien hoe u de standaardafwijking van elke variabele berekent:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate standard deviation for each variable<\/span>\nsapply(df, sd, na. <span style=\"color: #3366ff;\">rm<\/span> = <span style=\"color: #008000;\">TRUE<\/span> )\n\n       X Y Z\n3.522884 3.758324 3.327376<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">We kunnen ook een <strong>functie()<\/strong> in <strong>sapply()<\/strong> gebruiken om beschrijvende statistieken te berekenen.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">De volgende code laat bijvoorbeeld zien hoe u <a href=\"https:\/\/statorials.org\/nl\/strand-in-r\/\" target=\"_blank\" rel=\"noopener\">het bereik<\/a> voor elke variabele berekent:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate range for each variable<\/span>\nsapply(df, function(df) max(df, na. <span style=\"color: #3366ff;\">rm<\/span> = <span style=\"color: #008000;\">TRUE<\/span> )-min(df, na. <span style=\"color: #3366ff;\">rm<\/span> = <span style=\"color: #008000;\">TRUE<\/span> ))\n\n X Y Z\n11 9 9\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Ten slotte kunnen we een complexe functie maken die beschrijvende statistieken berekent en deze functie vervolgens gebruiken met de functie <strong>sapply()<\/strong> .<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">De volgende code laat bijvoorbeeld zien hoe u <a href=\"https:\/\/statorials.org\/nl\/modus-in-r\/\" target=\"_blank\" rel=\"noopener\">de modus<\/a> van elke variabele in het dataframe berekent:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define function that calculates mode<\/span>\nfind_mode &lt;- <span style=\"color: #008000;\">function<\/span> (x) {\n  u &lt;- unique(x)\n  tab &lt;- tabulate(match(x, u))\n  u[tab <span style=\"color: #3366ff;\">==<\/span> max(tab)]\n}\n\n<span style=\"color: #008080;\">#calculate mode for each variable\n<\/span>sapply(df, find_mode)\n\n$x\n[1] 4\n\n$y\n[1] 2 3 11\n\n$z\n[1] 9\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we zien:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">De modus van de variabele x is <strong>4<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De modus van de y-variabele is <strong>2<\/strong> , <strong>3<\/strong> en <strong>11<\/strong> (aangezien elk van deze waarden het vaakst voorkomt)<\/span><\/li>\n<li> <span style=\"color: #000000;\">De modus van de variabele z is <strong>9<\/strong> .<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Met behulp van de functies <strong>summary()<\/strong> en <strong>sapply()<\/strong> kunnen we voor elke variabele in een dataframe de beschrijvende statistieken berekenen die we willen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende taken in R kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/samenvattende-tabel-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe u samenvattende tabellen maakt in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/interkwartielbereik-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe het interkwartielbereik in R te vinden<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/verwijder-uitschieters-r\/\" target=\"_blank\" rel=\"noopener\">Hoe uitschieters in R te verwijderen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Beschrijvende statistieken zijn waarden die een reeks gegevens beschrijven. Ze helpen ons te begrijpen waar het centrum van de dataset zich bevindt, evenals de verdeling van waarden in de dataset. Er zijn twee functies die we kunnen gebruiken om beschrijvende statistieken in R te berekenen: Methode 1: Gebruik de functie summary(). summary(my_data) De functie summary() [&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-3216","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 beschrijvende statistieken in R te berekenen (met voorbeeld) - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u beschrijvende statistieken in R kunt berekenen.\" \/>\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\/beschrijvende-statistiek-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe beschrijvende statistieken in R te berekenen (met voorbeeld) - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u beschrijvende statistieken in R kunt berekenen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T15:39:28+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=\"3\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/\",\"name\":\"Hoe beschrijvende statistieken in R te berekenen (met voorbeeld) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-18T15:39:28+00:00\",\"dateModified\":\"2023-07-18T15:39:28+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u beschrijvende statistieken in R kunt berekenen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe beschrijvende statistieken in r te berekenen (met voorbeeld)\"}]},{\"@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 beschrijvende statistieken in R te berekenen (met voorbeeld) - Statorials","description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u beschrijvende statistieken in R kunt berekenen.","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\/beschrijvende-statistiek-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe beschrijvende statistieken in R te berekenen (met voorbeeld) - Statorials","og_description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u beschrijvende statistieken in R kunt berekenen.","og_url":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-18T15:39:28+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"3\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/","url":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/","name":"Hoe beschrijvende statistieken in R te berekenen (met voorbeeld) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-18T15:39:28+00:00","dateModified":"2023-07-18T15:39:28+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u beschrijvende statistieken in R kunt berekenen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/beschrijvende-statistiek-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe beschrijvende statistieken in r te berekenen (met voorbeeld)"}]},{"@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\/3216","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=3216"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3216\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}