羅德興老師的教學歷程檔案 - 107-1 資訊科技大數據分析 - 期末考試 B 卷
 

企業資訊與管理系
助理教授/日導
羅德興


歷程檔案 Portfolio

    期末考試 B 卷

    # 資訊科技大數據分析期末考 B 卷
    # 請安裝  R 3.5.2 
    setwd("d:/temp")
    getwd()
     
    # 資料集的第一步
    # 可參考 R 的 資料分析第一步
    require (datasets)
    # 看有哪些資料集
    data()
    # B-1 請列出第 5 個資料集的名稱:(       )
     
    head(airquality)
    # B-2 此資料集為:(           )
    # B-3 此資料集 第 3 筆資料的 wind   的值為:(        )
    # B-4 此資料集 第 4 筆資料的 Ozone  的值為:(        )
     
    iris
    summary(iris)
     
    # B-5 此資料集為:(         )
    # B-6 列出此資料集的三種品種(species)為:(      )
    # B-7 列出此資料集的其餘四個欄位名稱為 :(           )
    # B-8 此資料集第 3 筆資料的 Sepal.Length 的值為:(        )
    # B-9 此資料集第 11 筆資料的 Petal.Width 的值為:(        )
    # B-10 此資料集共有資料幾筆: (            )
     
    iris$Sepal.Width
    # B-11 此指令為:(            )
    # B-12 也可將該資料框 (data frame)視為矩陣或陣列 (matrix/array),則此指令可改寫為:(     )
     
    # Simple Scatter Plots (簡易散佈圖)
    # 散佈圖1
    plot(iris$Petal.Length, iris$Petal.Width, main="Edgar Anderson's Iris Data")
    # 散佈圖2
    plot(iris$Petal.Length, iris$Petal.Width, pch=c(23,24,25)[unclass(iris$Species)], main="Edgar Anderson's Iris Data")
    # 散佈圖3
    plot(iris$Petal.Length, iris$Petal.Width, pch=21, bg=c("red","green3","blue")[unclass(iris$Species)], main="Edgar Anderson's Iris Data")
    plot(iris[,3], iris[,4], pch=21, bg=c("red","green3","blue")[unclass(iris$Species)], main="Edgar Anderson's Iris Data")
     
    # Draftsman's or Pairs Scatter Plots (成對散佈圖)
    # 成對散佈圖
    pairs(iris[1:4], main = "Edgar Anderson's Iris Data", pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])
     
    # B-13 在 散佈圖1 的程式碼中,要將標題改為"您的名字",要改變的指令為:(        )
    # B-14 在 散佈圖1 的程式碼中,Y 軸的欄位名稱為:(      )
    # B-15 散佈圖2 與 散佈圖1 的差別為:(           )
    # B-16 散佈圖2 的程式碼中,c(23,24,25)[unclass(iris$Species)]的作用為:(       )
    # B-17 散佈圖3 中綠色圖示的品種類別為:(        )
    # B-18 成對散佈圖的作用為:(                  )
     
    # 載入maps及ggplot2套件
    # 資料來源 https://ithelp.ithome.com.tw/articles/10186894
    install.packages("maps")
    install.packages("ggplot2")
     
    library(maps) 
    library(ggplot2)
     
    #載入世界地圖二維地圖(Latitude緯度,Longitude經度)
    world_map <- map_data("world")
    head(world_map, 10)
     
    # B-19 這是每個國家地圖邊界的經緯度資料,變數有:(         )個。
    # B-20 這是每個國家地圖邊界的經緯度資料,大概邊界資料有:(           )筆。
     
    #找出區域
    sort(unique(world_map$region))
     
    # 輸入一下你想要旅行的歐洲國家,然後利用指定國家的邊界經緯度劃出幾個國家的地圖。
    # 旅行國家
    mycountry <- c("France", "Austria", "Italy", "Switzerland", "Germany", "Spain")
    honeymoon <- map_data("world", region = mycountry)
     
    p <- ggplot(honeymoon, aes(x = long, y = lat, group = group, fill = region)) + 
      geom_polygon(colour = "black") + 
      scale_fill_brewer(palette = "Set2")
    p
     
    # B-21 想要旅行的國家存在哪個變數:(       )
    # B-22 想要旅行的國家共有幾個:(        )
     
    # 用城市經緯度來畫點
    # 決定好國家後,來試算一下你想要去的城市,符合以下任一條件:
    # 首都人口 > 85萬人
     
    #載入世界城市的經緯度(二維地圖)
    data(world.cities)
     
    mycity <- subset(world.cities, (world.cities$capital == 1 | world.cities$pop > 8500000) & world.cities$country.etc %in% mycountry)
    mycity$region <- mycity$country.etc
    mycity$group <- 1
    mycity
     
    # B-23 world.cities 是世界城市的經緯度資料,變數有:(         )個。
    # B-24 world.cities 大概資料有:(        )筆。
    # B-25 符合 首都人口 > 85 萬人 的城市 有:(         )筆。
     
    # 加上旅行城市的點圖,然後人口越多點越大(size=pop)。
    p + 
      geom_point(aes(x = long, y = lat, size = pop), data = mycity, alpha = .7) 
     
    # 加上旅行城市的名稱,位置放在城市點-0.5緯度
    p +
      geom_point(aes(x = long, y = lat, size = pop), data = mycity, alpha = .7) +
      geom_text(aes(x = long, y = lat - 0.5, label = name), data = mycity, colour = "black", fontface = "bold")
     
    全部共 0則留言
    登入帳號密碼代表遵守學術網路規範


    文章分類 Labels


    最新文章 Top10

    中華科技大學數位化學習歷程 - 意見反應