{"id":458,"date":"2023-07-29T20:32:53","date_gmt":"2023-07-29T20:32:53","guid":{"rendered":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/"},"modified":"2023-07-29T20:32:53","modified_gmt":"2023-07-29T20:32:53","slug":"plot-distribusi-normal-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/","title":{"rendered":"Cara memplot distribusi normal di r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Untuk memplot distribusi normal di R, kita dapat menggunakan basis R atau menginstal paket yang lebih canggih seperti ggplot2.<\/span><\/p>\n<h2> <strong><span style=\"color: #000000;\">Menggunakan BaseR<\/span><\/strong><\/h2>\n<p> <span style=\"color: #000000;\">Berikut tiga contoh pembuatan plot distribusi normal menggunakan Base R.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Contoh 1: berdistribusi normal dengan mean = 0 dan simpangan baku = 1<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Untuk membuat plot distribusi normal dengan mean = 0 dan standar deviasi = 1, kita dapat menggunakan kode berikut:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#Create a sequence of 100 equally spaced numbers between -4 and 4<\/span>\nx &lt;- seq(-4, 4, length=100)\n\n<span style=\"color: #008080;\">#create a vector of values that shows the height of the probability distribution<\/span>\n<span style=\"color: #008080;\">#for each value in x<\/span>\ny &lt;- dnorm(x)\n\n<span style=\"color: #008080;\">#plot x and y as a scatterplot with connected lines (type = \"l\") and add<\/span>\n<span style=\"color: #008080;\">#an x-axis with custom labels<\/span>\nplot(x,y, type = \"l\", lwd = 2, axes = FALSE, xlab = \"\", ylab = \"\")\naxis(1, at = -3:3, labels = c(\"-3s\", \"-2s\", \"-1s\", \"mean\", \"1s\", \"2s\", \"3s\"))<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ini menghasilkan plot berikut:<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Contoh 2: Distribusi normal dengan mean = 0 dan standar deviasi = 1 (dikurangi kode)<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Kita juga dapat membuat plot distribusi normal tanpa mendefinisikan <em>x<\/em> dan <em>y<\/em> , dan cukup menggunakan fungsi &#8220;kurva&#8221; dengan menggunakan kode berikut:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>curve(dnorm, -3.5, 3.5, lwd=2, axes = FALSE, xlab = \"\", ylab = \"\")\naxis(1, at = -3:3, labels = c(\"-3s\", \"-2s\", \"-1s\", \"mean\", \"1s\", \"2s\", \"3s\"))<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ini menghasilkan plot yang persis sama:<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Contoh 3: Distribusi Normal dengan Mean Kustom dan Deviasi Standar<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Untuk membuat plot distribusi normal dengan mean dan deviasi standar yang ditentukan pengguna, kita dapat menggunakan kode berikut:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define population mean and standard deviation<\/span>\npopulation_mean &lt;- 50\npopulation_sd &lt;- 5\n\n<span style=\"color: #008080;\">#define upper and lower bound\n<\/span>lower_bound &lt;- population_mean - population_sd\nupper_bound &lt;- population_mean + population_sd\n\n<span style=\"color: #008080;\">#Create a sequence of 1000 x values based on population mean and standard deviation<\/span>\nx &lt;- seq(-4, 4, length = 1000) * population_sd + population_mean\n\n<span style=\"color: #008080;\">#create a vector of values that shows the height of the probability distribution\n<\/span><span style=\"color: #008080;\">#for each value in x<\/span>\ny &lt;- dnorm(x, population_mean, population_sd)\n\n<span style=\"color: #008080;\">#plot normal distribution with customized x-axis labels\n<\/span>plot(x,y, type = \"l\", lwd = 2, axes = FALSE, xlab = \"\", ylab = \"\")\nsd_axis_bounds = 5\naxis_bounds &lt;- seq(-sd_axis_bounds * population_sd + population_mean,\n                    sd_axis_bounds * population_sd + population_mean,\n                    by = population_sd)\naxis(side = 1, at = axis_bounds, pos = 0)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ini menghasilkan plot berikut:<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Menggunakan ggplot2<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Cara lain untuk membuat plot distribusi normal di R adalah dengan menggunakan paket ggplot2. Berikut dua contoh pembuatan plot distribusi normal menggunakan ggplot2.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Contoh 1: berdistribusi normal dengan mean = 0 dan simpangan baku = 1<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Untuk membuat plot distribusi normal dengan mean = 0 dan standar deviasi = 1, kita dapat menggunakan kode berikut:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#install (if not already installed) and load ggplot2<\/span>\nif(!(require(ggplot2))){install.packages('ggplot2')}\n\n<span style=\"color: #008080;\">#generate a normal distribution plot\n<\/span>ggplot(data.frame(x = c(-4, 4)), aes(x = x)) +\nstat_function(fun = dnorm)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ini menghasilkan plot berikut:<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Contoh 2: Distribusi normal menggunakan dataset &#8216;mtcars&#8217;<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Kode berikut menunjukkan cara membuat distribusi normal untuk kolom <em>mil per galon<\/em> di kumpulan data R tertanam <em>mtcars<\/em> :<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>ggplot(mtcars, aes(x = mpg)) +\nstat_function(\nfun = dnorm,\nargs = with(mtcars, c(mean = mean(mpg), sd = sd(mpg)))\n) +\nscale_x_continuous(\"Miles per gallon\")<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ini menghasilkan plot berikut:<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Untuk memplot distribusi normal di R, kita dapat menggunakan basis R atau menginstal paket yang lebih canggih seperti ggplot2. Menggunakan BaseR Berikut tiga contoh pembuatan plot distribusi normal menggunakan Base R. Contoh 1: berdistribusi normal dengan mean = 0 dan simpangan baku = 1 Untuk membuat plot distribusi normal dengan mean = 0 dan standar [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Cara memplot distribusi normal di R - Statorials<\/title>\n<meta name=\"description\" content=\"Tutorial sederhana ini menjelaskan cara memplot distribusi normal di R menggunakan basis R dan ggplot2.\" \/>\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\/id\/plot-distribusi-normal-r\/\" \/>\n<meta property=\"og:locale\" content=\"id_ID\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cara memplot distribusi normal di R - Statorials\" \/>\n<meta property=\"og:description\" content=\"Tutorial sederhana ini menjelaskan cara memplot distribusi normal di R menggunakan basis R dan ggplot2.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-29T20:32:53+00:00\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Ditulis oleh\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimasi waktu membaca\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 menit\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/\",\"url\":\"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/\",\"name\":\"Cara memplot distribusi normal di R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/id\/#website\"},\"datePublished\":\"2023-07-29T20:32:53+00:00\",\"dateModified\":\"2023-07-29T20:32:53+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81\"},\"description\":\"Tutorial sederhana ini menjelaskan cara memplot distribusi normal di R menggunakan basis R dan ggplot2.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/#breadcrumb\"},\"inLanguage\":\"id\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/statorials.org\/id\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cara memplot distribusi normal di r\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/id\/#website\",\"url\":\"https:\/\/statorials.org\/id\/\",\"name\":\"Statorials\",\"description\":\"Panduan anda untuk kompetensi statistik!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/id\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"id\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"id\",\"@id\":\"https:\/\/statorials.org\/id\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Halo, saya Benjamin, pensiunan profesor statistika yang menjadi guru Statorial yang berdedikasi. Dengan pengalaman dan keahlian yang luas di bidang statistika, saya ingin berbagi ilmu untuk memberdayakan mahasiswa melalui Statorials. Baca selengkapnya\",\"sameAs\":[\"http:\/\/statorials.org\/id\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cara memplot distribusi normal di R - Statorials","description":"Tutorial sederhana ini menjelaskan cara memplot distribusi normal di R menggunakan basis R dan ggplot2.","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\/id\/plot-distribusi-normal-r\/","og_locale":"id_ID","og_type":"article","og_title":"Cara memplot distribusi normal di R - Statorials","og_description":"Tutorial sederhana ini menjelaskan cara memplot distribusi normal di R menggunakan basis R dan ggplot2.","og_url":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/","og_site_name":"Statorials","article_published_time":"2023-07-29T20:32:53+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Ditulis oleh":"Benjamin anderson","Estimasi waktu membaca":"3 menit"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/","url":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/","name":"Cara memplot distribusi normal di R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/id\/#website"},"datePublished":"2023-07-29T20:32:53+00:00","dateModified":"2023-07-29T20:32:53+00:00","author":{"@id":"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81"},"description":"Tutorial sederhana ini menjelaskan cara memplot distribusi normal di R menggunakan basis R dan ggplot2.","breadcrumb":{"@id":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/#breadcrumb"},"inLanguage":"id","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/id\/plot-distribusi-normal-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/statorials.org\/id\/"},{"@type":"ListItem","position":2,"name":"Cara memplot distribusi normal di r"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/id\/#website","url":"https:\/\/statorials.org\/id\/","name":"Statorials","description":"Panduan anda untuk kompetensi statistik!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/id\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"id"},{"@type":"Person","@id":"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"id","@id":"https:\/\/statorials.org\/id\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Halo, saya Benjamin, pensiunan profesor statistika yang menjadi guru Statorial yang berdedikasi. Dengan pengalaman dan keahlian yang luas di bidang statistika, saya ingin berbagi ilmu untuk memberdayakan mahasiswa melalui Statorials. Baca selengkapnya","sameAs":["http:\/\/statorials.org\/id"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/posts\/458"}],"collection":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/comments?post=458"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/posts\/458\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/media?parent=458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/categories?post=458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/tags?post=458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}