博文

目前显示的是 八月, 2015的博文

python 环境搭建

sudo apt-get install python python-dev python-pip python-setuptools #Install Oracle Java JDK/JRE 8 sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer java -version sudo apt-get install oracle-java8-set-default #Install PyCharm sudo apt-add-repository ppa:mystic-mirage/pycharm sudo apt-get update sudo apt-get install pycharm or sudo apt-get install pycharm-community 用户名:yueting3527 注册码: ===== LICENSE BEGIN ===== 93347-12042010 00001FMHemWIs"6wozMZnat3IgXKXJ 2!nV2I6kSO48hgGLa9JNgjQ5oKz1Us FFR8k"nGzJHzjQT6IBG!1fbQZn9!Vi ===== LICENSE END =====

Dot Density Maps in R

city = readShapePoly("/home/xuefliang/RInMedicine/city/city_region.shp")  gpclibPermit()  #install.packages("gpclib", type = "source") tract <- fortify(city,region="CNTY_CODE") city@data$USE_CODE8 <- sample(1000,14) dots.rand <- dotsInPolys(city, as.integer(city@data$USE_CODE8)) #table(iconv(city$NAME, from = "GBK")) dots <- data.frame(coordinates(dots.rand)[,1:2]) ggplot(tract, aes(x = long, y = lat)) +   geom_polygon(aes(group = group), size=0.2, fill = "white") +   coord_equal()+geom_point(data=dots, aes(x=x,y=y), size=0.8,colour="red")

ggmap Overlay shapefile with filled polygon of regions

city = readShapePoly("/home/xuefliang/RInMedicine/city/city_region.shp")  gpclibPermit()  #install.packages("gpclib", type = "source") tract <- fortify(city,region="CNTY_CODE") gansu <- get_map(location = 'gansu', zoom = 5,maptype = 'roadmap') ggmap(gansu)+   geom_polygon(data = tract, aes(x = long, y = lat, group = group), colour = "black",fill='grey' ,alpha = 0.2) +   theme_nothing(legend = TRUE)+   coord_cartesian(xlim=c(90, 110), ylim=c(32, 43))

Dot Density Electoral Map

doInstall <- TRUE toInstall <- c("XML", "maps", "ggplot2", "sp","RCurl","httr","plyr") if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} lapply(toInstall, library, character.only = TRUE) myURL <- "https://en.wikipedia.org/wiki/United_States_presidential_election,_2012" tabs <- getURL(myURL) allTables <- readHTMLTable(tabs) #library(httr) #tabs <- GET(myURL) #allTables <- readHTMLTable(rawToChar(tabs$content), stringsAsFactors = F) #stateTable = readHTMLTable(readLines(myURL, encoding = "UTF-8"), which = 14, header = T) #str(allTables)  # Look at the allTables object to find the specific table we want stateTable <- allTables[[14]]  # We want the 14th table in the list (maybe 13th?) #head(stateTable) # Clean up: stateTable <- stateTable[2:(nrow(stateTable)-1), ]  # Drop summary lines stateTable <- rename(stateTable,c("V1&q