To avoid this one creates a duplicate factor by assignment and then makes the changes to the new factor. The data frame remains unchanged. This includes functions created by R users like yourself. Data Frames Epidemiologists are familiar with data sets that come in the form of tables where each row is a record and each column is a field . A record can be data collected on individuals or groups.
Fields can contain numeric or character data.
In R, these types of data sets are handled by data frames. Each column of a data frame usually either a factor or numeric vector, although it can have complex, character, or logical vectors. Here are some examples. Note in the examples that the data.frame function is used to add new columns to a data frame. Indexing data frames is identical to indexing matrices.