R studio syntex i.e. new to this program just begining

Could you tell me why the following command is a double vector? I'm not sure what I'm doing wrong.

TIA

filtered_tg <- filter(ToothGrowth, dose -- 0.5)
Error in `filter()`:
ℹ In argument: `dose - -0.5`.
Caused by error:
! `..1` must be a logical vector, not a double vector.
Run `rlang::last_trace()` to see where the error occurred.

I assume you have loaded the dplyr package. The problem is with your --, which is not an operator. R thinks you are using it to mean dose - (-0.5), or equivalently dose + 0.5, which is indeed a vector of doubles. I suspect you want to replace -- with a comparison operator, one of <, <=, ==, >= or >.

The issue is a typo: you've used -- (two minus signs) instead of == (equality comparison).

Try this:

filtered_tg <- filter(ToothGrowth, dose == 0.5)

filter() expects a logical condition (TRUE or FALSE), but dose -- 0.5 performs subtraction and returns numeric values (doubles).

Thank you it worked perfectly.

Thank you it was the perfect solution.