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
.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-06-23 11:00:00 +0000
Seen: 8 times
Last updated: Feb 28 '23
What is the process for adding a Turbo Frame to `application.html.erb` in Turbo-Rails?
What is the process for identifying whether a frame is odd or even within an interlaced image?
What is the method to perform a function on several columns of a data frame simultaneously?
What is the process for converting a Pandas data frame into a category with a list of items?
In a pandas data frame, what is the method to transform a string into a specific date format?
How can a single-column be made from a pandas data frame that has n columns?