{"id":87,"date":"2012-06-23T18:39:36","date_gmt":"2012-06-23T15:39:36","guid":{"rendered":"http:\/\/ekqvist.goeuropeinfo.com\/rbloggerqvist\/?p=87"},"modified":"2012-06-23T18:39:36","modified_gmt":"2012-06-23T15:39:36","slug":"r-and-gvisgeomap","status":"publish","type":"post","link":"https:\/\/science.ekqvist.fi\/blogi\/uncategorized\/r-and-gvisgeomap\/","title":{"rendered":"R and gVisGeoMap"},"content":{"rendered":"<h1>Helppoa kuin hein\u00e4nteko<\/h1>\n<p><a href=\"http:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/coke_oven_2009.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-102\" title=\"coke_oven_2009\" src=\"http:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/coke_oven_2009-300x190.jpg\" alt=\"\" width=\"300\" height=\"190\" srcset=\"https:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/coke_oven_2009-300x190.jpg 300w, https:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/coke_oven_2009.jpg 562w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Here in Finland we have phrase: &#8221; Helppoa kuin hein\u00e4nteko&#8221;. Now my purpose is to indicate what is the relation between this phrase and using R library googleVis.<br \/>\nIn this example we use UN datasets <a href=\"http:\/\/data.un.org\/\" target=\"_blank\">from this source<\/a>.<\/p>\n<p>All datasets used in this examples You could download bloggerqvist server. Of course I encourage You to find appropriate UN dataset and find data within your interest.<\/p>\n<h2>Example1: Coke Oven gas production 2006-2009 (TJ)<\/h2>\n<p><code>################################################################<br \/>\nUN data source:<br \/>\nhttp:\/\/data.un.org\/<br \/>\nCoke oven gas - production<br \/>\n################################################################<br \/>\n# setting amazing library<br \/>\nlibrary(googleVis)<br \/>\n################################################################<br \/>\n# download data<br \/>\ninput &lt;- read.table(\"http:\/\/energy.goeuropeinfo.com\/data\/un_data\/UNdata_Export_20120622_210218958.csv\", header=TRUE, sep=\";\", na.strings=\"NA\", dec=\",\", strip.white=TRUE)<\/code><\/p>\n<p><code>#selecting yearly data<br \/>\nselect09&lt;- input[which(input$Year==\"2009\"),]<br \/>\nselect08&lt;- input[which(input$Year==\"2008\"),]<br \/>\nselect07&lt;- input[which(input$Year==\"2007\"),]<br \/>\nselect06&lt;- input[which(input$Year==\"2006\"),]<br \/>\n<\/code><code><br \/>\n#selecting variables<br \/>\nMap09&lt;- data.frame(select09$Country.or.Area, select09$Quantity)<br \/>\nMap08&lt;- data.frame(select08$Country.or.Area, select08$Quantity)<br \/>\nMap07&lt;- data.frame(select07$Country.or.Area, select07$Quantity)<br \/>\nMap06&lt;- data.frame(select06$Country.or.Area, select06$Quantity)<br \/>\n<\/code><code><br \/>\n#change variable name<br \/>\nnames(Map09)&lt;- c(\"Country\", \"Coke-oven gas prod. TJ\")<br \/>\nnames(Map08)&lt;- c(\"Country\", \"Coke-oven gas prod. TJ\")<br \/>\nnames(Map07)&lt;- c(\"Country\", \"Coke-oven gas prod. TJ\")<br \/>\nnames(Map06)&lt;- c(\"Country\", \"Coke-oven gas prod. TJ\")<br \/>\n<\/code><code><br \/>\n#year 2009<br \/>\nunmap09=gvisGeoMap(Map09, locationvar=\"Country\", numvar=\"Coke-oven gas prod. TJ\", options=list(height=350, dataMode='regions', chartid=\"Coke-oven prod 2009\"))<br \/>\n#year 2008<br \/>\nunmap08=gvisGeoMap(Map08, locationvar=\"Country\", numvar=\"Coke-oven gas prod. TJ\", options=list(height=350, dataMode='regions'))<br \/>\n#year 2007<br \/>\nunmap07=gvisGeoMap(Map07, locationvar=\"Country\", numvar=\"Coke-oven gas prod. TJ\", options=list(height=350, dataMode='regions'))<br \/>\n#year 2006<br \/>\nunmap06=gvisGeoMap(Map06, locationvar=\"Country\", numvar=\"Coke-oven gas prod. TJ\", options=list(height=350, dataMode='regions'))<br \/>\n<\/code><code><br \/>\n#testing that all is ok<br \/>\nplot(unmap09)<br \/>\nplot(unmap08)<br \/>\nplot(unmap07)<br \/>\nplot(unmap06)<br \/>\n<\/code><code><br \/>\n# saving just created map into html-file<br \/>\ncat(unmap09$html$chart, file=\"j:\/todo\/UN\/undata_cokeoven_prod_TJ_2009.html\")<br \/>\ncat(unmap08$html$chart, file=\"j:\/todo\/UN\/undata_cokeoven_prod_TJ_2008.html\")<br \/>\ncat(unmap07$html$chart, file=\"j:\/todo\/UN\/undata_cokeoven_prod_TJ_2007.html\")<br \/>\ncat(unmap06$html$chart, file=\"j:\/todo\/UN\/undata_cokeoven_prod_TJ_2006.html\")<\/code><\/p>\n<p>Results file looks like this:<br \/>\n<a href=\"http:\/\/ekqvist.goeuropeinfo.com\/rbloggerqvist\/data\/un_data\/undata_cokeoven_prod_TJ_2009.html\" target=\"_blank\">Map 2009<\/a>, <a href=\"http:\/\/ekqvist.goeuropeinfo.com\/rbloggerqvist\/data\/un_data\/undata_cokeoven_prod_TJ_2008.html\" target=\"_blank\">2008<\/a>, <a href=\"http:\/\/ekqvist.goeuropeinfo.com\/rbloggerqvist\/data\/un_data\/undata_cokeoven_prod_TJ_2007.html\" target=\"_blank\">2007<\/a> and <a href=\"http:\/\/ekqvist.goeuropeinfo.com\/rbloggerqvist\/data\/un_data\/undata_cokeoven_prod_TJ_2006.html\" target=\"_blank\">2006<\/a><\/p>\n<p>Have fun,<br \/>\nMarko<\/p>\n<p>&#8230;..oops Here Is also an another example&#8230;.<\/p>\n<h2>Example2: Energy use (kg oil eqv per capita)<\/h2>\n<p><a href=\"http:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/energy_use_2009.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-104\" title=\"energy_use_2009\" src=\"http:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/energy_use_2009-300x190.jpg\" alt=\"\" width=\"300\" height=\"190\" srcset=\"https:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/energy_use_2009-300x190.jpg 300w, https:\/\/science.ekqvist.fi\/blogi\/wp-content\/uploads\/2012\/06\/energy_use_2009.jpg 562w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><code>################################################################<br \/>\nUN data source:<br \/>\nhttp:\/\/data.un.org\/<br \/>\nenergy use<br \/>\n################################################################<br \/>\nlibrary(googleVis)<br \/>\ninput &lt;- read.table(\"http:\/\/energy.goeuropeinfo.com\/data\/UNdata_Export_20120623_070334184_energyuse_kg_eqv_oil_per_capita.txt\", header=TRUE, sep=\";\", na.strings=\"NA\", dec=\",\", strip.white=TRUE)<br \/>\n# select year into matrices<br \/>\nselect09&lt;- input[which(input$Year==\"2009\"),]<br \/>\nselect08&lt;- input[which(input$Year==\"2008\"),]<br \/>\nselect07&lt;- input[which(input$Year==\"2007\"),]<br \/>\nselect06&lt;- input[which(input$Year==\"2006\"),]<br \/>\n<\/code><code><br \/>\n#select area and value field<br \/>\nMap09&lt;- data.frame(select09$Country.or.Area, select09$Value)<br \/>\nMap08&lt;- data.frame(select08$Country.or.Area, select08$Value)<br \/>\nMap07&lt;- data.frame(select07$Country.or.Area, select07$Value)<br \/>\nMap06&lt;- data.frame(select06$Country.or.Area, select06$Value)<br \/>\n<\/code><code><br \/>\nnames(Map09)&lt;- c(\"Country\", \"Energy Use Eqv oil kg per capita\")<br \/>\nnames(Map08)&lt;- c(\"Country\", \"Energy Use Eqv oil kg per capita\")<br \/>\nnames(Map07)&lt;- c(\"Country\", \"Energy Use Eqv oil kg per capita\")<br \/>\nnames(Map06)&lt;- c(\"Country\", \"Energy Use Eqv oil kg per capita\")<br \/>\n<\/code><code><br \/>\nunmap09=gvisGeoMap(Map09, locationvar=\"Country\", numvar=\"Energy Use Eqv oil kg per capita\", options=list(height=350, dataMode='regions'))<br \/>\nunmap08=gvisGeoMap(Map08, locationvar=\"Country\", numvar=\"Energy Use Eqv oil kg per capita\", options=list(height=350, dataMode='regions'))<br \/>\nunmap07=gvisGeoMap(Map07, locationvar=\"Country\", numvar=\"Energy Use Eqv oil kg per capita\", options=list(height=350, dataMode='regions'))<br \/>\nunmap06=gvisGeoMap(Map06, locationvar=\"Country\", numvar=\"Energy Use Eqv oil kg per capita\", options=list(height=350, dataMode='regions', chartid=\"06\"),chartid=\"06\")<br \/>\n<\/code><code><\/code><\/p>\n<p>plot(unmap09)<br \/>\nplot(unmap08)<br \/>\nplot(unmap07)<br \/>\nplot(unmap06)<\/p>\n<p><code><br \/>\ncat(unmap09$html$chart, file=\"j:\/todo\/UN\/undata_energyuse_eqvkgpercapita_2009.html\")<br \/>\ncat(unmap08$html$chart, file=\"j:\/todo\/UN\/undata_energyuse_eqvkgpercapita_2008.html\")<br \/>\ncat(unmap07$html$chart, file=\"j:\/todo\/UN\/undata_energyuse_eqvkgpercapita_2007.html\")<br \/>\ncat(unmap06$html$chart, file=\"j:\/todo\/UN\/undata_energyuse_eqvkgpercapita_2006.html\")<br \/>\n<\/code><\/p>\n<p>that&#8217;s it&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Helppoa kuin hein\u00e4nteko Here in Finland we have phrase: &#8221; Helppoa kuin hein\u00e4nteko&#8221;. Now my purpose is to indicate what is the relation between this phrase and using R library googleVis. In this example we use UN datasets from this source. All datasets used in this examples You could download bloggerqvist server. Of course I <a class=\"read-more-excerpt\" href=\"https:\/\/science.ekqvist.fi\/blogi\/uncategorized\/r-and-gvisgeomap\/\">[&#8230;] Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"gallery","meta":[],"categories":[20,22,1],"tags":[29,33,36,48],"_links":{"self":[{"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/posts\/87"}],"collection":[{"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":0,"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"wp:attachment":[{"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/science.ekqvist.fi\/blogi\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}