data science - github pages · > ggmap(map) + geom_point(aes(x = lon, y = lat, size = uvi), data =...

42
R (1) Data Science 2016/10/3 ( ) . CC - - 3.0 http://shouzo.github.io/

Upload: hoanghanh

Post on 05-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • R (1)

    Data Science

    2016/10/3 ()

    . CC --

    3.0 http://shouzo.github.io/

  • Agenda() Prepare() Basic()

  • () Prepare

    () Prepare

  • () Prepare

    https://youtu.be/fcd6zSk0yd8 0:00 - 0:37

  • () Prepare

    "RStudio"

    RStudio

  • () Basic

    () Basic

  • () Basic

    1.

  • = (Knowledge Discovery in DatabasesKDD)

    A. B. C.

    """"

    https://zh.wikipedia.org/wiki/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98

    () Basic

  • (Knowledge Discovery)

    (Hypothesis Testing)

    (Classification)

    (Predication)

    (Estimation)

    (Clustering)

    (Association)

    http://myweb.fcu.edu.tw/~mhsung/Ecommerce/Data_Mining/DM_methods.htm

    () Basic

  • STEP1 STEP2 STEP3

    () Basic

  • () Basic

    2.

  • () Basic

    (1) (Vectors)

    (2) (Factors)

    (3) (Arrays)(Matrices)

    (4) (DataFrame)

    (5) (Lists)

  • () Basic

    >1+1[1]2>>1+2+3[1]6>>3*7*2[1]42>>4/2[1]2>>4/3[1]1.333333>

    >4*6+5[1]29>>(4*6)+5[1]29>>4*(6+5)[1]44>

    > > > >

  • () Basic

    >#("

  • () Basic (Vectors)

    (1) (Vectors)1. ""

    2. (Vectors)"(colume)""(row)"

    3. "(Objects)"

    ""(logical)(integer)(numeric)(complex)(character)

    >#"(vectors)">x>#"x">x[1]12345678910>

  • () Basic (Vectors)

    (1) (Vectors)(1)

    >x>x*3#3[1]3691215>>x+2#2[1]34567>>x4#4[1]32101>>x/10#10[1]0.10.20.30.40.5>>x^2#[1]1491625>

  • () Basic (Vectors)

    (1) (Vectors)(2)

    >#":">1:10[1]12345678910>5:4[1]5432101234>>#>xyx+y#[1]4202468101214>xy#[1]6666666666>x*y#[1]5898507162740>x/y#[1]0.20.51.02.05.0Inf7.04.03.02.5>x^y#[1]1.000000e+006.250000e023.703704e026.250000e022.000000e011.000000e+00[7]7.000000e+006.400000e+017.290000e+021.000000e+04

  • () Basic (Vectors)

    (1) (Vectors)

    1. 2. >x>#"[]">x[1][1]1>>x[1:2][1]12>>x[c(1,4)]#"1""4"[1]14>

    >x>#"mode()">mode(x)[1]"numeric">>#"length()">length(x)[1]10>

  • () Basic (Factors)

    (2) (Factors)

    ABABO

    1. ""2. "level"3. """"

    1 R "" levels ordered = TRUE Factor "")

    2(Factors)""(Vectors)

    >x>factor(x)[1]124312341Levels:1234>>>#Level>factor(x,labels=c("", "","",""))[1]Levels:

    >factor(x,ordered=TRUE)#[1]124312341Levels:1

  • () Basic (Array)(Matrices)

    (3) (Array)(Matrices)

    >#2x3x2>theArraytheArray,,1

    [,1][,2][,3][1,]135[2,]246

    ,,2

    [,1][,2][,3][1,]7911[2,]81012

    >#3x4>theMatrixtheMatrix[,1][,2][,3][,4][1,]14710[2,]25811[3,]36912>

    1. ""

    2. "(row)""(colume)"

    ""(vectors)

    1. ""

    2. "(row)""(colume)"

    ""(vectors)

    (Array) (Matrices)

  • () Basic (DataFrame)

    (4) (DataFrame)

    >aaidscores.1scores.211809022819133829244839355849466859577869688879799889810108999>

    "(row)""(colume)"

    1. """"

    2. """"

  • () Basic (Lists)

    (5) (Lists)

    >xx$irisSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpecies15.13.51.40.2setosa24.93.01.40.2setosa34.73.21.30.2setosa44.63.11.50.2setosa55.03.61.40.2setosa65.43.91.70.4setosa74.63.41.40.3setosa85.03.41.50.2setosa94.42.91.40.2setosa104.93.11.50.1setosa115.43.71.50.2setosa124.83.41.60.2setosa134.83.01.40.1setosa

    1. 2.

    numericcharacterDataFramelist...

  • () Basic ...

  • () Basic

  • () Basic

    R ggmap

  • () Basic

    R ggmap

  • () Basic

    (1)

    R ggmap

  • () Basic

    (2) - http://data.gov.tw/node/6076

    R ggmap

  • () Basic

    R ggmap

  • () Basic

    STEP1(1)ggmapmapproj#()

    >install.packages("ggmap")#"ggmap">install.packages("mapproj")#"mapproj"

    #>library(ggmap)#"ggmap">library(mapproj)#"mapproj"

    #>mapggmap(map)

    R ggmap

  • () Basic

    STEP1 ()

    R ggmap

  • () Basic

    STEP2(1)

    >getwd()#"getwd()"

    R ggmap

  • () Basic

    STEP2(2)

    >setwd()#"setwd()"

    #"r_test">setwd(".../r_test")

    R ggmap

  • () Basic

    STEP2(3)

    http://data.gov.tw/node/6076

    R ggmap

  • () Basic

    STEP2(4)

    >#>uv>head(uv)#SiteNameUVIPublishAgencyCountyWGS84LonWGS84LatPublishTime10120,29,16.9222,40,23.092016090611:0021120,18,20.4822,45,27.022016090611:0036120,19,2.1023,18,20.282016090611:0047120,14,50.4623,27,55.112016090611:0056120,52,50.0623,28,14.192016090611:0062120,48,05.0223,30,30.822016090611:00>

    R ggmap

  • () Basic

    STEP2A.

    >lon.deguv$lonlat.deguv$lat

    >ggmap(map)+geom_point(aes(x=lon,y=lat,size=UVI),data=uv)B.

    R ggmap

  • () Basic

    STEP3

    R ggmap

  • () Reference

    () Reference

  • http://datascienceandr.org/

    1. R - Wush WuChih Cheng LiangJohnson Hsieh

    2. R - &http://goo.gl/18mwug

    3. R - https://goo.gl/NPdzzP

    1. DataCamphttps://www.datacamp.com/

    2. R for Data Sciencehttp://r4ds.had.co.nz/

    () Reference

  • R

    Jared P. Lander

    () Reference

  • Taiwan R User Grouphttps://www.facebook.com/Tw.R.User/

    https://www.facebook.com/twdsconf/

    / Data Visualizationhttps://www.facebook.com/data.visualize/

    () Reference

  • Q & A