You can add additional dosing information to your R data frame by adding rows with the new dosing information using the rbind()
function.
For example, if you have a data frame called my_df
with the following columns:
patient_id | drug_name | dose
------------------------------
1 | Drug A | 100
2 | Drug B | 50
3 | Drug A | 200
And you want to add a new row with dosing information for patient 1:
patient_id | drug_name | dose
------------------------------
1 | Drug A | 100
2 | Drug B | 50
3 | Drug A | 200
1 | Drug A | 150
You can create a new data frame with the additional row using the following code:
new_row <- data.frame(patient_id = 1, drug_name = "Drug A", dose = 150)
new_df <- rbind(my_df, new_row)
The rbind()
function combines rows from two data frames, and in this case it is combining the my_df
data frame with the new row created in new_row
. The resulting data frame is assigned to a new variable called new_df
.
Asked: 2022-06-23 11:00:00 +0000
Seen: 8 times
Last updated: Feb 28 '23