데이터 프레임에 행을 추가하려면 rbind() 함수를 사용하여 새로운 레코드를 추가한다.
> rbind(persons, data.frame(Name = "John", Gender = "Male", Age = 25, Major = "Statistics"))
Name Gender Age Major
1 Ken Male 24 Finance
2 Ashley Female 25 Statistics
3 Jennifer Female 23 Computer Science
4 John Male 25 Statistics
여기에 사람마다 등록은 했는지(Registered), 프로젝트 개수는 몇 개인지(Projects)를 나타내는 새로운 행을 추가하고 싶다면 cbind() 함수를 사용한다.
> cbind(persons, Registered = c(TRUE, TRUE, FALSE), Projects = c(3, 2, 3))
Name Gender Age Major Registered Projects
1 Ken Male 24 Finance TRUE 3
2 Ashley Female 25 Statistics TRUE 2
3 Jennifer Female 23 Computer Science FALSE 3
여기서 rbind()와 cbind() 함수를 사용하면, 원래 데이터는 바뀌지 않고 주어진 행과 열이 추가된 새로운 데이터 프레임을 만든다는 점을 기억하자.