{"id":15613,"date":"2020-04-04T11:03:02","date_gmt":"2020-04-04T10:03:02","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?p=15613"},"modified":"2020-04-04T11:03:02","modified_gmt":"2020-04-04T10:03:02","slug":"dplyr-how-to-select-a-character-vector-of-variable-names","status":"publish","type":"post","link":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/","title":{"rendered":"dplyr: How to Select a Character Vector of Variable Names"},"content":{"rendered":"<div class=\"rdoc\">\n<p>Requirements:<\/p>\n<p>dplyr v&gt;=1.0.0<\/p>\n<pre class=\"r\"><code>library(dplyr)\r\n# Data preparation\r\ndf &lt;- as_tibble(iris)\r\ndf<\/code><\/pre>\n<pre><code>## # A tibble: 150 x 5\r\n##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species\r\n##           &lt;dbl&gt;       &lt;dbl&gt;        &lt;dbl&gt;       &lt;dbl&gt; &lt;fct&gt;  \r\n##  1          5.1         3.5          1.4         0.2 setosa \r\n##  2          4.9         3            1.4         0.2 setosa \r\n##  3          4.7         3.2          1.3         0.2 setosa \r\n##  4          4.6         3.1          1.5         0.2 setosa \r\n##  5          5           3.6          1.4         0.2 setosa \r\n##  6          5.4         3.9          1.7         0.4 setosa \r\n##  7          4.6         3.4          1.4         0.3 setosa \r\n##  8          5           3.4          1.5         0.2 setosa \r\n##  9          4.4         2.9          1.4         0.2 setosa \r\n## 10          4.9         3.1          1.5         0.1 setosa \r\n## # \u2026 with 140 more rows<\/code><\/pre>\n<pre class=\"r\"><code># Select varibales\r\nvariables = c(\"Species\", \"Sepal.Length\")\r\ndf %&gt;% select(any_of(variables))<\/code><\/pre>\n<pre><code>## # A tibble: 150 x 2\r\n##    Sepal.Length Species\r\n##           &lt;dbl&gt; &lt;fct&gt;  \r\n##  1          5.1 setosa \r\n##  2          4.9 setosa \r\n##  3          4.7 setosa \r\n##  4          4.6 setosa \r\n##  5          5   setosa \r\n##  6          5.4 setosa \r\n##  7          4.6 setosa \r\n##  8          5   setosa \r\n##  9          4.4 setosa \r\n## 10          4.9 setosa \r\n## # \u2026 with 140 more rows<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Requirements: dplyr v&gt;=1.0.0 library(dplyr) # Data preparation df &lt;- as_tibble(iris) df ## # A tibble: 150 x 5 ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;fct&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rating_form_position":"","rating_results_position":"","mr_structured_data_type":"","footnotes":""},"categories":[341],"tags":[359,357,358],"class_list":["post-15613","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-faq","tag-data-manipulation","tag-dplyr","tag-tidyverse"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>dplyr: How to Select a Character Vector of Variable Names - Datanovia<\/title>\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.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"dplyr: How to Select a Character Vector of Variable Names - Datanovia\" \/>\n<meta property=\"og:description\" content=\"Requirements: dplyr v&gt;=1.0.0 library(dplyr) # Data preparation df &lt;- as_tibble(iris) df ## # A tibble: 150 x 5 ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;fct&gt; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-04T10:03:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alboukadel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alboukadel\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\"},\"author\":{\"name\":\"Alboukadel\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\"},\"headline\":\"dplyr: How to Select a Character Vector of Variable Names\",\"datePublished\":\"2020-04-04T10:03:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\"},\"wordCount\":14,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg\",\"keywords\":[\"Data Manipulation\",\"dplyr\",\"tidyverse\"],\"articleSection\":[\"FAQ\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\",\"name\":\"dplyr: How to Select a Character Vector of Variable Names - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg\",\"datePublished\":\"2020-04-04T10:03:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg\",\"width\":1024,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"dplyr: How to Select a Character Vector of Variable Names\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"name\":\"Datanovia\",\"description\":\"Data Mining and Statistics for Decision Support\",\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.datanovia.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\",\"name\":\"Datanovia\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"width\":98,\"height\":99,\"caption\":\"Datanovia\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\",\"name\":\"Alboukadel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"caption\":\"Alboukadel\"},\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"dplyr: How to Select a Character Vector of Variable Names - Datanovia","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.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/","og_locale":"en_US","og_type":"article","og_title":"dplyr: How to Select a Character Vector of Variable Names - Datanovia","og_description":"Requirements: dplyr v&gt;=1.0.0 library(dplyr) # Data preparation df &lt;- as_tibble(iris) df ## # A tibble: 150 x 5 ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;fct&gt; [&hellip;]","og_url":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/","og_site_name":"Datanovia","article_published_time":"2020-04-04T10:03:02+00:00","og_image":[{"width":1024,"height":512,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg","type":"image\/jpeg"}],"author":"Alboukadel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alboukadel"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#article","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/"},"author":{"name":"Alboukadel","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e"},"headline":"dplyr: How to Select a Character Vector of Variable Names","datePublished":"2020-04-04T10:03:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/"},"wordCount":14,"commentCount":0,"publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg","keywords":["Data Manipulation","dplyr","tidyverse"],"articleSection":["FAQ"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/","url":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/","name":"dplyr: How to Select a Character Vector of Variable Names - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg","datePublished":"2020-04-04T10:03:02+00:00","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/Sur_le_sentier_montant_au_Pic_de_Greze.jpg","width":1024,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/blog\/dplyr-how-to-select-a-character-vector-of-variable-names\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"dplyr: How to Select a Character Vector of Variable Names"}]},{"@type":"WebSite","@id":"https:\/\/www.datanovia.com\/en\/#website","url":"https:\/\/www.datanovia.com\/en\/","name":"Datanovia","description":"Data Mining and Statistics for Decision Support","publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanovia.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanovia.com\/en\/#organization","name":"Datanovia","url":"https:\/\/www.datanovia.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","width":98,"height":99,"caption":"Datanovia"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e","name":"Alboukadel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","caption":"Alboukadel"},"url":"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/"}]}},"multi-rating":{"mr_rating_results":[]},"_links":{"self":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/comments?post=15613"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15613\/revisions"}],"predecessor-version":[{"id":15614,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15613\/revisions\/15614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/7849"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=15613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/categories?post=15613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/tags?post=15613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}