You can use the bind_rows()
function from dplyr
package to bind the original data with a duplicated copy of itself. Then, use the mutate()
function to add a suffix to a column indicating the original and duplicated copies. Here's an example:
main.r459 chars19 lines
In this example, each row was duplicated and a suffix was added to the Suffix
column to indicate whether it is the original or duplicated copy of the data. The ifelse()
statement checks the current row number against the number of rows in the original data frame to add the appropriate suffix.
gistlibby LogSnag