{"id":1777,"date":"2023-07-25T01:03:48","date_gmt":"2023-07-25T01:03:48","guid":{"rendered":"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/"},"modified":"2023-07-25T01:03:48","modified_gmt":"2023-07-25T01:03:48","slug":"r-fout-in-bestand-rt-kan-verbinding-niet-openen","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/","title":{"rendered":"Oplossing: fout in bestand (bestand, \u201crt\u201d): kan verbinding niet openen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Een veel voorkomende fout die u in R kunt tegenkomen is:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>Error in file(file, \"rt\"): cannot open the connection\nIn addition: Warning message:\nIn file(file, \"rt\"):\n  cannot open file 'data.csv': No such file or directory \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Deze fout treedt op wanneer u <a href=\"https:\/\/statorials.org\/nl\/csv-importeren-in-r\/\" target=\"_blank\" rel=\"noopener\">een CSV-bestand in R probeert te lezen<\/a> , maar de bestandsnaam of map die u probeert te openen bestaat niet.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial wordt precies uitgelegd hoe u deze fout kunt oplossen.<\/span><\/p>\n<h3> <strong>Hoe de fout te reproduceren<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Laten we zeggen dat ik een CSV-bestand met de naam <strong>data.csv<\/strong> heb opgeslagen op de volgende locatie:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>C:\\Gebruikers\\Bob\\Desktop\\data.csv<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">En stel dat het CSV-bestand de volgende gegevens bevat:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>team, points, assists\n'A', 78, 12\n'B', 85, 20\n'C', 93, 23\n'D', 90, 8\n'E', 91, 14\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Stel dat ik de volgende syntaxis gebruik om dit CSV-bestand in R te lezen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to read in CSV file<\/span>\ndf &lt;- read. <span style=\"color: #3366ff;\">csv<\/span> ('data.csv')\n\nError in file(file, \"rt\"): cannot open the connection\nIn addition: Warning message:\nIn file(file, \"rt\"):\n  cannot open file 'data2.csv': No such file or directory<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ik krijg een foutmelding omdat dit bestand niet bestaat in de huidige werkmap.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hoe u de fout kunt oplossen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Ik kan de functie <strong>getwd()<\/strong> gebruiken om de werkmap te vinden waarin ik me bevind:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display current directory<\/span>\ngetwd()\n\n[1] \"C:\/Users\/Bob\/Documents\"\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Omdat mijn CSV-bestand op mijn bureaublad staat, moet ik de werkmap wijzigen met <strong>setwd()<\/strong> en vervolgens <strong>read.csv()<\/strong> gebruiken om het bestand te lezen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#set current directory<\/span>\nsetwd('C:\\Users\\Bob\\Desktop')\n\n<span style=\"color: #008080;\">#read in CSV file\n<span style=\"color: #000000;\">df &lt;- read. <span style=\"color: #3366ff;\">csv<\/span> ('data.csv', header= <span style=\"color: #008000;\">TRUE<\/span> , stringsAsFactors= <span style=\"color: #008000;\">FALSE<\/span> )\n<\/span><\/span>\n<span style=\"color: #008080;\">#view data\n<\/span>df\n\n  team points assists\n1 A 78 12\n2 B 85 20\n3 C 93 23\n4 D 90 8\n5 E 91 14\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het werkte!<\/span><\/p>\n<p> <span style=\"color: #000000;\">Een andere manier om het CSV te importeren zonder de werkmap in te stellen, is door bij het importeren het volledige bestandspad in R op te geven:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#read in CSV file using entire file path\n<span style=\"color: #000000;\">df &lt;- read. <span style=\"color: #3366ff;\">csv<\/span> ('C:\\\\Users\\\\Bob\\\\Desktop\\\\data.csv', header= <span style=\"color: #008000;\">TRUE<\/span> , stringsAsFactors= <span style=\"color: #008000;\">FALSE<\/span> )\n<\/span><\/span>\n<span style=\"color: #008080;\">#view data\n<\/span>df\n\n  team points assists\n1 A 78 12\n2 B 85 20\n3 C 93 23\n4 D 90 8\n5 E 91 14<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/nl\/csv-importeren-in-r\/\" target=\"_blank\" rel=\"noopener\">CSV-bestanden importeren in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/excel-importeren-in-r\/\" target=\"_blank\" rel=\"noopener\">Excel-bestanden importeren in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/voer-gegevens-in-r-in\/\">Handmatig ruwe gegevens invoeren in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een veel voorkomende fout die u in R kunt tegenkomen is: Error in file(file, &#8222;rt&#8220;): cannot open the connection In addition: Warning message: In file(file, &#8222;rt&#8220;): cannot open file &#8218;data.csv&#8216;: No such file or directory Deze fout treedt op wanneer u een CSV-bestand in R probeert te lezen , maar de bestandsnaam of map die [&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-1777","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>Oplossing: Fout in bestand (bestand, &quot;rt&quot;): Kan verbinding niet openen<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: error in file(file, &quot;rt&quot;): Kan verbinding niet openen.\" \/>\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\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Oplossing: Fout in bestand (bestand, &quot;rt&quot;): Kan verbinding niet openen\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: error in file(file, &quot;rt&quot;): Kan verbinding niet openen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T01:03:48+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\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/\",\"url\":\"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/\",\"name\":\"Oplossing: Fout in bestand (bestand, &quot;rt&quot;): Kan verbinding niet openen\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-25T01:03:48+00:00\",\"dateModified\":\"2023-07-25T01:03:48+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: error in file(file, &quot;rt&quot;): Kan verbinding niet openen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Oplossing: fout in bestand (bestand, \u201crt\u201d): kan verbinding niet openen\"}]},{\"@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":"Oplossing: Fout in bestand (bestand, &quot;rt&quot;): Kan verbinding niet openen","description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: error in file(file, &quot;rt&quot;): Kan verbinding niet openen.","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\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/","og_locale":"de_DE","og_type":"article","og_title":"Oplossing: Fout in bestand (bestand, &quot;rt&quot;): Kan verbinding niet openen","og_description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: error in file(file, &quot;rt&quot;): Kan verbinding niet openen.","og_url":"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/","og_site_name":"Statorials","article_published_time":"2023-07-25T01:03:48+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\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/","url":"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/","name":"Oplossing: Fout in bestand (bestand, &quot;rt&quot;): Kan verbinding niet openen","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-25T01:03:48+00:00","dateModified":"2023-07-25T01:03:48+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: error in file(file, &quot;rt&quot;): Kan verbinding niet openen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/r-fout-in-bestand-rt-kan-verbinding-niet-openen\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Oplossing: fout in bestand (bestand, \u201crt\u201d): kan verbinding niet openen"}]},{"@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\/1777","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=1777"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1777\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}