Hi everyone,
I am really beginner in R and it is my first day in this community.
I need help to understand how I can define the command to run a linear regression only in specific lines.
For instance, I have a database with several lines and columns: “country” (1, 2, 3, and 4), “year” (1, 2, 3, 4, 5, 6), “period” (1, 2, 3), “advertising ”, and “sales”.
How can I run linear regression between “advertising” and “sales” but using data only there are country 2, year 3, and period 2?
How can I fit that situation in the command for the model below ?
mod <- lm(sales ~ advertising, data)
summary (mod)
The same situation to run a descriptive analysis (mean, min, max, ...) of sales when, for example, it’s county 1 and period 3.
Basically, I would like to create conditions to run analysis only in specific lines based on different columns.
I don’t know if I explained clearly.
Thank you,