I am having a data set with a mixed of positive and positive number.
Can I use table() command to give me an output of how many data that have negative values and how many have positive value?
I tried one and I have an error message.
> table(final_df$Gross_MarginDollars_Percentage(which[final_df$Gross_MarginDollars_Percentage < '0'],))
Error in table(final_df$Gross_MarginDollars_Percentage(which[final_df$Gross_MarginDollars_Percentage < :
attempt to apply non-function
which(final_df$Gross_MarginDollars_Percentage < 0) gives you the indexes of the values in final_df$Gross_MarginDollars_Percentage that are less than zero. (Note that you don't want to put 0 in quotes!)
To just get a table of counts for a logical condition as applied to a vector, try:
The answer for what happened: you used a parenthesis when you meant to use a bracket.
table(final_df$Gross_MarginDollars_Percentage( # here
final_df$Gross_MarginDollars_Percentage is (assumedly) a vector. Following it up with a parenthesis means it should be used as a function, but R notices it's not a function. Hence the error message
attempt to apply non-function
Errors and warnings can be cryptic, but they're also consistent. Now you'll know what this one means when it pops up again (and it will, for we are but humans who type with dumb fingers).