I am trying to create a subset using only the Provider's Yellow Cab of DC and Hitch. I also want to keep the variables Provider, Payment Provider, Trip Time, Mileage, and Total Cost.
variables are retained.
My code and the error:
subset(Provider, subset (Yellow Cab of DC, Hitch), select (Provider, PaymentType, TripTime, Mileage, TotalCosts))
Error: unexpected symbol in "subset(Provider, subset (Yellow Cab"
To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
The issue is that subset function has two parameters. Subset and Select. These parameters if named should be followed by equals = symbol, and then the thing that they should equal. Following them with brackets rather than equals is a syntax error
And just as an example of this and of a reproducible example, see below.
Note the first argument in the subset function is the data.frame. The second arguement is for how you'd like to subset that data.frame. And the third argument lets you select specific columns to keep (leave it blank to select all).
ex_df <- data.frame(
c1 = c(1,2,3,4,5),
c2 = c("a", "b","c","d","e")
)
subset(ex_df, c1 < 4, select = c(c2))
#> c2
#> 1 a
#> 2 b
#> 3 c
I want it to only consist of trips provided by Yellow Cab of DC and Hitch but also retain the variables Provider, PaymentProvider, TripTime, Mileage, and TotalCost
Ok . I understand the concept. But not your data...
Do you have a variable and does the variable have possible values?
If you as a person tried to find the relevant roles you would look at column... For exact values of....
as a general rule, pictures are a bad way to share information about data or code, and for best engagement with the community here, I strongly recommend taking the time to read through the suggested link [Subset Error Help]
However, because you are new, and need some time to absorb those recommendations, I'll help you out.