新增欄位(Add Column)
prodinfor #檢視新增前的DataFrame
prodinfor$count <- c(2,7,3,10,33) #新增count 欄位
prodinfor #檢視新增後的DataFrame
新增資料(Insert Record)
Months <- c("August")
ProductRevenue <- c(700)
count <- c(50)
Prodinfor2 <- data.frame(Months, ProductRevenue, count)
prodinforAll <- rbind(prodinfor, Prodinfor2)
prodinforAll
修改資料(Update Record)
prodinfor$ProductRevenue[1] <- 50
prodinfor
DataFrame合併(類似SQL的Join)
Months <- c("Mar","Apr","May","Jun","Jul","August")
IntMonths <- c("3","4","5","6","7","8")
dfMonth <- data.frame(Months, IntMonths)
prodinforMerge <- merge(prodinfor, dfMonth, by = "Months")
prodinforMerge
刪除Column(Drop Column)
prodinforMerge$IntMonths = NULL
prodinforMerge
刪除Record(Delete Record)
prodinforMerge <- prodinforMerge[-1, , ]
prodinforMerge
沒有留言:
張貼留言