| data_push | R Documentation |
Shorthand to add data to a dataset and save as the same name
data_push(., add, which = c("rows", "cols"))
. |
first data set |
add |
data set to add |
which |
where to append the new data e.g. rows or cols |
the combined dataset store to a variable with the name of the first
# initialize p1 and p2 init(p1,p2) p1 p2 # declare p1 and p2 as data frame p1 <- data.frame(PK=1:10,ID2=1:10) p2 <- data.frame(PK=11:20,ID2=21:30) p1 p2 #add p1 to p2 by row, and resave as p1 data_push(p1,p2,"rows") # p2 # p2 remains the same p1 #p1 has been updated # declare a new data frame called p3 p3 <- data.frame(Hindex=number(20),Rindex=number(20,seed=20)) # add p3 to p1 as column, and resave as p1 data_push(p1,p3,"cols") p1 # p1 has been updated