Filter from a dataframe and create another dataframe

dplyr

#1

I have two data frames as following:

df <- data.frame(month = c("mazda", "yamaha"),
                 april = c(11,12),
                 may = c(14,15)) 

df_whole <- data.frame(month = c("car", "bikes"),
                 april = c(.1,.2),
                 may = c(.5,.2)) 

What I want to do is create a row called total_car which would be a product of car and mazda. However if df_whole doesnt have row car I would still like to create a row total_car which would mazda*0.The output I want to get to is as below. How could I calculate something like this in R

df_car <- data.frame(month = c("mazda", "yamaha","total"),
                 april = c(11,12,1.1),
                 may = c(14,15,7))

#2

Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.packages("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ.