本文主要是介绍R tutorial 13 - cbind 黏合,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*
使用cbind在表中添加数据。
*/userName <- c("Lam Wei Wei", "Zheng Da Shi", "Lin Da You", "Fei Gu Man", "Chen Kuang", "Wong wei yun")
salary <- c(8500, 9800, 12500, 15000, 8700, 7500)
jobPosition <- c("Staff", "Manger", "BOSS", "CEO", "Staff", "Staff")
bonus <- c(2300, 1350, 3285, 1035, 3285, 1035)MixInfo = c(userName, salary, jobPosition, bonus)
result <- matrix(MixInfo, nrow = 4, ncol = 6, byrow = TRUE)newUserName <- "Lam Ka Hai"
newSalary <- 15000
newJobPosition <- "CTO"
newBonus <- 3600
NewInfo = c(newUserName, newSalary, newJobPosition, newBonus)
NewMatr <- matrix(NewInfo, nrow = 4, ncol = 1, byrow = TRUE)NewResult <- cbind(result, NewMatr)
rownames(NewResult) <- c("userName", "salary", "jobPosition", "bonus")
NewResult
这篇关于R tutorial 13 - cbind 黏合的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!