Re: [R] editing a data.frame

2008-06-09 Thread john.polo
that did the trick. thanks a lot! john jim holtman wrote: Actually change the TreeTag to characters first because you are trying to store in a new factor value that is not there yr1bp$TreeTag <- as.character(yr1bp$TreeTag) yr1bp$TreeTag[1501]<-sub("1.00", "1", yr1bp$TreeTag[1501]) # change b

Re: [R] editing a data.frame

2008-06-07 Thread jim holtman
Actually change the TreeTag to characters first because you are trying to store in a new factor value that is not there yr1bp$TreeTag <- as.character(yr1bp$TreeTag) yr1bp$TreeTag[1501]<-sub("1.00", "1", yr1bp$TreeTag[1501]) # change back to a factor if desired yr1bp$TreeTag <- factor(yr1bp$TreeTa

Re: [R] editing a data.frame

2008-06-07 Thread jim holtman
try: yr1bp$TreeTag[1501]<-sub("1.00", "1", as.character(yr1bp$TreeTag[1501])) Since it appears that TreeTag is a factor. This can be verified with 'str'. On Fri, Jun 6, 2008 at 11:22 PM, john.polo <[EMAIL PROTECTED]> wrote: > Daniel Folkinshteyn wrote: > >> works for me: >> > sub('1.00', '1',

Re: [R] editing a data.frame

2008-06-06 Thread john.polo
Daniel Folkinshteyn wrote: works for me: > sub('1.00', '1', '1.00E-20') [1] "1E-20" when i input what you wrote, i get the same result. but that doesn't change the value for TreeTag at row 1501, it's just floating around in space. if i try it for yr1bp$TreeTag[1501], which is 1.00E-20 i get thi

Re: [R] editing a data.frame

2008-06-06 Thread Daniel Folkinshteyn
works for me: > sub('1.00', '1', '1.00E-20') [1] "1E-20" remember, according to ?sub, it's sub(pattern, repl, string) try doing it step by step. first, see what yr1bp$TreeTag[1501] is. then, if it's the right data item, see what the output of sub("1.00", "1", yr1bp$TreeTag[1501]) is. that'll l

[R] editing a data.frame

2008-06-06 Thread john.polo
dear R users, the data frame (read in from a csv) looks like this: TreeTag CensusStage 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