1.The following student ID file is missing an ID U76067010 at the third to the last position. How would you fix it? Dowload and display the data contents in R.
(dta<-read.table("student2017.txt", header = T))
## 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 U76041064
## 16 U76041080
dta$ID<-as.character(dta$ID)
missdta <- "U76067010"
dta2<-data.frame(c(dta[1:14,],missdta,dta[15:16,]))
names(dta2)<-"ID";dta2
## 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
2.A classmate of yours used data.entry() to change the first woman’s height to 50 in the women{datasets}. She then closed the editor and issued plot(women). To her surprise, she got this message:
Error in xy.coords(x, y, xlabel, ylabel, log) :
‘x’ is a list, but does not have components ‘x’ and ‘y’
Explain what had happened. How would you plot the edited data file?
class(dta <- women)
## [1] "data.frame"
data.entry(dta)
class(dta)
## [1] "list"
data.entry()會使資料類別從二維的“data.frame”轉為一維的“list”,所以無法畫X及Y象限的圖
4.Make a Google citations plot (for the last 5 years) of one of NCKU faculty members you know.
Huey-Jen Jenny Su
pacman::p_load(scholar)
dta <- get_citation_history('uv6_au4AAAAJ')
plot(dta, xlab = "Year", ylab = "Citations", type = "h",
lwd = 2, xlim = c(2014, 2018), ylim = c(0, 500))
grid()
