Hello,
I need some help with a database manipulation. This might seem trivial but I really haven't been able to handle it.
I have a database df that follows the below pattern. It happens that I need to breakdown the "marketing" value in df$team into three components "tv", "social_media" and "podcast" , as in df2.
I need to apply a share factor to the budget value, that is, to break down the marketing value into 3 shares. This shares are region specific.
I really appreciate any advise on this.
df <- data.frame(Region = rep(c("a","b","c","d","e"),2),
team = c(rep(c("wages","marketing"),5)),
budget = rnorm(10,100,1)
)
df2 <- data.frame(Region = c(rep("a",4), rep("d",4), rep("c",4), rep("d",4), rep("e",4)),
team = c(rep(c("wages","tv","social_med","podcast"),5)),
budget = c(rep(c(rnorm(1,100,1),
rnorm(3,33,3)))))
df2$budget <- jitter(df2$budget, factor = 1)
shares <- data.frame(
s_a= rnorm(3,33.3,2),
s_b= rnorm(3,33.3,3),
s_c= rnorm(3,33.3,1),
s_d= rnorm(3,33.3,0.5),
s_e= rnorm(3,33.3,2))