emmeans: command emmeans() or contrast(), whats the difference? I hope somebody is available to help a desperate rookie..
I fitted a glmer with a Poisson distribution and log link, including main effects and several interactions, an offset variable and a random effect. Something like this:
model1 <- glmer(count ~ A + B + C + A*B + offset(log(X)) + ( 1 | D), data = workmap, family = poisson(link = "log"))
A, B and C are all factors with two levels.
My Prof generated "contrasts of marginal linear predictions" in Stata to, for example, look at the contrasts provided by A@B, or just simply A. I now want to do the same but in R by making use of the emmeans package.
First: should I use emmeans() or contrast() command? What is the difference?
I did the following: emm <- emmeans(model1, pairwise ~ A | B)
Was that the right thing to do or should I have used the contrast() command?

The emmeans package provides some flexibility in looking at different parts of the analysis, as well as some convenience functions. With this example, you could do:
EMM <- emmeans(model1, ~ A|B)
EMM          # show the estimated marginal means

PRS <- contrast(EMM, "pairwise")  # or PRS <- pairs(EMM)
PRS          # show the pairwise comparisons

The call you have, emmeans(model1, pairwise ~ A|B), does both of the above, and packages the results in a list. So in that sense, there is no difference.
That said, I strongly recommend doing the estimation of EMMs, and contrasts thereof, separately, because there may be more things you want to do with either part. For example,
# show on the original scale rather than the log scale:
confint(EMM, type = "response")

# show estimated Poisson rates:
confint(EMM, offset = 0)

# show pairwise comparisons as ratios on original scale:
summary(PRS, type = "response", infer = c(TRUE, TRUE))

Also, the fact that the emmeans(..., pairwise ~ ...) construct creates a list of emmGrid objects rather than a single emmGrid object causes confusion for some users.
By the way, since you have a mixed model, there is an additional issue that back-transformed estimates (with type = "response") are biased. To correct for bias, you need an estimate of the SD of the random effect, which you can get from VarCorr(model1). Then you can do confint(EMM, type = "response", bias.adj = TRUE, sigma = <your SD estimate>). It's important to specify sigma because the default value is incorrect for these models.
