Question 1

讀取資料以及查看資料格式

setwd("/Users/tayloryen/Desktop/大學/成大課業/大四下/資料管理/0319/inclass_exercise/EX1")
dta<-read.table("student2017.txt",header=T)
str(dta)
## 'data.frame':    16 obs. of  1 variable:
##  $ ID: Factor w/ 16 levels "C44035023","D84021057",..: 5 1 3 4 2 7 8 10 11 6 ...

修改資料,在倒數第三個加入U76067010

dta<-fix(dta)
## Warning in edit.data.frame(get(subx, envir = parent), title = subx, ...):
## added factor levels in 'ID'

確認最終資料內容

dta
##           ID
## 1  D84057058
## 2  C44035023
## 3  D84041162
## 4  D84046081
## 5  D84021057
## 6  U36037025
## 7  U36041074
## 8  U36041090
## 9  U36051087
## 10 U36031118
## 11 U36041082
## 12 U76051019
## 13 U76054025
## 14 U76064062
## 15 U76067010
## 16 U76041064
## 17 U76041080

Question 2

會出現錯誤是因為women的資料格式是list

data.entry(women)
class(women)
## [1] "list"
plot(women)
## Error in xy.coords(x, y, xlabel, ylabel, log): 'x' is a list, but does not have components 'x' and 'y'

Question 3

讀survival of Titanic passengers的資料

load("/Users/tayloryen/Desktop/大學/成大課業/大四下/資料管理/0319/inclass_exercise/EX3/titanic.raw.rdata")

查看前六筆資料樣式以及資料架構

head(titanic.raw)
##   Class  Sex   Age Survived
## 1   3rd Male Child       No
## 2   3rd Male Child       No
## 3   3rd Male Child       No
## 4   3rd Male Child       No
## 5   3rd Male Child       No
## 6   3rd Male Child       No
str(titanic.raw)
## 'data.frame':    2201 obs. of  4 variables:
##  $ Class   : Factor w/ 4 levels "1st","2nd","3rd",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ Sex     : Factor w/ 2 levels "Female","Male": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Age     : Factor w/ 2 levels "Adult","Child": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Survived: Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 1 1 1 ...

Question 4

所使用的教授為現任成大心理系系主任謝淑蘭教授的資料

pacman::p_load(scholar)
dta4<-get_citation_history('8Wb4EZ8AAAAJ')
plot(dta4,main="Citation Number from 2014 to 2018",xlab="Year",ylab="Citations",type="h",lwd=2,xlim=c(2014,2018),ylim=c(0,400))
grid()

The End