{"id":10883,"date":"2021-03-09T11:04:12","date_gmt":"2021-03-09T19:04:12","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=10883"},"modified":"2023-05-24T03:31:55","modified_gmt":"2023-05-24T10:31:55","slug":"couchbase-r-programming-with-query-maps-leaflet","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/","title":{"rendered":"R Programming With Coucbhase NoSQL Queries &amp; Maps"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Many statistical data analysts and data scientists use the <\/span><a href=\"https:\/\/r-project.org\"><span style=\"font-weight: 400\">R programming language<\/span><\/a><span style=\"font-weight: 400\"> to crunch their numbers outside of a database. Likewise, database analysts try to do everything in the same database whenever possible to maintain a single source. Couchbase provides a common basis for bridging the gap between JSON datasets, powerful query languages, and analytic toolsets like R.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">The distributed, fault-tolerant nature and flexible schema are only some of the reasons businesses turn to Couchbase. To learn more, see <a href=\"https:\/\/www.couchbase.com\/resources\/why-nosql\/\">Why Enterprises use NoSQL<\/a> to deliver next-generation products.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The <a href=\"https:\/\/www.couchbase.com\/products\/developer-sdk\/\">Couchbase SDK<\/a> covers the most popular programming languages: Java, .NET, Node.js, Go, and more. But does not need to provide a specific drive for R because it can easily use the REST API.<\/span><\/p>\n<p><span style=\"font-weight: 400\">In this post, I resurrect an R programming tutorial from an older blog and see how R works with the latest Couchbase version. Examples show how to run a tabular N1QL\/SQL query on the JSON data, as well as mapping the resulting locations of some of the <a href=\"https:\/\/www.couchbase.com\/blog\/geospatial-basics-spatial-databases-and-nosql-examples\/\">geospatial data<\/a>.\u00a0<\/span><\/p>\n<h2><span style=\"font-weight: 400\">What is R?<\/span><\/h2>\n<p><span style=\"font-weight: 400\">R fills the need for an open source statistical computing and graphics toolset similar to proprietary products like SAS and SPSS. This covers statistical analysis and graphical visualization geared especially well for publication-ready graphical plots for scientific documentation.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Is R better than Python for statistical analysis? That&#8217;s open for debate, and yet there are plenty of advocates. In fact, for many developers, it may be the most popular analytical environment you&#8217;ve <em>never<\/em> used. In <\/span><a href=\"https:\/\/r4stats.com\/articles\/popularity\/\"><span style=\"font-weight: 400\">one global R programming jobs search project<\/span><\/a><span style=\"font-weight: 400\">, the author found R programming in 5th place behind Python, SQL, Java, and Amazon ML. It was moderately higher than C\/C++, Tableau, Hadoop, and even SAS for statistical data analysis toolsets.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The ecosystem that it spawned provides tens of thousands of packages that add powerful analytics, time series analysis, visualization capabilities and more. Several IDEs exist for building solutions, for this post I use <\/span><a href=\"https:\/\/rstudio.com\/\"><span style=\"font-weight: 400\">R Studio<\/span><\/a><span style=\"font-weight: 400\"> (which I easily used for the first time while writing this article).<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Setting up Couchbase<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The default Couchbase server install has everything needed for this tutorial. I suggest installing it on a single node, ideally the PC you are using with R Studio so the connection URL will be <\/span><i><span style=\"font-weight: 400\">localhost<\/span><\/i><span style=\"font-weight: 400\">. I&#8217;m using the Couchbase 7.x beta version.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Once installed, set up a <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-settings\/install-sample-buckets.html\"><span style=\"font-weight: 400\">new bucket with the <\/span><i><span style=\"font-weight: 400\">travel-sample<\/span><\/i><span style=\"font-weight: 400\"> dataset<\/span><\/a><span style=\"font-weight: 400\"> and create a new user that has access to that bucket.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Setting up R Studio<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Next, <\/span><a href=\"https:\/\/mirror.rcg.sfu.ca\/mirror\/CRAN\/\"><span style=\"font-weight: 400\">install R<\/span><\/a><span style=\"font-weight: 400\"> and then <\/span><a href=\"https:\/\/rstudio.com\/\"><span style=\"font-weight: 400\">R Studio Desktop<\/span><\/a><span style=\"font-weight: 400\"> (free version) with all the default options. Once installations are complete, launch R Studio and select<\/span><span style=\"font-weight: 400\"> Tools -&gt; Install Packages<\/span><span style=\"font-weight: 400\"> and install these four:<\/span><em><span style=\"font-weight: 400\"> httr, jsonlite, ggplot2, leaflet<\/span><\/em><span style=\"font-weight: 400\">.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Alternatively, you can run the following code in the R coding console:<\/span><\/p>\n<pre class=\"lang:r decode:true\">install.packages(c(\"httr\", \"jsonlite\", \"ggplot2\", \"leaflet\"))<\/pre>\n<p><span style=\"font-weight: 400\">R Studio will go away and install a bunch of underlying dependencies for you. Meanwhile, you continue to the next step while that runs.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Testing N1QL Query in Couchbase<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Before we start the R programming code, let&#8217;s test the query using the Query tab in the <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-ui\/manage-ui.html#console-query\"><span style=\"font-weight: 400\">Couchbase web console<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT a.name, count(*) as total_flights\r\nFROM `travel-sample` r \r\nJOIN `travel-sample` a \r\nON KEYS r.airlineid \r\nWHERE r.type =\"route\" \r\nAND a.type=\"airline\" \r\nGROUP BY a.name \r\nORDER BY total_flights DESC \r\nLIMIT 20<\/pre>\n<p>If you&#8217;ve had to work JSON before, you&#8217;ll see how simple it can be to query from documents in Couchbase using a familiar syntax.<\/p>\n<p><span style=\"font-weight: 400\">The result shows the top 20 airlines and the number of flights each has in the sample database.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">R Coding N1QL Query<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Set up your R project by setting the library requirements at the top of the script in the console:<\/span><\/p>\n<pre class=\"lang:r decode:true\">library(httr) \r\nlibrary(jsonlite) \r\nlibrary(ggplot2) \r\nlibrary(leaflet)<\/pre>\n<p><span style=\"font-weight: 400\">To build the query and handle the data responses, we create a few variables.<\/span><\/p>\n<p><span style=\"font-weight: 400\">First, the connection info for Couchbase is provided including the URL, port, and the username and password you created earlier:<\/span><\/p>\n<pre class=\"lang:r decode:true\">cbServer &lt;- \"https:\/\/localhost:8093\/query\/service\"<\/pre>\n<p><span style=\"font-weight: 400\">Then encode the query into its own variable as well. Note the escaped double quotes that are needed (\\&#8221;).<\/span><\/p>\n<pre class=\"lang:r decode:true\">query &lt;- \"SELECT a.name, count(*) as total_flights FROM `travel-sample` r JOIN `travel-sample` a ON KEYS r.airlineid WHERE r.type =\\\"route\\\" AND a.type=\\\"airline\\\" GROUP BY a.name ORDER BY total_flights DESC LIMIT 20\"<\/pre>\n<p><span style=\"font-weight: 400\">Next is setting up the HTTP request:<\/span><\/p>\n<pre class=\"lang:r decode:true\">req &lt;- httr::POST(cbServer, httr::add_headers(\"Content-Type\" = \"application\/x-www-form-urlencoded;charset=UTF-8\"), body = paste(\"statement=\", query), authentication(\"public\",\"public\"))<\/pre>\n<p><span style=\"font-weight: 400\">And then receiving the actual response from the request and assigning it to a variable to hold the data:<\/span><\/p>\n<pre class=\"lang:r decode:true\">res &lt;- fromJSON(httr::content(req, \"text\")) \r\nairlineFlights &lt;- res$results<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_coding_airlines_cmd.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-10884\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_coding_airlines_cmd-267x300.jpg\" alt=\"Couchbase R Programming SQL Query output\" width=\"267\" height=\"300\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_airlines_cmd-267x300.jpg 267w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_airlines_cmd-18x20.jpg 18w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_airlines_cmd.jpg 300w\" sizes=\"auto, (max-width: 267px) 100vw, 267px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">That&#8217;s it!\u00a0<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Visualize Query Results from Couchbase<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Now we can see the results of the query by entering the data variable:<\/span><\/p>\n<p><span style=\"font-weight: 400\">R-Studio, with the ggplot extension and a few settings, is a simple way to rapidly view data in a variable:<\/span><\/p>\n<pre class=\"lang:r decode:true\">ggplot(data=airlineFlights, aes(x=name, y=total_flights)) + theme(axis.text.x=element_text(angle=90,hjust=1)) + geom_bar(stat=\"identity\")<\/pre>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/cb_r_programming_n1ql_query1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10885 size-large\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/cb_r_programming_n1ql_query1-1024x832.png\" alt=\"Couchbase R Programming SQL Query chart\" width=\"900\" height=\"731\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/cb_r_programming_n1ql_query1-1024x832.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/cb_r_programming_n1ql_query1-300x244.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/cb_r_programming_n1ql_query1-768x624.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/cb_r_programming_n1ql_query1-20x16.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/cb_r_programming_n1ql_query1.png 1280w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">Now you can tweak the query or ggplot code and experiment with other approaches.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Map Geospatial Data from Couchbase using R Coding<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The power of some of the other packages is incredible. For the next example, we use the R coding that leverages the <\/span><a href=\"https:\/\/leafletjs.com\/\"><span style=\"font-weight: 400\">Leaflet web mapping library<\/span><\/a><span style=\"font-weight: 400\">.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Let&#8217;s change the query to list hotels that are pet-friendly. Because the hotel data includes a geographic latitude and longitude object (&#8220;geo&#8221;) we can easily make a <a href=\"https:\/\/www.couchbase.com\/blog\/geospatial-basics-spatial-databases-and-nosql-examples\/\">map<\/a> of the results.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Adjust your query to include name, latitude, and longitude along with a couple of simple filters:<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT name,geo.lat as lat,geo.lon as long \r\nFROM `travel-sample` \r\nWHERE type=\"hotel\" AND city=\"London\" AND pets_ok=true<\/pre>\n<p><span style=\"font-weight: 400\">Test it in the Couchbase web console and you get 37 results. Then put the query into the variables as before:<\/span><\/p>\n<pre class=\"lang:r decode:true\">query &lt;- \"SELECT name, geo.lat as lat, geo.lon as long FROM `travel-sample` WHERE type=\\\"hotel\\\" AND city=\\\"London\\\" AND pets_ok=true\" \r\nreq &lt;- httr::POST(cbServer, httr::add_headers(\"Content-Type\" = \"application\/x-www-form-urlencoded;charset=UTF-8\"), body = paste(\"statement=\", query), authentication(\"public\",\"public\")) res &lt;- fromJSON(httr::content(req, \"text\")) \r\npetFriendlyHotelsLondon &lt;- res$results<\/pre>\n<p><span style=\"font-weight: 400\">Results will look similar to this:<\/span><\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_coding_hotels.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-10886\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_coding_hotels-274x300.jpg\" alt=\"Couchbase R Programming SQL Query output\" width=\"274\" height=\"300\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_hotels-274x300.jpg 274w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_hotels-300x328.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_hotels-18x20.jpg 18w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_hotels.jpg 768w\" sizes=\"auto, (max-width: 274px) 100vw, 274px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">To make the map, we use the leaflet package and provide a few settings to identify the fields to use for locating the marker symbols on the map.<\/span><\/p>\n<pre class=\"lang:r decode:true\">leaflet(data = petFriendlyHotelsLondon) %&gt;% addTiles() %&gt;% addMarkers(~long, ~lat, popup = ~as.character(name), label = ~as.character(name)) %&gt;% addProviderTiles(providers$OpenStreetMap)<\/pre>\n<p><span style=\"font-weight: 400\">R Studio is a great information-rich IDE allowing code editing, interactive console, and built-in viewer components, including the map, just like ggplot did with the earlier chart.\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_programming_n1ql_query_map1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-10887\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_programming_n1ql_query_map1-1024x832.png\" alt=\"Couchbase R Programming SQL Query Mapping in Leaflet web map\" width=\"900\" height=\"731\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_programming_n1ql_query_map1-1024x832.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_programming_n1ql_query_map1-300x244.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_programming_n1ql_query_map1-768x624.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_programming_n1ql_query_map1-20x16.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_programming_n1ql_query_map1.png 1280w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">Naturally, you can expand any of the window panes accordingly:<\/span><\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_coding_leaflet_mapping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-10888\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/03\/couchbase_r_coding_leaflet_mapping-1024x768.png\" alt=\"Couchbase R Programming with Map and Leaflet Web Map\" width=\"900\" height=\"675\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_leaflet_mapping-1024x768.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_leaflet_mapping-300x225.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_leaflet_mapping-768x576.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_leaflet_mapping-20x15.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/03\/couchbase_r_coding_leaflet_mapping.png 1064w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<h2><span style=\"font-weight: 400\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The flexibility of Couchbase and R, with its powerful set of 3rd party packages, are a great combination. Application developers can leave data in the central database and take advantage of failover, distributed processing, full-text search, and SQL analytics.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Meanwhile, the same database can serve analysts who need an easy-to-use API to access data without making multiple offline copies.<\/span><\/p>\n<p><span style=\"font-weight: 400\">This comprehensive data platform approach continues to attract enterprises of all sizes that need to simplify their architecture while also making it more stable and scalable.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Further Reading<\/span><\/h2>\n<ul>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/www.couchbase.com\/resources\/why-nosql\/\"><span style=\"font-weight: 400\">NoSQL Databases: Why successful enterprises rely on NoSQL<\/span><\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/geospatial-basics-spatial-databases-and-nosql-examples\/\">What is a Geospatial Database?<\/a><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Whitepaper: <\/span><a href=\"https:\/\/resources.couchbase.com\/c\/relational-no-sql-wp?x=Y7B0ca\"><span style=\"font-weight: 400\">Moving from Relational to NoSQL: How to Get Started<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-rest-api\/index.html\"><span style=\"font-weight: 400\">N1QL REST API reference<\/span><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Many statistical data analysts and data scientists use the R programming language to crunch their numbers outside of a database. Likewise, database analysts try to do everything in the same database whenever possible to maintain a single source. Couchbase provides [&hellip;]<\/p>\n","protected":false},"author":75185,"featured_media":3865,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[2242,1816,8683],"tags":[2013,2403],"ppma_author":[9163],"class_list":["post-10883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-connectors","category-couchbase-server","category-geospatial","tag-r","tag-statistics"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is R Programming Language? NoSQL &amp; Maps Guide<\/title>\n<meta name=\"description\" content=\"What is R programming language? Use this expert guide from Couchbase to utilize NoSQL query and map data in R. \u2713 Get started with R coding statistics now!\" \/>\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.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R Programming With Coucbhase NoSQL Queries &amp; Maps\" \/>\n<meta property=\"og:description\" content=\"What is R programming language? Use this expert guide from Couchbase to utilize NoSQL query and map data in R. \u2713 Get started with R coding statistics now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-09T19:04:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-24T10:31:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/07\/featuredR.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2036\" \/>\n\t<meta property=\"og:image:height\" content=\"1264\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tyler Mitchell - Senior Product Marketing Manager\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@1tylermitchell\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tyler Mitchell - Senior Product Marketing Manager\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\"},\"author\":{\"name\":\"Tyler Mitchell - Senior Product Marketing Manager\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0\"},\"headline\":\"R Programming With Coucbhase NoSQL Queries &amp; Maps\",\"datePublished\":\"2021-03-09T19:04:12+00:00\",\"dateModified\":\"2023-05-24T10:31:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\"},\"wordCount\":1009,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg\",\"keywords\":[\"R\",\"statistics\"],\"articleSection\":[\"Connectors\",\"Couchbase Server\",\"Geospatial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\",\"name\":\"What is R Programming Language? NoSQL & Maps Guide\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg\",\"datePublished\":\"2021-03-09T19:04:12+00:00\",\"dateModified\":\"2023-05-24T10:31:55+00:00\",\"description\":\"What is R programming language? Use this expert guide from Couchbase to utilize NoSQL query and map data in R. \u2713 Get started with R coding statistics now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg\",\"width\":2036,\"height\":1264},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"R Programming With Coucbhase NoSQL Queries &amp; Maps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0\",\"name\":\"Tyler Mitchell - Senior Product Marketing Manager\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/d8a7c532bf2b94b7a2fe7a8439aafd75\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g\",\"caption\":\"Tyler Mitchell - Senior Product Marketing Manager\"},\"description\":\"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind.\",\"sameAs\":[\"https:\/\/linkedin.com\/in\/tylermitchell\",\"https:\/\/x.com\/1tylermitchell\",\"https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What is R Programming Language? NoSQL & Maps Guide","description":"What is R programming language? Use this expert guide from Couchbase to utilize NoSQL query and map data in R. \u2713 Get started with R coding statistics now!","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.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/","og_locale":"en_US","og_type":"article","og_title":"R Programming With Coucbhase NoSQL Queries &amp; Maps","og_description":"What is R programming language? Use this expert guide from Couchbase to utilize NoSQL query and map data in R. \u2713 Get started with R coding statistics now!","og_url":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-03-09T19:04:12+00:00","article_modified_time":"2023-05-24T10:31:55+00:00","og_image":[{"width":2036,"height":1264,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/07\/featuredR.jpg","type":"image\/jpeg"}],"author":"Tyler Mitchell - Senior Product Marketing Manager","twitter_card":"summary_large_image","twitter_creator":"@1tylermitchell","twitter_misc":{"Written by":"Tyler Mitchell - Senior Product Marketing Manager","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/"},"author":{"name":"Tyler Mitchell - Senior Product Marketing Manager","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0"},"headline":"R Programming With Coucbhase NoSQL Queries &amp; Maps","datePublished":"2021-03-09T19:04:12+00:00","dateModified":"2023-05-24T10:31:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/"},"wordCount":1009,"commentCount":2,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg","keywords":["R","statistics"],"articleSection":["Connectors","Couchbase Server","Geospatial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/","url":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/","name":"What is R Programming Language? NoSQL & Maps Guide","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg","datePublished":"2021-03-09T19:04:12+00:00","dateModified":"2023-05-24T10:31:55+00:00","description":"What is R programming language? Use this expert guide from Couchbase to utilize NoSQL query and map data in R. \u2713 Get started with R coding statistics now!","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/07\/featuredR.jpg","width":2036,"height":1264},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-r-programming-with-query-maps-leaflet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"R Programming With Coucbhase NoSQL Queries &amp; Maps"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0","name":"Tyler Mitchell - Senior Product Marketing Manager","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/d8a7c532bf2b94b7a2fe7a8439aafd75","url":"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g","caption":"Tyler Mitchell - Senior Product Marketing Manager"},"description":"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind.","sameAs":["https:\/\/linkedin.com\/in\/tylermitchell","https:\/\/x.com\/1tylermitchell","https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg"],"url":"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/"}]}},"authors":[{"term_id":9163,"user_id":75185,"is_guest":0,"slug":"tylermitchell","display_name":"Tyler Mitchell - Senior Product Marketing Manager","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/876da1e4284f1832c871b3514caf7867357744b8c0a370ef6f53a79dee2f379e?s=96&d=mm&r=g","author_category":"","last_name":"Mitchell - Senior Product Marketing Manager","first_name":"Tyler","job_title":"Senior Product Marketing Manager","user_url":"","description":"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/10883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/75185"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=10883"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/10883\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/3865"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=10883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=10883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=10883"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=10883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}