[R] trimming a factor
Dan Chan
dchan at GFC.STATE.GA.US
Fri Mar 10 21:52:03 CET 2006
Hi,
I have the following dataframe. The County Column has many empty spaces
at the end.
I want to cut out the empty space and put them back into the dataframe.
How can this be done?
> head(DailyCounty)
Date County GFCPer GFCEquip Acre nFires
Date2
1 2001-01-04 00:00:00 Appling 1 1 0.20 1
2001-01-04
2 2001-01-05 00:00:00 Appling 2 2 0.13 1
2001-01-05
3 2001-01-06 00:00:00 Appling 1 1 3.41 1
2001-01-06
4 2001-01-07 00:00:00 Appling 1 1 0.18 1
2001-01-07
5 2001-01-10 00:00:00 Appling 1 1 5.10 1
2001-01-10
6 2001-01-16 00:00:00 Appling 1 1 0.48 1
2001-01-16
>sub(' +$','',levels(DailyCounty$County))
"Appling"
>sub(' +$','',DailyCounty$County)
[1] "1"
Thank you!
Daniel Chan
Meteorologist
Georgia Forestry Commission
P O Box 819
Macon, GA
31202
Tel: 478-751-3508
Fax: 478-751-3465
More information about the R-help
mailing list