{"id":1995,"date":"2023-07-24T04:03:53","date_gmt":"2023-07-24T04:03:53","guid":{"rendered":"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/"},"modified":"2023-07-24T04:03:53","modified_gmt":"2023-07-24T04:03:53","slug":"repliceer-functie-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/","title":{"rendered":"Hoe de functie replicate() in r te gebruiken (met voorbeelden)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de functie <strong>repliceren()<\/strong> gebruiken om een expressie in R een bepaald aantal keren herhaaldelijk te evalueren.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Deze functie gebruikt de volgende basissyntaxis:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>repliceren (n, expr)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Goud:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>n<\/strong> : Het aantal keren dat een expressie herhaaldelijk moet worden ge\u00ebvalueerd.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>expr<\/strong> : De expressie die moet worden ge\u00ebvalueerd.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">De volgende voorbeelden laten zien hoe u deze functie in de praktijk kunt gebruiken.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld 1: Repliceer een waarde meerdere keren<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u de functie <strong>repliceren()<\/strong> gebruikt om \u00e9\u00e9n waarde meerdere keren herhaaldelijk te evalueren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#replicate the value 3 exactly 10 times<\/span>\nreplicate(n= <span style=\"color: #008000;\">10,3<\/span> )\n\n[1] 3 3 3 3 3 3 3 3 3 3\n\n<span style=\"color: #008080;\">#replicate the letter 'A' exactly 7 times\n<\/span>replicate(n= <span style=\"color: #008000;\">7<\/span> , ' <span style=\"color: #ff0000;\">A<\/span> ')\n\n[1] \u201cA\u201d \u201cA\u201d \u201cA\u201d \u201cA\u201d \u201cA\u201d \u201cA\u201d \u201cA\u201d\n\n<span style=\"color: #008080;\">#replicate FALSE exactly 5 times<\/span>\nreplicate(n= <span style=\"color: #008000;\">5<\/span> , <span style=\"color: #008000;\">FALSE<\/span> )\n\n[1] FALSE FALSE FALSE FALSE FALSE\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld 2: Repliceer een functie meerdere keren<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Stel nu dat we een functie herhaaldelijk willen evalueren.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Stel dat we bijvoorbeeld de functie <strong>rnorm()<\/strong> gebruiken om drie waarden te produceren voor een <a href=\"https:\/\/statorials.org\/nl\/willekeurige-variabelen\/\" target=\"_blank\" rel=\"noopener\">willekeurige variabele<\/a> die een normale verdeling volgt met een gemiddelde van 0 en een standaarddeviatie van 1:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (1)\n\n<span style=\"color: #008080;\">#generate 3 values that follow normal distribution\n<\/span>rnorm(3, mean= <span style=\"color: #008000;\">0<\/span> , sd= <span style=\"color: #008000;\">1<\/span> ) \n\n[1] -0.6264538 0.1836433 -0.8356286<\/span>\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Door de functie <strong>repliceren()<\/strong> te gebruiken, kunnen we deze functie rnorm() een aantal keren herhaaldelijk evalueren.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen deze functie bijvoorbeeld 5 keer evalueren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (1)\n\n<span style=\"color: #008080;\">#generate 3 values that follow normal distribution (replicate this 4 times)\n<\/span>replicate(n= <span style=\"color: #008000;\">4<\/span> , rnorm(3, mean= <span style=\"color: #008000;\">0<\/span> , sd= <span style=\"color: #008000;\">1<\/span> ))\n\n           [,1] [,2] [,3] [,4]\n[1,] 1.5952808 0.4874291 -0.3053884 -0.6212406\n[2,] 0.3295078 0.7383247 1.5117812 -2.2146999\n[3,] -0.8204684 0.5757814 0.3898432 1.1249309<\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het resultaat is een matrix van 3 rijen en 4 kolommen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Of misschien willen we deze functie zes keer evalueren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (1)\n\n<span style=\"color: #008080;\">#generate 3 values that follow normal distribution (replicate this 6 times)\n<\/span>replicate(n= <span style=\"color: #008000;\">6<\/span> , rnorm(3, mean= <span style=\"color: #008000;\">0<\/span> , sd= <span style=\"color: #008000;\">1<\/span> ))\n\n           [,1] [,2] [,3] [,4] [,5] [,6]\n[1,] 1.5952808 0.4874291 -0.3053884 -0.6212406 -0.04493361 0.8212212\n[2,] 0.3295078 0.7383247 1.5117812 -2.2146999 -0.01619026 0.5939013\n[3,] -0.8204684 0.5757814 0.3898432 1.1249309 0.94383621 0.9189774<\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het resultaat is een matrix van 6 rijen en 3 kolommen.<\/span><\/p>\n<h3> <strong>Gebruik replicate() om gegevens te simuleren<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">De functie <strong>repliceren()<\/strong> is vooral handig voor het uitvoeren van simulaties.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Stel dat we bijvoorbeeld vijf steekproeven willen genereren met de grootte n = 10, die elk een normale verdeling volgen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen de functie <strong>repliceren()<\/strong> gebruiken om 5 verschillende monsters te produceren en we kunnen vervolgens de functie <strong>colMeans()<\/strong> gebruiken om de gemiddelde waarde van elk monster te vinden:<\/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;\">#create 5 samples each of size n=10\n<\/span>data &lt;- replicate(n=5, rnorm(10, mean= <span style=\"color: #008000;\">0<\/span> , sd= <span style=\"color: #008000;\">1<\/span> ))\n\n<span style=\"color: #008080;\">#view samples\n<\/span>data\n\n            [,1] [,2] [,3] [,4] [,5]\n [1,] -0.6264538 1.51178117 0.91897737 1.35867955 -0.1645236\n [2,] 0.1836433 0.38984324 0.78213630 -0.10278773 -0.2533617\n [3,] -0.8356286 -0.62124058 0.07456498 0.38767161 0.6969634\n [4,] 1.5952808 -2.21469989 -1.98935170 -0.05380504 0.5566632\n [5,] 0.3295078 1.12493092 0.61982575 -1.37705956 -0.6887557\n [6,] -0.8204684 -0.04493361 -0.05612874 -0.41499456 -0.7074952\n [7,] 0.4874291 -0.01619026 -0.15579551 -0.39428995 0.3645820\n [8,] 0.7383247 0.94383621 -1.47075238 -0.05931340 0.7685329\n [9,] 0.5757814 0.82122120 -0.47815006 1.10002537 -0.1123462\n[10,] -0.3053884 0.59390132 0.41794156 0.76317575 0.8811077\n\n<span style=\"color: #008080;\">#calculate mean of each sample\n<\/span>colMeans(data)\n\n[1] 0.1322028 0.2488450 -0.1336732 0.1207302 0.1341367\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;\">Het gemiddelde van het eerste monster is <strong>0,1322<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Het gemiddelde van het tweede monster is <strong>0,2488<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Het gemiddelde van het derde monster is <strong>-0,1337<\/strong> .<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Enzovoort.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p><a href=\"https:\/\/statorials.org\/nl\/r-selecteer-specifieke-kolommen\/\" target=\"_blank\" rel=\"noopener\">Hoe specifieke kolommen in R te selecteren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/r-rollende-kolom\/\" target=\"_blank\" rel=\"noopener\">Hoe kolommen uit het dataframe te verwijderen in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/r-voorwaarde-voor-het-verwijderen-van-lijnen-uit-het-dataframe\/\" target=\"_blank\" rel=\"noopener\">Hoe rijen uit het dataframe te verwijderen op basis van de voorwaarde in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de functie repliceren() gebruiken om een expressie in R een bepaald aantal keren herhaaldelijk te evalueren. Deze functie gebruikt de volgende basissyntaxis: repliceren (n, expr) Goud: n : Het aantal keren dat een expressie herhaaldelijk moet worden ge\u00ebvalueerd. expr : De expressie die moet worden ge\u00ebvalueerd. De volgende voorbeelden laten zien hoe u [&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-1995","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 de functie Replicate() in R te gebruiken (met voorbeelden) - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie repliceren() in R gebruikt, met verschillende voorbeelden.\" \/>\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\/repliceer-functie-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe de functie Replicate() in R te gebruiken (met voorbeelden) - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie repliceren() in R gebruikt, met verschillende voorbeelden.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T04:03:53+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\/repliceer-functie-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/\",\"name\":\"Hoe de functie Replicate() in R te gebruiken (met voorbeelden) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-24T04:03:53+00:00\",\"dateModified\":\"2023-07-24T04:03:53+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de functie repliceren() in R gebruikt, met verschillende voorbeelden.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe de functie replicate() in r te gebruiken (met voorbeelden)\"}]},{\"@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 de functie Replicate() in R te gebruiken (met voorbeelden) - Statorials","description":"In deze tutorial wordt uitgelegd hoe u de functie repliceren() in R gebruikt, met verschillende voorbeelden.","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\/repliceer-functie-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe de functie Replicate() in R te gebruiken (met voorbeelden) - Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de functie repliceren() in R gebruikt, met verschillende voorbeelden.","og_url":"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-24T04:03:53+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\/repliceer-functie-in-r\/","url":"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/","name":"Hoe de functie Replicate() in R te gebruiken (met voorbeelden) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-24T04:03:53+00:00","dateModified":"2023-07-24T04:03:53+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de functie repliceren() in R gebruikt, met verschillende voorbeelden.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/repliceer-functie-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe de functie replicate() in r te gebruiken (met voorbeelden)"}]},{"@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\/1995","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=1995"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1995\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}