Skip to main content

4.5) Useful Functions For Data Frames


edit()

An interactive function, this brings up a spreadsheet window in which you can edit any values of a data frame that need changing. Be sure to store the result (e.g. GRASS.new <- edit(GRASS) ), otherwise it will just be printed on the screen for you!
stack() This takes the columns of a data frame or list and stacks them into a single vector, with another vector to show which columns they came from. The output is a two-column data frame.
split() This splits a vector or data frame into groups according to the values in the vector supplied to the argument f=. The output is a list, with a separate element for each group. If you want a dataframe output, try unstack() instead.
subset() Instead of using square brackets to select rows and columns, you can use subset() with three arguments: the name of the data frame, then a logical condition to specify rows, then the names of the columns you want (as a vector if there are more than one).