Graphics not showing in R: device null?

I am trying to create a graphic using rworldmap using my dataframe dagg. ETA: data . Here's what I have so far.

library(rworldmap)
data(dagg)
sPDF <- joinCountryData2Map(dagg, joinCode='ISO2',
nameJoinColumn='country', verbose='TRUE')

mapDevice()

mapCountryData(sPDF, nameColumnToPlot='avoidance', 
numCats=10, mapTitle="Avoidance", addLegend=TRUE)
dev.off()

      

But when I run, nothing appears. The console displays "null device 1". It only worked now and I'm not sure what could change it ...

Perhaps I am not using the correct device ?

ETA: Below is a summary of the rworldmap I am reading from.

+3


source to share


1 answer


dev.off()

closes the currently active graphics device, so if you run all of this code at the same time, the map will build and disappear almost immediately with typical output:

## null device 
##           1 

      

Doing the next exclusive dev.off()

should result in the expected map.



library(rworldmap)
dagg <- read.csv(
  'http://raw.githubusercontent.com/pourque/country-data/master/data/dagg.csv')
sPDF <- joinCountryData2Map(dagg, joinCode='ISO2',
                            nameJoinColumn='country', verbose='TRUE')

mapDevice()   
mapCountryData(sPDF, nameColumnToPlot='avoidance', 
               numCats=10, mapTitle="Avoidance", addLegend=TRUE)

      

enter image description here

+4


source







All Articles