How do I create a new variable using multiple data frames in R

0 votes
I am trying to create a new variable by subtracting variable "A" from dataframe "data1" and variable "B" from dataframe "data2".

AB = data1$A - data2$B worked in that I created value AB and can run basic descriptive analyses on it. However, I want to save this value as a variable to data2.

I tried data2$AB = data1$A - data2$B but got the error below:

Error: Assigned data `MergeFinal.ScreenBaseline$pain_severity_score - MergeFinal.FU$pain_severity_score` must be compatible with existing data.
x Existing data has 99 rows.
x Assigned data has 49 rows.
ℹ Only vectors of size 1 are recycled.
Jan 17, 2022 in Data Analytics by anonymous

edited Mar 4 19 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP