Q1

setwd("D:/201802/data_management/w4/")
dta <- read.csv("student2017.txt",sep = "",h=T)
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 U76067010
## 15 U76064062
## 16 U76041064
## 17 U76041080

Q2

library(datasets)
dta2 <- women
str(dta2)
## 'data.frame':    15 obs. of  2 variables:
##  $ height: num  58 59 60 61 62 63 64 65 66 67 ...
##  $ weight: num  115 117 120 123 126 129 132 135 139 142 ...
data.entry(dta2)
str(dta2)
## List of 2
##  $ height: num [1:15] 50 59 60 61 62 63 64 65 66 67 ...
##  $ weight: num [1:15] 115 117 120 123 126 129 132 135 139 142 ...

當輸入數字後,兩列的數值變成list,R便無法將任何一個當成x或y作圖。

Q3

load("D:/201802/data_management/w4/titanic.raw.rdata")

#看data的名稱
ls()
## [1] "dta"         "dta2"        "titanic.raw"
dta3 <- titanic.raw
head(dta3)
##   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

Q4

pacman::p_load(scholar)
dta <- get_citation_history('8Wb4EZ8AAAAJ')
plot(dta, xlab = "Year", ylab = "Citations", type = "h", 
     lwd = 2, xlim = c(2013, 2018), ylim = c(0, 500), main = "Scholar:Shulan Hsieh")
grid()