{"id":9635,"date":"2022-09-19T23:01:05","date_gmt":"2022-09-19T17:31:05","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/"},"modified":"2022-09-19T23:01:05","modified_gmt":"2022-09-19T17:31:05","slug":"solved-how-to-select-certain-character-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/","title":{"rendered":"[Solved] How to select certain character? [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-49294527\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"49294527\" data-parentid=\"49293529\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Please add a reproducible sample next time. Below is the sample input based on the data from the given link. <\/p>\n<p>Input:  <\/p>\n<pre><code>url &lt;- c(\"\/history\/apollo\/\",    \"\/shuttle\/countdown\/\",  \"\/shuttle\/missions\/sts-73\/mission-sts-73.html\", \n         \"\/shuttle\/countdown\/liftoff.html\", \"\/shuttle\/missions\/sts-73\/sts-73-patch-small.gif\",  \n         \"\/images\/NASA-logosmall.gif\",  \"\/shuttle\/countdown\/video\/livevideo.gif\",   \n         \"\/shuttle\/countdown\/countdown.html\",   \"\/shuttle\/countdown\/\",  \"https:\/\/stackoverflow.com\/\",    \"\/shuttle\/countdown\/count.gif\", \n         \"\/images\/NASA-logosmall.gif\",  \"\/images\/KSC-logosmall.gif\",    \"\/shuttle\/countdown\/count.gif\", \n         \"\/images\/NASA-logosmall.gif\",  \"\/images\/KSC-logosmall.gif\",    \"\/images\/ksclogo-medium.gif\",   \n         \"\/images\/launch-logo.gif\", \"\/facts\/about_ksc.html\",    \"\/shuttle\/missions\/sts-71\/images\/KSC-95EC-0916.jpg\")\n\nreturn_code &lt;- c(200, 200, 200, 304, 200, 304, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 304, 200, 200, 200)\n\ndf &lt;- tibble(url, return_code)\ndf\n\n# A tibble: 20 x 2\n   url                                               return_code\n   &lt;chr&gt;                                                   &lt;dbl&gt;\n 1 \/history\/apollo\/                                         200.\n 2 \/shuttle\/countdown\/                                      200.\n 3 \/shuttle\/missions\/sts-73\/mission-sts-73.html             200.\n 4 \/shuttle\/countdown\/liftoff.html                          304.\n 5 \/shuttle\/missions\/sts-73\/sts-73-p=atch-small.gif         200.\n 6 \/images\/NASA-logosmall.gif                               304.\n 7 \/shuttle\/countdown\/video\/livevideo.gif                   200.\n 8 \/shuttle\/countdown\/countdown.html                        200.\n 9 \/shuttle\/countdown\/                                      200.\n10 \/                                                        200.\n11 \/shuttle\/countdown\/count.gif                             200.\n12 \/images\/NASA-logosmall.gif                               200.\n13 \/images\/KSC-logosmall.gif                                200.\n14 \/shuttle\/countdown\/count.gif                             200.\n15 \/images\/NASA-logosmall.gif                               200.\n16 \/images\/KSC-logosmall.gif                                200.\n17 \/images\/ksclogo-medium.gif                               304.\n18 \/images\/launch-logo.gif                                  200.\n19 \/facts\/about_ksc.html                                    200.\n20 \/shuttle\/missions\/sts-71\/images\/KSC-95EC-0916.jpg        200.\n<\/code><\/pre>\n<p>Method:  <\/p>\n<pre><code>library(tidyverse)\n\n# Custom function to select the last vector from the str_split() output \nfind_gif &lt;- function(myDF) {\n  map_chr(myDF, ~(.x %&gt;% last()))\n}\n\ndf2 &lt;- df %&gt;% \n  filter(grepl(\".gif$\", url), return_code == 200) %&gt;% \n  mutate(url2 = find_gif(str_split(url, \"[\/]\"))) %&gt;% \n  select(url2, return_code)\n<\/code><\/pre>\n<p>Output:  <\/p>\n<pre><code>df2\n# A tibble: 9 x 2\n  url2                    return_code\n  &lt;chr&gt;                         &lt;dbl&gt;\n1 sts-73-patch-small.gif         200.\n2 livevideo.gif                  200.\n3 count.gif                      200.\n4 NASA-logosmall.gif             200.\n5 KSC-logosmall.gif              200.\n6 count.gif                      200.\n7 NASA-logosmall.gif             200.\n8 KSC-logosmall.gif              200.\n9 launch-logo.gif                200.\n<\/code><\/pre>\n<p>If you want only the unique values, use the <code>unique()<\/code> function.<\/p>\n<pre><code>df2 %&gt;% select(url2) %&gt;% unique()\n# A tibble: 6 x 1\n  url2                  \n  &lt;chr&gt;                 \n1 sts-73-patch-small.gif\n2 livevideo.gif         \n3 count.gif             \n4 NASA-logosmall.gif    \n5 KSC-logosmall.gif     \n6 launch-logo.gif \n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How to select certain character? [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Please add a reproducible sample next time. Below is the sample input based on the data from the given link. Input: url &lt;- c(&#8220;\/history\/apollo\/&#8221;, &#8220;\/shuttle\/countdown\/&#8221;, &#8220;\/shuttle\/missions\/sts-73\/mission-sts-73.html&#8221;, &#8220;\/shuttle\/countdown\/liftoff.html&#8221;, &#8220;\/shuttle\/missions\/sts-73\/sts-73-patch-small.gif&#8221;, &#8220;\/images\/NASA-logosmall.gif&#8221;, &#8220;\/shuttle\/countdown\/video\/livevideo.gif&#8221;, &#8220;\/shuttle\/countdown\/countdown.html&#8221;, &#8220;\/shuttle\/countdown\/&#8221;, &#8220;https:\/\/stackoverflow.com\/&#8221;, &#8220;\/shuttle\/countdown\/count.gif&#8221;, &#8220;\/images\/NASA-logosmall.gif&#8221;, &#8220;\/images\/KSC-logosmall.gif&#8221;, &#8220;\/shuttle\/countdown\/count.gif&#8221;, &#8220;\/images\/NASA-logosmall.gif&#8221;, &#8220;\/images\/KSC-logosmall.gif&#8221;, &#8220;\/images\/ksclogo-medium.gif&#8221;, &#8220;\/images\/launch-logo.gif&#8221;, &#8220;\/facts\/about_ksc.html&#8221;, &#8220;\/shuttle\/missions\/sts-71\/images\/KSC-95EC-0916.jpg&#8221;) return_code &lt;- c(200, 200, 200, 304, 200, 304, 200, 200, 200, &#8230; <a title=\"[Solved] How to select certain character? [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\" aria-label=\"More on [Solved] How to select certain character? [closed]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[2499,321,362],"class_list":["post-9635","post","type-post","status-publish","format-standard","hentry","category-solved","tag-gsub","tag-r","tag-string"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How to select certain character? [closed] - JassWeb<\/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:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How to select certain character? [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Please add a reproducible sample next time. Below is the sample input based on the data from the given link. Input: url &lt;- c(&quot;\/history\/apollo\/&quot;, &quot;\/shuttle\/countdown\/&quot;, &quot;\/shuttle\/missions\/sts-73\/mission-sts-73.html&quot;, &quot;\/shuttle\/countdown\/liftoff.html&quot;, &quot;\/shuttle\/missions\/sts-73\/sts-73-patch-small.gif&quot;, &quot;\/images\/NASA-logosmall.gif&quot;, &quot;\/shuttle\/countdown\/video\/livevideo.gif&quot;, &quot;\/shuttle\/countdown\/countdown.html&quot;, &quot;\/shuttle\/countdown\/&quot;, &quot;https:\/\/stackoverflow.com\/&quot;, &quot;\/shuttle\/countdown\/count.gif&quot;, &quot;\/images\/NASA-logosmall.gif&quot;, &quot;\/images\/KSC-logosmall.gif&quot;, &quot;\/shuttle\/countdown\/count.gif&quot;, &quot;\/images\/NASA-logosmall.gif&quot;, &quot;\/images\/KSC-logosmall.gif&quot;, &quot;\/images\/ksclogo-medium.gif&quot;, &quot;\/images\/launch-logo.gif&quot;, &quot;\/facts\/about_ksc.html&quot;, &quot;\/shuttle\/missions\/sts-71\/images\/KSC-95EC-0916.jpg&quot;) return_code &lt;- c(200, 200, 200, 304, 200, 304, 200, 200, 200, ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-19T17:31:05+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How to select certain character? [closed]\",\"datePublished\":\"2022-09-19T17:31:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\"},\"wordCount\":49,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"gsub\",\"r\",\"string\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\",\"name\":\"[Solved] How to select certain character? [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-19T17:31:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How to select certain character? [closed]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How to select certain character? [closed] - JassWeb","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:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How to select certain character? [closed] - JassWeb","og_description":"[ad_1] Please add a reproducible sample next time. Below is the sample input based on the data from the given link. Input: url &lt;- c(\"\/history\/apollo\/\", \"\/shuttle\/countdown\/\", \"\/shuttle\/missions\/sts-73\/mission-sts-73.html\", \"\/shuttle\/countdown\/liftoff.html\", \"\/shuttle\/missions\/sts-73\/sts-73-patch-small.gif\", \"\/images\/NASA-logosmall.gif\", \"\/shuttle\/countdown\/video\/livevideo.gif\", \"\/shuttle\/countdown\/countdown.html\", \"\/shuttle\/countdown\/\", \"https:\/\/stackoverflow.com\/\", \"\/shuttle\/countdown\/count.gif\", \"\/images\/NASA-logosmall.gif\", \"\/images\/KSC-logosmall.gif\", \"\/shuttle\/countdown\/count.gif\", \"\/images\/NASA-logosmall.gif\", \"\/images\/KSC-logosmall.gif\", \"\/images\/ksclogo-medium.gif\", \"\/images\/launch-logo.gif\", \"\/facts\/about_ksc.html\", \"\/shuttle\/missions\/sts-71\/images\/KSC-95EC-0916.jpg\") return_code &lt;- c(200, 200, 200, 304, 200, 304, 200, 200, 200, ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/","og_site_name":"JassWeb","article_published_time":"2022-09-19T17:31:05+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How to select certain character? [closed]","datePublished":"2022-09-19T17:31:05+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/"},"wordCount":49,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["gsub","r","string"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/","name":"[Solved] How to select certain character? [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-19T17:31:05+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-select-certain-character-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How to select certain character? [closed]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/9635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=9635"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/9635\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=9635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=9635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=9635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}