R - Adding vector from one dataframe as column to another dataframe
Here is a base R approach -
df$number <- df2$number[df2$application == "current"]
df$calculation <- with(df, area * yield * number)
df
Or if you prefer dplyr
-
library(dplyr)
df <- df %>%
bind_cols(df2 %>%
filter(application == "current") %>%
select(number)) %>%
mutate(calculation = area * yield * number)
df
# name area yield number calculation
#1 A 1 10 10 100
#2 B 2 20 10 400
#3 C 3 30 10 900
#4 D 4 40 10 1600
#5 E 5 50 10 2500