Reputation: 721
I am on Windows, using R 3.0.2 (2013-09-25) – Frisbee Sailing
I used package XLConnect
to import an Excel table into a df
called ConsolFLAT
.
The Excel table contains rows that are totals which I want to filter out.
Rows that are totals can be identified by a character "■" as the first character in the GLDESC
column, i.e. GLDESC
has a row with the value "■cash" which is a total line for all cash, I want to filter these out.
I was able to create a column TOTALS
in my data frame that just has the first character with:
ConsolFLAT$TOTALS<-(substring(ConsolFLAT$GLDESC,1,1)
I now want filter my dataframe for all rows for which this TOTALS
column is not equal to "■"
I can't find the character "■" in the ASCII list, but in Excel "code ("■") returns "63"
My problem is that I am unable to get R to identify this character, i.e. as.character ("■") returns:[1] "¦"
How do I set up in R a subset function against the character "■"?
Upvotes: 0
Views: 459
Reputation: 54247
ConsolFLAT[ConsolFLAT$TOTALS != intToUtf8(9632),]
or
grep(paste0("^", intToUtf8(9632)), ConsolFLAT$GLDESC, invert=T, value=T)
Upvotes: 1