{"id":1570,"date":"2023-07-25T20:17:43","date_gmt":"2023-07-25T20:17:43","guid":{"rendered":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/"},"modified":"2023-07-25T20:17:43","modified_gmt":"2023-07-25T20:17:43","slug":"histogram-met-twee-variabelen-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/","title":{"rendered":"Hoe maak je een histogram van twee variabelen in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Een histogram is een handige manier om de verdeling van waarden voor een bepaalde variabele te visualiseren.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Om een histogram voor een variabele in R te maken, kunt u de functie <strong>hist()<\/strong> gebruiken. En om een histogram voor twee variabelen in R te maken, kunt u de volgende syntaxis gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>hist(variable1, col=' <span style=\"color: #008000;\">red<\/span> ')\nhist(variable2, col=' <span style=\"color: #008000;\">blue<\/span> ', add= <span style=\"color: #008000;\">TRUE<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld: Maak een histogram van twee variabelen in R<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u een histogram van twee variabelen in R maakt:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (1)\n\n<span style=\"color: #008080;\">#define data\n<\/span>x1 = rnorm(1000, mean=0.6, sd=0.1)\nx2 = rnorm(1000, mean=0.4, sd=0.1)\n\n<span style=\"color: #008080;\">#plot two histograms in same graph\n<\/span>hist(x1, col=' <span style=\"color: #008000;\">red<\/span> ')\nhist(x2, col=' <span style=\"color: #008000;\">blue<\/span> ', add= <span style=\"color: #008000;\">TRUE<\/span> )\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-15566 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/multhistr1.png\" alt=\"\" width=\"421\" height=\"429\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Omdat de histogramwaarden elkaar overlappen, is het een goed idee om <strong>rgb()-<\/strong> kleuren met verhoogde transparantie te gebruiken:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (1)\n\n<span style=\"color: #008080;\">#define data\n<\/span>x1 = rnorm(1000, mean=0.6, sd=0.1)\nx2 = rnorm(1000, mean=0.4, sd=0.1)\n\n<span style=\"color: #008080;\">#plot two histograms in same graph\n<\/span>hist(x1, col=rgb(0,0,1,0.2), xlim=c(0, 1),\n     xlab=' <span style=\"color: #008000;\">Values<\/span> ', ylab=' <span style=\"color: #008000;\">Frequency<\/span> ', main=' <span style=\"color: #008000;\">Histogram for two variables<\/span> ')\nhist(x2, col=rgb(1,0,0,0.2), add= <span style=\"color: #008000;\">TRUE<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-15567\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/multhistr2.png\" alt=\"Histogram voor twee variabelen in R\" width=\"445\" height=\"452\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">U kunt ook een legenda toevoegen om de histogrammen gemakkelijker te kunnen interpreteren:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (1)\n\n<span style=\"color: #008080;\">#define data\n<\/span>x1 = rnorm(1000, mean=0.6, sd=0.1)\nx2 = rnorm(1000, mean=0.4, sd=0.1)\n\n<span style=\"color: #008080;\">#plot two histograms in same graph\n<\/span>hist(x1, col=rgb(0,0,1,0.2), xlim=c(0, 1),\n     xlab=' <span style=\"color: #008000;\">Values<\/span> ', ylab=' <span style=\"color: #008000;\">Frequency<\/span> ', main=' <span style=\"color: #008000;\">Histogram for two variables<\/span> ')\nhist(x2, col=rgb(1,0,0,0.2), add= <span style=\"color: #008000;\">TRUE<\/span> )\n\n<span style=\"color: #008080;\">#add legend<\/span>\nlegend(' <span style=\"color: #008000;\">topright<\/span> ', c(' <span style=\"color: #008000;\">Variable 1<\/span> ', ' <span style=\"color: #008000;\">Variable 2<\/span> '),\n       fill=c(rgb(0,0,1,0.2), rgb(1,0,0,0.2)))\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-15568 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/multhistr3.png\" alt=\"Histogram van twee variabelen in voorbeeld R\" width=\"453\" height=\"441\" srcset=\"\" sizes=\"auto, \"><\/p>\n<hr>\n<p> <span style=\"color: #000000;\">Op deze pagina vindt u meer R-tutorials.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een histogram is een handige manier om de verdeling van waarden voor een bepaalde variabele te visualiseren. Om een histogram voor een variabele in R te maken, kunt u de functie hist() gebruiken. En om een histogram voor twee variabelen in R te maken, kunt u de volgende syntaxis gebruiken: hist(variable1, col=&#8216; red &#8218;) hist(variable2, [&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-1570","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 maak je een histogram van twee variabelen in R<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt met een voorbeeld uitgelegd hoe u een histogram van twee variabelen in R maakt.\" \/>\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\/histogram-met-twee-variabelen-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe maak je een histogram van twee variabelen in R\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt met een voorbeeld uitgelegd hoe u een histogram van twee variabelen in R maakt.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T20:17:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/multhistr1.png\" \/>\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=\"1\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/\",\"name\":\"Hoe maak je een histogram van twee variabelen in R\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-25T20:17:43+00:00\",\"dateModified\":\"2023-07-25T20:17:43+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt met een voorbeeld uitgelegd hoe u een histogram van twee variabelen in R maakt.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe maak je een histogram van twee variabelen 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 maak je een histogram van twee variabelen in R","description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe u een histogram van twee variabelen in R maakt.","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\/histogram-met-twee-variabelen-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe maak je een histogram van twee variabelen in R","og_description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe u een histogram van twee variabelen in R maakt.","og_url":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-25T20:17:43+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/multhistr1.png"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/","url":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/","name":"Hoe maak je een histogram van twee variabelen in R","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-25T20:17:43+00:00","dateModified":"2023-07-25T20:17:43+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe u een histogram van twee variabelen in R maakt.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/histogram-met-twee-variabelen-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe maak je een histogram van twee variabelen 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\/1570","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=1570"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1570\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}