I am writing code to go through each row and if a certain parameter is met, that row will be put into a new table. My code is:
for(i in 1:nrow(mastercourseTable))
{
if(startsWith(mastercourseTable[i,3], "ACC") == TRUE)
{
accTable <- mastercourseTable[i,]
}
}
It works but will only put the last row that matches the if statement. When I change the action from putting the row into a table to other things like, print(mastercourseTable[i,] it will print each row but as soon as I want them in a table it will not work properly.