{"id":3788,"date":"2015-10-17T13:03:04","date_gmt":"2015-10-17T18:03:04","guid":{"rendered":"http:\/\/hoolihan.net\/blog-tim\/?p=3788"},"modified":"2015-10-17T13:03:04","modified_gmt":"2015-10-17T18:03:04","slug":"mapping-functions-in-r","status":"publish","type":"post","link":"http:\/\/hoolihan.net\/blog-tim\/2015\/10\/17\/mapping-functions-in-r\/","title":{"rendered":"Mapping Functions in R"},"content":{"rendered":"<p>I have been buffing up on some areas of Math that I felt rusty in. One of the tools I was using was my <a href=\"https:\/\/en.wikipedia.org\/wiki\/TI-82\">old TI-82<\/a> calculator I used in high school. <\/p>\n<p><a href=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/IMG_0383.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/IMG_0383-225x300.jpg\" alt=\"TI-82 Graphing Calculator\" width=\"225\" height=\"300\" class=\"alignnone size-medium wp-image-3789\" srcset=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/IMG_0383-225x300.jpg 225w, http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/IMG_0383.jpg 480w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><\/p>\n<p>I even got the TI Connect software working where I could download screenshots, etc. <\/p>\n<p><a href=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Trig.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Trig.jpg\" alt=\"TI-82 Screen Cap of Sin, Cos, Tan\" width=\"192\" height=\"128\" class=\"alignnone size-full wp-image-3790\" \/><\/a><\/p>\n<p>You can put in data sets (see screen cap below), and do some graphing and some statistical analysis.<\/p>\n<p><a href=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Data.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Data.jpg\" alt=\"Data Entry on TI-82\" width=\"192\" height=\"128\" class=\"alignnone size-full wp-image-3792\" \/><\/a><\/p>\n<p>However, mapping functions is a more straight forward use of the calculator. Which got me thinking&#8230; How does one do that in R?<\/p>\n<p>I did a little digging. With the traditional R graphics and plotting functions, you would use curve() to draw a function. It works fine, but I like to use <a href=\"http:\/\/ggplot2.org\/\">ggplot2<\/a> when I can.<\/p>\n<p>Turns out ggplot2 supports this well. The following code sample maps the same functions I was mapping on the calculator (sin, cos, and tan from 0 to 2pi radians). <\/p>\n<script src=\"https:\/\/gist.github.com\/29645fa7d982c2e3ff1a.js\"><\/script>\n<p>And the resulting graph is&#8230;<\/p>\n<p><a href=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Trig.jpeg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Trig-300x160.jpeg\" alt=\"ggplot2 Trig Function Graphing\" width=\"300\" height=\"160\" class=\"alignnone size-medium wp-image-3793\" srcset=\"http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Trig-300x160.jpeg 300w, http:\/\/hoolihan.net\/blog-tim\/wp-content\/uploads\/2015\/10\/Trig.jpeg 450w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been buffing up on some areas of Math that I felt rusty in. One of the tools I was using was my old TI-82 calculator I used in high school. I even got the TI Connect software working where I could download screenshots, etc. You can put in data sets (see screen cap [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[286,267],"tags":[287,278,288],"class_list":["post-3788","post","type-post","status-publish","format-standard","hentry","category-math","category-r","tag-graphing-calculator","tag-r","tag-ti"],"_links":{"self":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts\/3788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/comments?post=3788"}],"version-history":[{"count":0,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts\/3788\/revisions"}],"wp:attachment":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/media?parent=3788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/categories?post=3788"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/tags?post=3788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}