{"id":75596,"date":"2020-01-20T11:43:05","date_gmt":"2020-01-20T06:13:05","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=75596"},"modified":"2020-01-20T11:43:05","modified_gmt":"2020-01-20T06:13:05","slug":"r-vector-functions","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/","title":{"rendered":"Vector Functions in R &#8211; Master R seq, sapply, rep functions"},"content":{"rendered":"<p><strong>Are you finding difficulty working with R vectors? Don&#8217;t worry, look at some vector functions in R that will make your life easier with R programming.<\/strong><\/p>\n<p>Functions are pieces of code that are created to perform specific tasks. We make functions to avoid repetition of code and errors. They also help us in making the code organized and readable.<\/p>\n<p>In this R tutorial, we will take a look at a few commonly used vector functions in R. We will see how they are used and what they do. We will also look at some examples of their usage. So, let\u2019s get going!<\/p>\n<h2>What are R vector functions?<\/h2>\n<p>There are functions in R that either help with creating a vector or take vectors as input arguments. We call such functions as <strong>vector functions<\/strong> in R programming.<\/p>\n<p>Today, we are going to study a few vector functions in R, that you will find very useful in R programming. These functions are:<\/p>\n<ol>\n<li>rep()<\/li>\n<li>seq()<\/li>\n<li>is.vector()<\/li>\n<li>as.vector()<\/li>\n<li>any()<\/li>\n<li>all()<\/li>\n<li>lapply()<\/li>\n<li>sapply()<\/li>\n<\/ol>\n<p>These functions either take a vector as input or return a vector as output.<\/p>\n<h3>1. The rep() Function<\/h3>\n<p>The <strong><code>rep()<\/code><\/strong> function repeats a vector, or value, a given number of times. It then returns a vector with the repeated values. For example:<\/p>\n<p>Wait! Do you know what is R vector? \u2013 <a href=\"https:\/\/techvidvan.com\/tutorials\/r-vector\/\"><strong>vectors in R<\/strong><\/a><\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">repeated_vector &lt;- rep(c(1,2,3),4)\nrepeated_vector<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-rep-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75598\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-rep-function.png\" alt=\"rep() function - vector functions in r\" width=\"1299\" height=\"742\" \/><\/a><\/strong><\/p>\n<p>We can also specify the <strong>length<\/strong> of the vector instead of the number of times using the <strong><code>length.out<\/code><\/strong> argument. The function keeps the repetition going until the mentioned length is reached.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">repeated_vector2 &lt;- rep(c(4,5,6),length.out=15)\nrepeated_vector2<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-rep-function-length.out_.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75599\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-rep-function-length.out_.png\" alt=\"rep() function length.out - vector functions in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<p>We can also use the <strong><code>each<\/code><\/strong> argument to repeat each element of the repeating vector. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">repeated_vector3 &lt;- rep(c(4,5,6),each=3)\nrepeated_vector3<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-function-in-r-rep-function-each.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75606\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-function-in-r-rep-function-each.png\" alt=\"rep() function each - vector functions in r \" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>2. The seq() Function<\/h3>\n<p>The <strong><code>seq()<\/code><\/strong> function creates a sequence of numbers starting from the given <strong><code>from<\/code><\/strong> argument and ending at the <strong><code>to<\/code><\/strong> argument. We can also pass the <strong><code>by<\/code><\/strong> argument to specify the increase\/decrease step. By default, the increase step is 1.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sequence1 &lt;- seq(from=2,to=15,by=0.5)\nsequence1<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-seq-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75607\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-seq-function.png\" alt=\"seq() function - vector functions in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<p>We can also use the <strong><code>length.out<\/code><\/strong> argument to specify the length of the output vector. This way R keeps the sequence going until the desired length is reached.<\/p>\n<p><strong>Example 2:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sequence2 &lt;- seq(from=5,length.out=12)\nsequence2<\/pre>\n<p><strong>Example 3:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sequence3 &lt;- seq(from=5,to=15,length.out=20)\nsequence3<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-function-in-r-seq-function-length.out_.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75608\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-function-in-r-seq-function-length.out_.png\" alt=\"seq() function length.out - vector function in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>3. The is.vector() Function<\/h3>\n<p>The <strong><code>is.vector()<\/code><\/strong> function takes an object as an input and returns <strong><code>TRUE<\/code><\/strong> if the input object is a vector. It returns <strong><code>FALSE<\/code><\/strong> if the object is not a <a href=\"https:\/\/cran.r-project.org\/doc\/manuals\/r-release\/R-intro.html#Vector-arithmetic\">vector<\/a>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">is.vector(sequence3)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-is.vector-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75609\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-is.vector-function.png\" alt=\"is.vector() function - vector functions in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>4. The as.vector() Function<\/h3>\n<p>The <strong><code>as.vector()<\/code><\/strong> function takes an object as an argument and converts it into a vector. Let&#8217;s take a look at the workings of this function with an example.<\/p>\n<p>First, let&#8217;s create a matrix. We will name this matrix <strong><code>mat_to_vec<\/code><\/strong>, as we will be converting it into a vector soon.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">mat_to_vec &lt;- matrix(c(1:9),c(3,3))\nmat_to_vec<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[,1] [,2] [,3]<br \/>\n[1,] 1 4 7<br \/>\n[2,] 2 5 8<br \/>\n[3,] 3 6 9<\/div>\n<p>By using the <strong><code>class()<\/code>\u00a0<\/strong>function we can confirm that <strong><code>mat_to_vec<\/code><\/strong> is in fact a matrix.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class(mat_to_vec)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[1] &#8220;matrix&#8221;<\/div>\n<p>Now, let&#8217;s use the <strong><code>as.vector()<\/code><\/strong> function on our matrix.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">mat_to_vec &lt;- as.vector(mat_to_vec)\nmat_to_vec<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[1] 1 2 3 4 5 6 7 8 9<\/div>\n<p>As you can see, <strong><code>mat_to_vec<\/code><\/strong> is now arranged in a single row instead of 3&#215;3 rows and columns. Instead of an integer matrix, it should now be an integer vector and should have a class of <strong>integer<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class(mat_to_vec)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[1] &#8220;integer&#8221;<\/div>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-as.vector-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75610\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-as.vector-function.png\" alt=\"as.vector() function - vector functions in r \" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>5. The any() Function<\/h3>\n<p>The <strong><code>any()<\/code><\/strong> function takes a vector and a logical condition as input arguments. It checks the vector against the condition and creates a <strong>logical vector<\/strong>. It then return<strong><code>TRUE<\/code><\/strong>, if <strong>any one<\/strong> of the elements in the logical vector is <strong><code>TRUE<\/code><\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">vec &lt;- as.integer(c(34,23,53,42,16,42,64,32,76))\nany(vec,vec&gt;50)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-any-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75611\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-any-function.png\" alt=\"any() function - vector functions in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>6. The all() Function<\/h3>\n<p>The <strong><code>all()<\/code><\/strong> function takes a vector and a logical condition as input arguments. It checks the vector against the condition and creates a logical vector. It then returns <strong><code>TRUE<\/code><\/strong> if <strong>all<\/strong> the elements in the logical vector are <strong><code>TRUE<\/code><\/strong>, and <strong><code>FALSE<\/code><\/strong> if <strong>all elements<\/strong> are not <strong><code>TRUE<\/code><\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">all(vec,vec&gt;50)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-all-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75612\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-all-function.png\" alt=\"all() function - vector functions in R\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>7. The lapply() Function<\/h3>\n<p>The <strong><code>lapply()<\/code><\/strong> function takes a vector, list or a data frame and a function. The <strong><code>lapply()<\/code><\/strong> function applies a function to all elements of a vector, <a href=\"https:\/\/techvidvan.com\/tutorials\/r-list\/\"><strong>list<\/strong><\/a> or data frames. The function then returns the result in the form of a <strong>list<\/strong>. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">names &lt;- c(\"JOHN\",\"RICK\",\"RAHUL\",\"ABDUL\")\nlapply(names,tolower)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-lapply-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75613\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-lapply-function.png\" alt=\"lapply() function - vector functions in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>8. The sapply() Function<\/h3>\n<p>The <strong><code>sapply()<\/code><\/strong> is very similar to the <strong><code>lappy()<\/code><\/strong> function. The only difference is that the <strong><code>sapply()<\/code><\/strong> function returns the result in the form of a vector. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sapply(names,tolower)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-sapply-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75614\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/vector-functions-in-r-sapply-function.png\" alt=\"sapply() function - vector functions in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h2>Summary<\/h2>\n<p>Vector functions are functions that perform operations on vectors or give output as vectors. In this article, we studied some important vector functions in R. We looked at their uses and also saw examples of their usage.<\/p>\n<p>The above functions like <strong><code>is.vector()<\/code><\/strong>, <strong><code>as.vector()<\/code><\/strong>, <strong><code>lapply()<\/code>,<\/strong>\u00a0<strong><code>sapply()<\/code>, <code>any()<\/code>, <\/strong>and<strong><code> seq()<\/code><\/strong>\u00a0are very important and commonly used functions in the R programming language.<\/p>\n<p><strong>Still, finding difficulty working with vector functions in R?<\/strong><\/p>\n<p>Feel free to ask any queries related to R tutorial and our experts at <strong>TechVidvan<\/strong> will be happy to help you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you finding difficulty working with R vectors? Don&#8217;t worry, look at some vector functions in R that will make your life easier with R programming. Functions are pieces of code that are created&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":75627,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1020],"tags":[1396,1397,1398,1399,1254,1400,1401,1402,1260],"class_list":["post-75596","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","tag-any","tag-lapply-r","tag-r-function","tag-r-seq","tag-r-vector","tag-r-vector-functions","tag-rep-in-r","tag-sapply-r","tag-vector-function-in-r"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Vector Functions in R - Master R seq, sapply, rep functions - TechVidvan<\/title>\n<meta name=\"description\" content=\"Vector functions in R are pieces of code that are created to perform specific tasks. In this R tutorial, have a look at few commonly used vector functions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vector Functions in R - Master R seq, sapply, rep functions - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Vector functions in R are pieces of code that are created to perform specific tasks. In this R tutorial, have a look at few commonly used vector functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-20T06:13:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/Vector-functions-in-R.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vector Functions in R - Master R seq, sapply, rep functions - TechVidvan","description":"Vector functions in R are pieces of code that are created to perform specific tasks. In this R tutorial, have a look at few commonly used vector functions.","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:\/\/techvidvan.com\/tutorials\/r-vector-functions\/","og_locale":"en_US","og_type":"article","og_title":"Vector Functions in R - Master R seq, sapply, rep functions - TechVidvan","og_description":"Vector functions in R are pieces of code that are created to perform specific tasks. In this R tutorial, have a look at few commonly used vector functions.","og_url":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-01-20T06:13:05+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/Vector-functions-in-R.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Vector Functions in R &#8211; Master R seq, sapply, rep functions","datePublished":"2020-01-20T06:13:05+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/"},"wordCount":760,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/Vector-functions-in-R.jpg","keywords":["any()","lapply R","r function","R seq","R Vector","R Vector functions","rep() in R","sapply R","vector function in r"],"articleSection":["R Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/","url":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/","name":"Vector Functions in R - Master R seq, sapply, rep functions - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/Vector-functions-in-R.jpg","datePublished":"2020-01-20T06:13:05+00:00","description":"Vector functions in R are pieces of code that are created to perform specific tasks. In this R tutorial, have a look at few commonly used vector functions.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/Vector-functions-in-R.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/Vector-functions-in-R.jpg","width":802,"height":420,"caption":"Vector functions in R"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/r-vector-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Vector Functions in R &#8211; Master R seq, sapply, rep functions"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=75596"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75596\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/75627"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=75596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=75596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=75596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}