{"id":3621,"date":"2023-07-16T12:21:20","date_gmt":"2023-07-16T12:21:20","guid":{"rendered":"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/"},"modified":"2023-07-16T12:21:20","modified_gmt":"2023-07-16T12:21:20","slug":"r-printtekenreeks-en-variabele","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/","title":{"rendered":"Hoe u een string en een variabele op dezelfde regel in r afdrukt"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Vaak wilt u misschien een string en een variabele op dezelfde regel in R afdrukken.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Gelukkig is dit eenvoudig te doen met de functies <strong>print()<\/strong> en <strong>paste0()<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u dit doet.<\/span><\/p>\n<h2> <strong><span style=\"color: #000000;\">Voorbeeld: druk een string en een variabele af op dezelfde regel in R<\/span><\/strong><\/h2>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u een string en een variabele op dezelfde regel in R kunt afdrukken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define variable\n<\/span>my_variable &lt;- 540.38\n\n<span style=\"color: #008080;\">#print string and variable on same line\n<\/span><span style=\"color: #008000;\">print<\/span> ( <span style=\"color: #008000;\">paste0<\/span> (\" <span style=\"color: #ff0000;\">The value of my variable is<\/span> \", my_variable))\n\n[1] \"The value of my variable is 540.38\"\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat u de functies <strong>Paste()<\/strong> en <strong>Paste0()<\/strong> in R kunt gebruiken om meerdere objecten samen te voegen tot \u00e9\u00e9n tekenreeks.<\/span><\/p>\n<p> <span style=\"color: #000000;\">De functie <strong>paste()<\/strong> voegt tekenreeksen samen met <strong>een spatie<\/strong> als standaardscheidingsteken.<\/span><\/p>\n<p> <span style=\"color: #000000;\">De functie <strong>paste0()<\/strong> voegt tekenreeksen aaneen <strong>zonder spaties<\/strong> als scheidingsteken.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dus als we in plaats daarvan <strong>paste()<\/strong> zouden gebruiken, zou er een extra spatie in de laatste string staan:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define variable\n<span style=\"color: #000000;\">my_variable &lt;- 540.38<\/span>\n\n#print string and variable on same line<\/span>\n<span style=\"color: #008000;\">print<\/span> ( <span style=\"color: #008000;\">paste<\/span> (\" <span style=\"color: #ff0000;\">The value of my variable is<\/span> \", my_variable))\n\n[1] \"The value of my variable is 540.38\"\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat er een extra spatie in de laatste string zit.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Merk ook op dat we een vergelijkbare syntaxis kunnen gebruiken om meerdere variabelen op dezelfde regel af te drukken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define variables\n<span style=\"color: #000000;\">var1 &lt;- 540.38\nvar2 &lt;- 122\n<\/span>\n#print string and multiple variables on same line<\/span>\n<span style=\"color: #008000;\">print<\/span> ( <span style=\"color: #008000;\">paste0<\/span> (\" <span style=\"color: #ff0000;\">The first variable is<\/span> \", var1, \" <span style=\"color: #ff0000;\">and the second is<\/span> \", var2))\n\n[1] \"The first variable is 540.38 and the second is 122\"\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat de string en beide variabelen op dezelfde regel worden afgedrukt.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h2>\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\/afdruktabel-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe arrays af te drukken in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/print-alle-regels-van-tibble-r\/\" target=\"_blank\" rel=\"noopener\">Hoe u alle regels van een Tibble in R afdrukt<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/sprintf-r-functie\/\" target=\"_blank\" rel=\"noopener\">Hoe de sprintf-functie in R te gebruiken om opgemaakte tekenreeksen af te drukken<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vaak wilt u misschien een string en een variabele op dezelfde regel in R afdrukken. Gelukkig is dit eenvoudig te doen met de functies print() en paste0() . Het volgende voorbeeld laat zien hoe u dit doet. Voorbeeld: druk een string en een variabele af op dezelfde regel in R De volgende code laat zien [&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-3621","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 u een string en een variabele op dezelfde regel afdrukt in R - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt met voorbeelden uitgelegd hoe u een string en een variabele op dezelfde regel in R afdrukt.\" \/>\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-printtekenreeks-en-variabele\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe u een string en een variabele op dezelfde regel afdrukt in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt met voorbeelden uitgelegd hoe u een string en een variabele op dezelfde regel in R afdrukt.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-16T12:21:20+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-printtekenreeks-en-variabele\/\",\"url\":\"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/\",\"name\":\"Hoe u een string en een variabele op dezelfde regel afdrukt in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-16T12:21:20+00:00\",\"dateModified\":\"2023-07-16T12:21:20+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt met voorbeelden uitgelegd hoe u een string en een variabele op dezelfde regel in R afdrukt.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe u een string en een variabele op dezelfde regel in r afdrukt\"}]},{\"@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 u een string en een variabele op dezelfde regel afdrukt in R - Statorials","description":"In deze tutorial wordt met voorbeelden uitgelegd hoe u een string en een variabele op dezelfde regel in R afdrukt.","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-printtekenreeks-en-variabele\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe u een string en een variabele op dezelfde regel afdrukt in R - Statorials","og_description":"In deze tutorial wordt met voorbeelden uitgelegd hoe u een string en een variabele op dezelfde regel in R afdrukt.","og_url":"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/","og_site_name":"Statorials","article_published_time":"2023-07-16T12:21:20+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-printtekenreeks-en-variabele\/","url":"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/","name":"Hoe u een string en een variabele op dezelfde regel afdrukt in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-16T12:21:20+00:00","dateModified":"2023-07-16T12:21:20+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt met voorbeelden uitgelegd hoe u een string en een variabele op dezelfde regel in R afdrukt.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/r-printtekenreeks-en-variabele\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe u een string en een variabele op dezelfde regel in r afdrukt"}]},{"@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\/3621","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=3621"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3621\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}