This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output$plotedition <- renderPlotly({ | |
plot_ly(data = popular_editions, x = Popularity , y = Scarcity, mode = "markers", | |
text= paste(Name, "<br>Edition: ", Edition, "<br>Country: ", Country, | |
"<br>City: ",City, "<br>Owner: ",Owner,"<br>Seeker: ", | |
Seeker,"<br>Trader: ",Trader, "<br>Difficulty: ",Difficulty), | |
color = Edition, | |
colors = c('olivedrab3','navyblue','indianred2','darkgoldenrod1')) %>% | |
layout(title='Collectible Editions: Scarcity vs. Popularity', | |
xaxis=list(title='Popularity: Seeker/max(Seeker)'), | |
yaxis=list(title='Scarcity: |Owner/max(Owner)-1|')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wss <- (nrow(mug[,7:9])-1)*sum(apply(mug[,7:9],2,var)) | |
for (i in 2:10) wss[i] <- sum(kmeans(mug[,7:9], | |
centers=i)$withinss) | |
plot(1:10, wss, type="b", xlab="Number of Clusters", | |
ylab="Within groups sum of squares") | |
#determines k=5 | |
set.seed(123) | |
mugCluster <- kmeans(mug[, 7:9], 5, nstart = 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(plotly) | |
library(dplyr) | |
library(countrycode) | |
shinyServer(function(input, output) { | |
chooseMap=function(a){ | |
switch(a, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user[which(is.na(user$Country)),3]<-'Undefined Country' | |
user$Country<-tolower(user$Country) | |
user$City<-tolower(user$City) | |
user$Country<-recode(user$Country, | |
"c('81250 r.o.c taiwan','台灣','taiwan( r.o.c)','taichung','roc')='taiwan'; | |
c('156013 russia ','russia ','россия','russian federation', | |
'russia / austria')='russia'; | |
c('america','arizona','california','ap','美國','wa','washington','wisconsin', | |
'アメリカ合衆国','vereinigte staaten','usa / philippines','usa/germany','va', | |
'usa ','usa','us ','united states of america ','united states of america', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup as bs | |
import re | |
import requests | |
import pandas as pd | |
url_list_user, userName, userCity, userCountry, userMug,userPercent,userTrading,userLooking= ([] for i in range(8)) | |
for i in range(1,438): | |
url_list_user.append('http://fredorange.com/users/?&pg=' + str(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
barInput <- reactive({ | |
newboroughkid<-boroughkid[,c("Borough",input$yvar)] | |
newboroughkid<-newboroughkid[newboroughkid$Borough %in% input$boroughbar,] | |
newboroughkid | |
}) | |
output$bar <- renderGvis({ | |
gvisColumnChart(barInput(),options = list(title="Are There Enough Seats at Pre-Kindergartens",hAxes="[{title:'Borough', | |
titleTextStyle: {color:'blue'}}]" | |
, vAxes="[{title:'Number of Eligible Kids', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output$table <- renderDataTable(kidtable, | |
options=list(aLengthMenu = c(15,25,50), | |
iDisplayLength = 15, | |
columnDefs = list(list(width = '160px', targets = c(10,11)), | |
list(width = '120px', targets = c(4,5)), | |
list(width = '200px', targets = 3)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mapInput <- eventReactive(input$go,{ | |
newkid<-kid[kid$Borough %in% input$borough & | |
kid$Type %in% input$type & | |
kid$Length %in% input$length,] | |
newkid | |
}) | |
output$map <- renderLeaflet({ | |
leaflet(kid) %>% | |
addProviderTiles("CartoDB.Positron") %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################use address to get long/lat info################ | |
kinder <- read.csv(url("https://github.com/amy17519/NYCPre-KGuide/blob/master/Universal_Pre-K__UPK__School_Locations.csv"), | |
stringsAsFactors=FALSE) | |
######paste zipcodes to all addresses to increase accuracy of locating | |
kinder$address<- paste(kinder$address,kinder$zip) | |
geo<-geocode(kinder$address) #use geocode from ggmap package to get longtitude/latitude coordinates | |
geo<-geo[,c(2,1)] #change col order of long and lat to match convention | |
#Find abnormal locations using longitude/latitude boundaries of NYC |