{"id":63743,"date":"2020-10-22T10:58:12","date_gmt":"2020-10-22T14:58:12","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=63743"},"modified":"2022-11-21T09:46:30","modified_gmt":"2022-11-21T14:46:30","slug":"why-you-should-use-vapply-in-r","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/","title":{"rendered":"Why You Should Use vapply in R"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this post we\u2019ll cover the&nbsp;<strong>vapply<\/strong>&nbsp;function in R.&nbsp;<strong>vapply<\/strong>&nbsp;is generally lesser known than the more popular&nbsp;<strong>sapply<\/strong>,&nbsp;<strong>lapply<\/strong>, and&nbsp;<strong>apply<\/strong>&nbsp;functions. However, it is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors. Because of this, it can be more advisable to use&nbsp;<strong>vapply<\/strong>&nbsp;rather than&nbsp;<strong>sapply<\/strong>&nbsp;or&nbsp;<strong>lapply<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Examples<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take the following example. Here, we have a list of numeric vectors and we want to get the max value of each vector. That\u2019s simple enough \u2013 we can just use&nbsp;<strong>sapply<\/strong>&nbsp;and apply the max function for each vector.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\ntest <- list(a = c(1, 3, 5), b = c(2,4,6), c = c(9,8,7))<br><br>\n \nsapply(test, max)\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But what if our list also contains a vector of characters, rather than numeric values? Running the example below gives us the max value of each vector, but coerces the final result to a character vector, which would not be desirable if our code \/ script is expecting numeric results.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\ntest$d <- c(\"a\", \"b\", \"c\")<br><br>\n \nsapply(test, max)\n<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"547\" height=\"75\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2020\/10\/sapply-in-r.png\" alt=\"vapply\" class=\"wp-image-63758 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/10\/sapply-in-r.png 547w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/10\/sapply-in-r-300x41.png 300w\" data-sizes=\"(max-width: 547px) 100vw, 547px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 547px; aspect-ratio: 547\/75;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To get around this, we can use&nbsp;<strong>vapply<\/strong>. In this case, we just need to add an extra parameter that specifies the data type expected for the function being applied \u2013 i.e. when we apply the max function we expect to be applying it to numeric vectors. Running the code below will result in an error, rather than coercing the final result to a character vector.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\nvapply(test, max, numeric(1))\n<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"640\" height=\"63\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2020\/10\/vapply-example-in-r.png\" alt=\"\" class=\"wp-image-63768 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/10\/vapply-example-in-r.png 640w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/10\/vapply-example-in-r-300x30.png 300w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 640px; aspect-ratio: 640\/63;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>numeric(1)<\/strong>&nbsp;signifies that we just want individual numeric values.&nbsp;<strong>numeric(0)<\/strong>&nbsp;would signify we\u2019re expecting zero-length numeric values.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To adjust the expected data type, we just need to change the third parameter. For example, if we are expecting a list of data frames, we could write:<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\nvapply(frames, nrow, data.frame(1))\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, the third parameter is called FUN.VALUE, so we could also do this:<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\t\nvapply(frames, nrow, FUN.VALUE = data.frame(1))\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all for now!&nbsp;<em><a href=\"https:\/\/365datascience.teachable.com\/courses\/data-scientist-career-track?affcode=130400_ubcdm-g4\">Check out online courses here to learn more about R \/ Python \/ data science (including my course on web scraping)!<\/a><\/em>&nbsp;To learn about other lesser-known apply functions,&nbsp;<a href=\"https:\/\/theautomatic.net\/2018\/11\/13\/those-other-apply-functions\/\">see this post<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Visit &nbsp;<a href=\"https:\/\/theautomatic.net\/\">TheAutomatic.net<\/a>&nbsp;to download the complete R script: <a href=\"https:\/\/theautomatic.net\/2020\/10\/20\/why-you-should-use-vapply-in-r\/\">https:\/\/theautomatic.net\/2020\/10\/20\/why-you-should-use-vapply-in-r\/<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The function &#8220;vapply&#8221; is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.<\/p>\n","protected":false},"author":388,"featured_media":25708,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,338,341,352,344,342],"tags":[5121,6956,8485,806,1006,487,6591,508],"contributors-categories":[13695],"class_list":["post-63743","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-ibkr-quant-news","category-quant-development","category-quant-north-america","category-quant-regions","category-r-development","tag-big-data","tag-data-analysis","tag-data-mining","tag-data-science","tag-fintech","tag-r","tag-rstats","tag-rstudio","contributors-categories-theautomatic-net"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v28.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Why You Should Use vapply in R | IBKR Quant<\/title>\n<meta name=\"description\" content=\"The function &quot;vapply&quot; is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/63743\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Why You Should Use vapply in R | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"The function &quot;vapply&quot; is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-22T14:58:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T14:46:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"535\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Andrew Treadway\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Andrew Treadway\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Andrew Treadway\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/d4018570a16fb867f1c08412fc9c64bc\"\n\t            },\n\t            \"headline\": \"Why You Should Use vapply in R\",\n\t            \"datePublished\": \"2020-10-22T14:58:12+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:46:30+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/\"\n\t            },\n\t            \"wordCount\": 133,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/11\\\/binary-code.jpg\",\n\t            \"keywords\": [\n\t                \"Big Data\",\n\t                \"Data Analysis\",\n\t                \"Data Mining\",\n\t                \"Data Science\",\n\t                \"fintech\",\n\t                \"R\",\n\t                \"rstats\",\n\t                \"RStudio\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Quant\",\n\t                \"Quant Development\",\n\t                \"Quant North America\",\n\t                \"Quant Regions\",\n\t                \"R Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/\",\n\t            \"name\": \"Why You Should Use vapply in R | IBKR Quant Blog\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/11\\\/binary-code.jpg\",\n\t            \"datePublished\": \"2020-10-22T14:58:12+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:46:30+00:00\",\n\t            \"description\": \"The function \\\"vapply\\\" is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/why-you-should-use-vapply-in-r\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/11\\\/binary-code.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/11\\\/binary-code.jpg\",\n\t            \"width\": 900,\n\t            \"height\": 535,\n\t            \"caption\": \"Algo Trading\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/d4018570a16fb867f1c08412fc9c64bc\",\n\t            \"name\": \"Andrew Treadway\",\n\t            \"description\": \"Andrew Treadway currently works as a Senior Data Scientist, and has experience doing analytics, software automation, and ETL. He completed a master\u2019s degree in computer science \\\/ machine learning, and an undergraduate degree in pure mathematics. Connect with him on LinkedIn: https:\\\/\\\/www.linkedin.com\\\/in\\\/andrew-treadway-a3b19b103\\\/In addition to TheAutomatic.net blog, he also teaches in-person courses on Python and R through my NYC meetup: more details.\",\n\t            \"sameAs\": [\n\t                \"https:\\\/\\\/theautomatic.net\\\/about-me\\\/\"\n\t            ],\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/andrewtreadway\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Why You Should Use vapply in R | IBKR Quant","description":"The function \"vapply\" is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.","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:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/63743\/","og_locale":"en_US","og_type":"article","og_title":"Why You Should Use vapply in R | IBKR Quant Blog","og_description":"The function \"vapply\" is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/","og_site_name":"IBKR Campus US","article_published_time":"2020-10-22T14:58:12+00:00","article_modified_time":"2022-11-21T14:46:30+00:00","og_image":[{"width":900,"height":535,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg","type":"image\/jpeg"}],"author":"Andrew Treadway","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Andrew Treadway","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/"},"author":{"name":"Andrew Treadway","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/d4018570a16fb867f1c08412fc9c64bc"},"headline":"Why You Should Use vapply in R","datePublished":"2020-10-22T14:58:12+00:00","dateModified":"2022-11-21T14:46:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/"},"wordCount":133,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg","keywords":["Big Data","Data Analysis","Data Mining","Data Science","fintech","R","rstats","RStudio"],"articleSection":["Data Science","Programming Languages","Quant","Quant Development","Quant North America","Quant Regions","R Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/","name":"Why You Should Use vapply in R | IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg","datePublished":"2020-10-22T14:58:12+00:00","dateModified":"2022-11-21T14:46:30+00:00","description":"The function \"vapply\" is very useful when you know what data type you\u2019re expecting to apply a function to as it helps to prevent silent errors.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/why-you-should-use-vapply-in-r\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg","width":900,"height":535,"caption":"Algo Trading"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/d4018570a16fb867f1c08412fc9c64bc","name":"Andrew Treadway","description":"Andrew Treadway currently works as a Senior Data Scientist, and has experience doing analytics, software automation, and ETL. He completed a master\u2019s degree in computer science \/ machine learning, and an undergraduate degree in pure mathematics. Connect with him on LinkedIn: https:\/\/www.linkedin.com\/in\/andrew-treadway-a3b19b103\/In addition to TheAutomatic.net blog, he also teaches in-person courses on Python and R through my NYC meetup: more details.","sameAs":["https:\/\/theautomatic.net\/about-me\/"],"url":"https:\/\/www.interactivebrokers.com\/campus\/author\/andrewtreadway\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/11\/binary-code.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/63743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/388"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=63743"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/63743\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/25708"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=63743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=63743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=63743"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=63743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}