Skip to content
Prev 171343 / 398503 Next

Filtering a data frame using a string for colum header

Hi all,

I was just radomly playing with R and got the following error when
trying to filter a data frame using a string:
DrHorrible
1         10
2          9
3          9
4         10
5         10
Error in -"DrHorrible" : invalid argument to unary operator
I know how to work around this problem quite easily, I'm just curious
as to why the my.df[-"DrHorrible] statement didn't work?

Cheers,
Tony

OS = win XP
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.
1252;LC_MONETARY=English_United Kingdom.
1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods
base