I am struggling to get the code right for this. Any insight or direction on how to get this to run?

Use dplyr verbs to select state, fy, funding_per_fte, tuition_per_fte and use a filter to select only rows for the six New England states from 1996 through 2019. Use %in% to select states. Assign the resulting data frame to an object named new_england.

This looks like a homework question.

Why don't you take a look at the documentation first:
A Grammar of Data Manipulation • dplyr (

it is, I have been working on it for awhile with my group and we were just seeking a bit of help to get on the right page

Every R problem can be thought of with advantage as the interaction of three objects— an existing object, x , a desired object,y , and a function, f, that will return a value of y given x as an argument. In other words, school algebra— f(x) = y. Any of the objects can be composites.

For this problem, we have an object, x, a data frame, and we want another data frame, y, that contains only a subset of columns and rows. The problem specifies the components of fselect, filter %in% and assign.

Thus, we have a(b(c(d(x)))) = f(x), and it's just a matter of the correct order. We can introduce another function, %>% the pipe operator, to avoid the plague of parentheses:

x %>% a(.) %>% b(.) %>% c(.) %>% d()

d is simply the assignment operator's right side version, ->.

This leaves the remaining functions, and it will be convenient to set up two subsidiary objects use by with %in%

NE <- c("Connecticut","Maine","Massachusetts","New Hampshire","Rhode Island","Vermont")
years <- 1996:2019

There remains only to choose the appropriate functions for a and b from among those identified in the question and decide the order.

1 Like

Thank you! This was really helpful.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.