This file contains hidden or 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
### Extracting Squads | |
library(XML) | |
doc <- readHTMLTable(doc="http://en.wikipedia.org/wiki/2014_FIFA_World_Cup_squads", header=TRUE) | |
#put the countries into a list | |
#had to manually check the correct doc to use for each country | |
l<-list(doc[[2]], doc[[4]],doc[[6]], doc[[8]],doc[[10]], doc[[12]],doc[[14]], doc[[16]],doc[[18]], doc[[20]], | |
doc[[22]], doc[[24]],doc[[26]], doc[[28]],doc[[30]], doc[[32]],doc[[34]], doc[[36]],doc[[38]], doc[[40]], | |
doc[[42]], doc[[44]],doc[[46]], doc[[48]],doc[[50]], doc[[52]],doc[[54]], doc[[56]],doc[[58]], doc[[60]], | |
doc[[62]], doc[[64]]) |
This file contains hidden or 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
#### Anscombe's Quartet | |
temp <- | |
data.frame( x1 = c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5), | |
y1 = c(8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68), | |
x2 = c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5), | |
y2 = c(9.14, 8.14, 8.74, 8.77, 9.26, 8.1, 6.13, 3.1, 9.13, 7.26, 4.74), | |
x3 = c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5), | |
y3 = c(7.46, 6.77, 12.74, 7.11, 7.81, 8.84, 6.08, 5.39, 8.15, 6.42, 5.73), | |
x4 = c(8, 8, 8, 8, 8, 8, 8, 19, 8, 8, 8), |
This file contains hidden or 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
### Quick illustration of dplyr / ggplot2 | |
library(dplyr) | |
library(ggplot2) | |
library(magrittr) | |
# Install babynames package | |
install.packages("babynames") | |
# load library |
This file contains hidden or 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
### Using tsne to map similarity of English Soccer Teams | |
library(engsoccerdata) | |
library(dplyr) | |
library(magrittr) | |
library(ggplot2) | |
library(tidyr) | |
library(tsne) |
This file contains hidden or 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(DiagrammeR) | |
#import onetrain data | |
head(onetrain) | |
edges <- onetrain | |
edges #edges.minlen doesn't seem to do much in final viz | |
# Create a 'nodes' data frame |
This file contains hidden or 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
### Bar plots in ggplot | |
# data come from engsoccerdata package. | |
#### bar plot | |
library(ggplot2) | |
ggplot(df, aes(Season, totalpts, fill= country)) + | |
geom_bar(position="dodge", stat="identity") + |
This file contains hidden or 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
### Permutation Test Example... #based on: http://spark.rstudio.com/ahmed/permutation/ | |
# Group A | |
a = c(86, 88, 89, 89, 92, 93, 94, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 99, 99, 101, 106, 107, 110, 113, 116, 118) | |
# Group B | |
b = c(89, 90, 92, 93, 93, 96, 99, 99, 99, 102, 103, 104, 105, 106, 106, 107, 108, 108, 110, 110, 112, 114, 116, 116) | |
df <- |
This file contains hidden or 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(sortableR) | |
library(ggplot2) | |
ui = shinyUI(fluidPage( | |
fluidRow( | |
column( width = 4 | |
,tags$h4("sortableR in Shiny - Moving widgets") | |
,tags$div(id="veryUniqueId", class="list-group" | |
,tags$div(class="list-group-item", sliderInput("slider", "Slide me:", min = 10, max = 500, value = 275)) |
This file contains hidden or 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
## app.R ## | |
library(shiny) | |
library(shinydashboard) | |
library(sortableR) | |
ui <- dashboardPage( | |
dashboardHeader(disable = TRUE), | |
dashboardSidebar(disable = TRUE), | |
dashboardBody( |
This file contains hidden or 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
## app.R ## | |
library(shiny) | |
library(sortableR) | |
ui = shinyUI(fluidPage( | |
fluidRow( | |
,tags$h4("sortableR in Shiny - Moving plots") |
OlderNewer