{"id":1913,"date":"2023-07-24T11:50:10","date_gmt":"2023-07-24T11:50:10","guid":{"rendered":"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/"},"modified":"2023-07-24T11:50:10","modified_gmt":"2023-07-24T11:50:10","slug":"x-moet-numeriek-zijn","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/","title":{"rendered":"Hoe op te lossen in r: &#39;x&#39; moet numeriek zijn"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Een fout die je tegen kunt komen in R is:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>Error in hist.default(data): 'x' must be numeric\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Deze fout treedt op wanneer u probeert een histogram te maken voor een variabele die niet numeriek is.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial wordt precies uitgelegd hoe u deze fout kunt oplossen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hoe de fout te reproduceren<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we proberen een histogram te maken voor de volgende gegevensvector:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#definevector\n<\/span>data &lt;- c('1.2', '1.4', '1.7', '1.9', '2.2', '2.5', '3', '3.4', '3.7', '4.1')\n\n<span style=\"color: #008080;\">#attempt to create histogram to visualize distribution of values in vector\n<\/span>hist(data)\n\nError in hist.default(data): 'x' must be numeric\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We ontvangen een foutmelding omdat <strong>de gegevens<\/strong> momenteel geen numerieke vector zijn. We kunnen dit bevestigen door de klasse te controleren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#check class\n<\/span>class(data)\n\n[1] \u201ccharacter\u201d\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Momenteel zijn <strong>de gegevens<\/strong> een karaktervector.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hoe u de fout kunt oplossen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De eenvoudigste manier om deze fout op te lossen is door simpelweg <strong>as.numeric()<\/strong> te gebruiken om onze vector naar numeriek te converteren:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert vector from character to numeric\n<\/span>data_numeric &lt;- as. <span style=\"color: #3366ff;\">numeric<\/span> (data)\n\n<span style=\"color: #008080;\">#create histogram\n<span style=\"color: #000000;\">hist(data_numeric)<\/span><\/span>\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-18279 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/histr1.png\" alt=\"\" width=\"429\" height=\"429\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Merk op dat we geen foutmelding krijgen en dat we het histogram kunnen maken omdat onze vector nu numeriek is.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen dit verifi\u00ebren door de klasse te controleren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#check class\n<\/span>class(data_numeric)\n\n[1] \"digital\"\n<\/strong><\/pre>\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 fouten in R kunt oplossen:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/nas-onder-dwang-geintroduceerd-in-r\/\" target=\"_blank\" rel=\"noopener\">Oplossing: NA&#8217;s ge\u00efntroduceerd door dwang<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/r-onjuist-aantal-indices-op-matrix\/\" target=\"_blank\" rel=\"noopener\">Oplossing: onjuist aantal indexen op matrix<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/r-aantal-te-vervangen-items-niet-een-veelvoud-van-de-vervangingslengte\/\" target=\"_blank\" rel=\"noopener\">Oplossing: het aantal te vervangen items is geen veelvoud van de vervangingslengte<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een fout die je tegen kunt komen in R is: Error in hist.default(data): &#8218;x&#8216; must be numeric Deze fout treedt op wanneer u probeert een histogram te maken voor een variabele die niet numeriek is. In deze tutorial wordt precies uitgelegd hoe u deze fout kunt oplossen. Hoe de fout te reproduceren Stel dat we [&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-1913","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 op te lossen in R: &#039;x&#039; moet numeriek zijn - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: &#039;x&#039; moet numeriek zijn.\" \/>\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\/x-moet-numeriek-zijn\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe op te lossen in R: &#039;x&#039; moet numeriek zijn - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: &#039;x&#039; moet numeriek zijn.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T11:50:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/histr1.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\/x-moet-numeriek-zijn\/\",\"url\":\"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/\",\"name\":\"Hoe op te lossen in R: &#39;x&#39; moet numeriek zijn - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-24T11:50:10+00:00\",\"dateModified\":\"2023-07-24T11:50:10+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: &#39;x&#39; moet numeriek zijn.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe op te lossen in r: &#39;x&#39; moet numeriek zijn\"}]},{\"@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 op te lossen in R: &#39;x&#39; moet numeriek zijn - Statorials","description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: &#39;x&#39; moet numeriek zijn.","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\/x-moet-numeriek-zijn\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe op te lossen in R: &#39;x&#39; moet numeriek zijn - Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: &#39;x&#39; moet numeriek zijn.","og_url":"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/","og_site_name":"Statorials","article_published_time":"2023-07-24T11:50:10+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/histr1.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\/x-moet-numeriek-zijn\/","url":"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/","name":"Hoe op te lossen in R: &#39;x&#39; moet numeriek zijn - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-24T11:50:10+00:00","dateModified":"2023-07-24T11:50:10+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: &#39;x&#39; moet numeriek zijn.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/x-moet-numeriek-zijn\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe op te lossen in r: &#39;x&#39; moet numeriek zijn"}]},{"@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\/1913","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=1913"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1913\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}