dear R users,
the data frame (read in from a csv) looks like this:
TreeTag Census Stage DBH
1 CW-W740 2001 juvenile 5.8
2 CW-W739 2001 juvenile 4.3
3 CW-W738 2001 juvenile 4.7
4 CW-W737 2001 juvenile 5.4
5 CW-W736 2001 juvenile 7.4
6 CW-W735 2001 juvenile 5.4
...
1501 1.00E-20 2001 adult 32.5
i would like to change values under the TreeTag column. as the last
value shows, some of the tags have decimals followed by 2 decimal
places. i just want whole numbers, i.e. not 1.00E-20, but 1E-20. i have
a rough understanding of regexp and grepped all the positions that have
the inappropriate tags. i tried sub() a couple of different ways, like
yr1bp$TreeTag[1501]<-sub("1.00", "1", yr1bp$TreeTag[1501])
and after turning yr1bp$TreeTag[1501] into <NA>,
yr1bp$TreeTag[1501]<-sub("", "1E-20", yr1pb$TreeTag[1501])
and
sub("", "1E-20", yr1bp$TreeTag[1501])
but it's not working. i guess it has something to do with the data.frame
characteristics i'm not aware of or don't understand. would i somehow
have to tear apart the columns, edit them, and then put it back
together? not that i know how to do that, but i'm wondering out loud.
john
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.