{"id":3214,"date":"2023-07-18T15:53:37","date_gmt":"2023-07-18T15:53:37","guid":{"rendered":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/"},"modified":"2023-07-18T15:53:37","modified_gmt":"2023-07-18T15:53:37","slug":"tracciare-lequazione-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/","title":{"rendered":"Come disegnare un&#39;equazione in r (con esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi di base per tracciare un&#8217;equazione o una funzione in R:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Metodo 1: utilizzare Base R<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>curve(2*x^2+5, from= <span style=\"color: #008000;\">1<\/span> , to= <span style=\"color: #008000;\">50<\/span> , , xlab=\" <span style=\"color: #ff0000;\">x<\/span> \", ylab=\" <span style=\"color: #ff0000;\">y<\/span> \")\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 2: utilizzare ggplot2<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\"><span style=\"color: #107d3f;\">library<\/span><\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#define equation<\/span>\nmy_equation &lt;- function(x){2*x^2+5}\n\n<span style=\"color: #008080;\">#plot equation<\/span>\nggplot( <span style=\"color: #3366ff;\">data.frame<\/span> (x=c( <span style=\"color: #008000;\">1,50<\/span> )), <span style=\"color: #008000;\">aes<\/span> (x=x)) + \n  stat_function(fun=my_equation)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Questi due esempi particolari tracciano l&#8217;equazione <strong>y = 2x <sup>2<\/sup> + 5<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Gli esempi seguenti mostrano come utilizzare ciascun metodo nella pratica.<\/span><\/p>\n<h2> <strong><span style=\"color: #000000;\">Esempio 1:<\/span> <span style=\"color: #000000;\">tracciare l&#8217;equazione in base R<\/span><\/strong><\/h2>\n<p> <span style=\"color: #000000;\">Supponiamo di voler tracciare la seguente equazione:<\/span><\/p>\n<blockquote>\n<p> <span style=\"color: #000000;\"><strong>y = <sup>2\u00d72<\/sup> + 5<\/strong><\/span><\/p>\n<\/blockquote>\n<p> <span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi R di base per eseguire questa operazione:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>curve(2*x^2+5, from= <span style=\"color: #008000;\">1<\/span> , to= <span style=\"color: #008000;\">50<\/span> , , xlab=\" <span style=\"color: #ff0000;\">x<\/span> \", ylab=\" <span style=\"color: #ff0000;\">y<\/span> \")<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Ci\u00f2 produce la seguente trama:<\/span><\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-27287\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ploteq1.jpg\" alt=\"tracciare l'equazione in R\" width=\"481\" height=\"440\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Se invece vuoi tracciare dei punti, specifica semplicemente type=&#8221;p&#8221; nella funzione <strong>Curve()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>curve(2*x^2+5, from= <span style=\"color: #008000;\">1<\/span> , to= <span style=\"color: #008000;\">50<\/span> , , xlab=\" <span style=\"color: #ff0000;\">x<\/span> \", ylab=\" <span style=\"color: #ff0000;\">y<\/span> \", type=\" <span style=\"color: #ff0000;\">p<\/span> \")<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ci\u00f2 produce la seguente trama:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-27288 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ploteq2.jpg\" alt=\"\" width=\"489\" height=\"444\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <strong><span style=\"color: #000000;\">Esempio 2:<\/span> <span style=\"color: #000000;\">traccia l&#8217;equazione in ggplot2<\/span><\/strong><\/h2>\n<p> <span style=\"color: #000000;\">Supponiamo di voler tracciare la seguente equazione:<\/span><\/p>\n<blockquote>\n<p> <span style=\"color: #000000;\"><strong>y = <sup>2\u00d72<\/sup> + 5<\/strong><\/span><\/p>\n<\/blockquote>\n<p> <span style=\"color: #000000;\">Per eseguire questa operazione \u00e8 possibile utilizzare la seguente sintassi in <a href=\"https:\/\/ggplot2.tidyverse.org\/\" target=\"_blank\" rel=\"noopener\">ggplot2<\/a> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\"><span style=\"color: #107d3f;\">library<\/span><\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#define equation<\/span>\nmy_equation &lt;- function(x){2*x^2+5}\n\n<span style=\"color: #008080;\">#plot equation<\/span>\nggplot( <span style=\"color: #3366ff;\">data.frame<\/span> (x=c( <span style=\"color: #008000;\">1,50<\/span> )), <span style=\"color: #008000;\">aes<\/span> (x=x)) + \n  stat_function(fun=my_equation)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ci\u00f2 produce la seguente trama:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-27289 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ploteq3.jpg\" alt=\"\" width=\"481\" height=\"477\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Nota che questo grafico corrisponde a quello che abbiamo creato nell&#8217;esempio precedente in base R.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : per tracciare un&#8217;equazione diversa, \u00e8 sufficiente modificare i valori definiti per la variabile <strong>my_equation<\/strong> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre attivit\u00e0 comuni in R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\" target=\"_blank\" rel=\"noopener\">Come aggiungere un&#8217;equazione di regressione a un grafico in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/diagramma-di-interazione-r\/\" target=\"_blank\" rel=\"noopener\">Come creare un grafico di interazione in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/traccia-residua-r\/\" target=\"_blank\" rel=\"noopener\">Come creare una trama residua in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi di base per tracciare un&#8217;equazione o una funzione in R: Metodo 1: utilizzare Base R curve(2*x^2+5, from= 1 , to= 50 , , xlab=&#8221; x &#8220;, ylab=&#8221; y &#8220;) Metodo 2: utilizzare ggplot2 library (ggplot2) #define equation my_equation &lt;- function(x){2*x^2+5} #plot equation ggplot( data.frame (x=c( 1,50 )), aes (x=x)) [&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>Come tracciare un&#039;equazione in R (con esempi) - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come rappresentare graficamente un&#039;equazione in R, con diversi esempi.\" \/>\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\/it\/tracciare-lequazione-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come tracciare un&#039;equazione in R (con esempi) - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come rappresentare graficamente un&#039;equazione in R, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T15:53:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ploteq1.jpg\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/\",\"url\":\"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/\",\"name\":\"Come tracciare un&#39;equazione in R (con esempi) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-18T15:53:37+00:00\",\"dateModified\":\"2023-07-18T15:53:37+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come rappresentare graficamente un&#39;equazione in R, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come disegnare un&#39;equazione in r (con esempi)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come tracciare un&#39;equazione in R (con esempi) - Statorials","description":"Questo tutorial spiega come rappresentare graficamente un&#39;equazione in R, con diversi esempi.","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\/it\/tracciare-lequazione-in-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come tracciare un&#39;equazione in R (con esempi) - Statorials","og_description":"Questo tutorial spiega come rappresentare graficamente un&#39;equazione in R, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-18T15:53:37+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ploteq1.jpg"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/","url":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/","name":"Come tracciare un&#39;equazione in R (con esempi) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-18T15:53:37+00:00","dateModified":"2023-07-18T15:53:37+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come rappresentare graficamente un&#39;equazione in R, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/tracciare-lequazione-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come disegnare un&#39;equazione in r (con esempi)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3214"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=3214"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3214\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}