You'll get faster answers if you post code, rather than screenshots: see https://goo.gl/pWhBfY. A simplified data frame with contrived data and the same structure is all that's needed.
In the meantime, just on a hunch, put each snippet on a separate line, separated by blank lines, without the accompanied uncoded text. I can't see anything obviously wrong, but when I get this kind of problem, it helps me confirm that there's no syntax error, there is one, or some combination isn't playing well.