assuming the structure is as I have it you could try
library(tidyverse)
#example data but use your own in place of this df
(df<- tribble(~"Stores",~"Financial",~"2010",~"2011",
"store1","income","654","456",
"store1","expenses","321","234",
"store2","income","999","789",
"store2","expenses","789","565"))
(dfl<-pivot_longer(df,
cols = starts_with("2"),
names_to = "year",
values_to="amount") %>% mutate(amount=as.numeric(amount)))
(df2 <- pivot_wider(dfl,
id_cols=c(Stores,year),
names_from = Financial,
values_from = amount) %>% mutate(
profit = income-expenses
))
# the best profit store from every year
group_by(df2,
year) %>%
top_n(n=1,wt=profit)
# the best year store for each store
group_by(df2,
Stores) %>%
top_n(n=1,wt=profit)