{"id":503,"date":"2023-07-29T16:49:12","date_gmt":"2023-07-29T16:49:12","guid":{"rendered":"https:\/\/statorials.org\/nl\/ablijn-in-r\/"},"modified":"2023-07-29T16:49:12","modified_gmt":"2023-07-29T16:49:12","slug":"ablijn-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/ablijn-in-r\/","title":{"rendered":"Hoe aline() in r te gebruiken om rechte lijnen aan plots toe te voegen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">De functie <strong>abline()<\/strong> in R kan worden gebruikt om een of meer rechte lijnen toe te voegen aan een plot in R.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Deze functie gebruikt de volgende syntaxis:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>abline(a=NULL, b=NULL, h=NULL, v=NULL, \u2026)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Goud:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>a, b:<\/strong> unieke waarden die de oorsprong en helling van de lijn specificeren<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>h:<\/strong> de y-waarde voor de horizontale lijn<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>v:<\/strong> de x-waarde voor de verticale lijn<\/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<h2> <span style=\"color: #000000;\"><strong>Horizontale lijnen toevoegen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">De basiscode voor het toevoegen van een horizontale lijn aan een plot in R is: <strong>abline(h = een bepaalde waarde)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende spreidingsdiagram hebben dat de waarden van <em>x<\/em> en <em>y<\/em> in een gegevensset weergeeft:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define dataset\n<\/span>data &lt;- data.frame(x = c(1, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 11, 11),\n                   y = c(13, 14, 17, 12, 23, 24, 25, 25, 24, 28, 32, 33, 35, 40, 41))\n\n<span style=\"color: #008080;\">#plot <em>x<\/em> and <em>y<\/em> values in dataset\n<\/span>plot(data$x, data$y, pch = 16)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Om een horizontale lijn toe te voegen met de waarde y = 20, kunnen we de volgende code gebruiken:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>abline(h = 20, col = 'coral2', lwd = 2)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De volgende code illustreert hoe u een ononderbroken horizontale lijn toevoegt aan de gemiddelde waarde van <em>y<\/em> en twee horizontale stippellijnen \u00e9\u00e9n standaardafwijking boven en onder de gemiddelde waarde:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create scatterplot for <em>x<\/em> and <em>y<\/em><\/span>\nplot(data$x, data$y, pch = 16)\n\n<span style=\"color: #008080;\">#create horizontal line at mean value of <em>y<\/em>\n<\/span>abline(h = mean(data$y), lwd = 2)\n\n<span style=\"color: #008080;\">#create horizontal lines at one standard deviation above and below the mean value\n<\/span>abline(h = mean(data$y) + sd(data$y), col = 'steelblue', lwd = 3, lty = 2)\nabline(h = mean(data$y) - sd(data$y), col = 'steelblue', lwd = 3, lty = 2)<\/strong><\/pre>\n<h2> <span style=\"color: #000000;\"><strong>Hoe verticale lijnen toe te voegen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">De basiscode voor het toevoegen van een verticale lijn aan een plot in R is: <strong>abline(v = een bepaalde waarde)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u een verticale lijn toevoegt aan de gemiddelde waarde op een histogram:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set.seed(0)\n\n<span style=\"color: #008080;\">#create dataset with 1000 random values normally distributed with mean = 10, sd = 2\n<\/span>data &lt;- rnorm(1000, mean = 10, sd = 2)\n\n<span style=\"color: #008080;\">#create histogram of data values\n<\/span>hist(data, col = 'steelblue')\n\n<span style=\"color: #008080;\">#draw a vertical dashed line at the mean value\n<\/span>abline(v = mean(data), lwd = 3, lty = 2)<\/strong><\/pre>\n<h2> <span style=\"color: #000000;\"><strong>Hoe u regressielijnen toevoegt<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">De basiscode voor het toevoegen van een eenvoudige lineaire regressielijn aan een plot in R is: <strong>abline(model)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u een aangepaste lineaire regressielijn aan een spreidingsdiagram toevoegt:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define dataset\n<\/span>data &lt;- data.frame(x = c(1, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 11, 11),\n                   y = c(13, 14, 17, 12, 23, 24, 25, 25, 24, 28, 32, 33, 35, 40, 41))\n\n<span style=\"color: #008080;\">#create scatterplot of <em>x<\/em> and <em>y<\/em> values\n<\/span>plot(data$x, data$y, pch = 16)\n\n<span style=\"color: #008080;\">#fit a linear regression model to the data\n<\/span>reg_model &lt;- lm(y ~ x, data = data)\n\n<span style=\"color: #008080;\">#add the fitted regression line to the scatterplot\n<\/span>abline(reg_model, col=\"steelblue\")<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat we eenvoudigweg een waarde nodig hebben voor het snijpunt en de helling om een eenvoudige lineaire regressielijn aan de gegevens te laten passen met behulp van de functie abline().<\/span><\/p>\n<p> <span style=\"color: #000000;\">Een andere manier om <strong>abline()<\/strong> te gebruiken om een regressielijn toe te voegen, is door expliciet de originele en hellingsco\u00ebffici\u00ebnten van het regressiemodel te specificeren:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define dataset\n<\/span>data &lt;- data.frame(x = c(1, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 11, 11),\n                   y = c(13, 14, 17, 12, 23, 24, 25, 25, 24, 28, 32, 33, 35, 40, 41))\n\n<span style=\"color: #008080;\">#create scatterplot of <em>x<\/em> and <em>y<\/em> values\n<\/span>plot(data$x, data$y, pch = 16)\n\n<span style=\"color: #008080;\">#fit a linear regression model to the data\n<\/span>reg_model &lt;- lm(y ~ x, data = data)\n\n<span style=\"color: #008080;\">#define intercept and slope values\n<\/span>a &lt;- coefficients(reg_model)[1] <span style=\"color: #008080;\">#intercept<\/span>\nb &lt;- coefficients(reg_model)[2] <span style=\"color: #008080;\">#slope<\/span>\n\n<span style=\"color: #008080;\">#add the fitted regression line to the scatterplot\n<\/span>abline(a=a, b=b, col=\"steelblue\")<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat dit dezelfde lijn oplevert als voorheen.<\/span><\/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>De functie abline() in R kan worden gebruikt om een of meer rechte lijnen toe te voegen aan een plot in R. Deze functie gebruikt de volgende syntaxis: abline(a=NULL, b=NULL, h=NULL, v=NULL, \u2026) Goud: a, b: unieke waarden die de oorsprong en helling van de lijn specificeren h: de y-waarde voor de horizontale lijn v: [&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-503","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 abline() in R te gebruiken om rechte lijnen aan plots toe te voegen - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie abline() in R kunt gebruiken om een of meer rechte lijnen aan een pad in R toe te voegen.\" \/>\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\/ablijn-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe abline() in R te gebruiken om rechte lijnen aan plots toe te voegen - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie abline() in R kunt gebruiken om een of meer rechte lijnen aan een pad in R toe te voegen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/ablijn-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-29T16:49:12+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=\"3\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/ablijn-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/ablijn-in-r\/\",\"name\":\"Hoe abline() in R te gebruiken om rechte lijnen aan plots toe te voegen - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-29T16:49:12+00:00\",\"dateModified\":\"2023-07-29T16:49:12+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de functie abline() in R kunt gebruiken om een of meer rechte lijnen aan een pad in R toe te voegen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/ablijn-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/ablijn-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/ablijn-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe aline() in r te gebruiken om rechte lijnen aan plots toe te voegen\"}]},{\"@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 abline() in R te gebruiken om rechte lijnen aan plots toe te voegen - Statorials","description":"In deze tutorial wordt uitgelegd hoe u de functie abline() in R kunt gebruiken om een of meer rechte lijnen aan een pad in R toe te voegen.","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\/ablijn-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe abline() in R te gebruiken om rechte lijnen aan plots toe te voegen - Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de functie abline() in R kunt gebruiken om een of meer rechte lijnen aan een pad in R toe te voegen.","og_url":"https:\/\/statorials.org\/nl\/ablijn-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-29T16:49:12+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"3\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/ablijn-in-r\/","url":"https:\/\/statorials.org\/nl\/ablijn-in-r\/","name":"Hoe abline() in R te gebruiken om rechte lijnen aan plots toe te voegen - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-29T16:49:12+00:00","dateModified":"2023-07-29T16:49:12+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de functie abline() in R kunt gebruiken om een of meer rechte lijnen aan een pad in R toe te voegen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/ablijn-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/ablijn-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/ablijn-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe aline() in r te gebruiken om rechte lijnen aan plots toe te voegen"}]},{"@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\/503","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=503"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/503\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}