[R] Automatic rounding of values after factors , converted to numeric, are multipled by a real number

From: Nelson, Gary (FWE) <Gary.Nelson_at_state.ma.us>
Date: Thu 20 Oct 2005 - 06:16:29 EST


I am wondering if someone would have any suggestion about my issue?

I have the following code:

wgts<-aggregate(subset(lendata,select=c(Length)),list(lendata$Cruise,len

data$Station,lendata$Region,lendata$Total),mean)
wgts<-wgts[order(wgts$Group.3,wgts$Group.1,wgts$Group.1),]
names(wgts)<-c("Cruise","Station","Region","Total","MLen")
wgts$Total<-as.numeric(levels(wgts$Total))[wgts$Total] wgts$swmean<-with(wgts,wgts$Total*wgts$MLen)

When I run it, I get:

   Cruise Station Region Total     MLen swmean
3    2350     256      1     2 70.50000    141
5    2350     254      1     3 73.33333    220
6    2350     287      1     3 65.66667    197
9    2350     232      1     4 75.25000    301
10   2350     294      1     4 56.00000    224
12   2350     301      1     5 70.20000    351
14   2350     316      1     6 67.33333    404
15   2350     255      1     7 55.00000    385
17   2350     285      1     8 73.50000    588
19   2350     212      1    10 57.50000    575
20   2350     250      1    10 61.50000    615
27   2350     221      1    24 95.29167   2287
33   2350     229      1    35 55.62857   1947
37   2350     293      1    47 53.82979   2530
38   2350     203      1    50 55.54000   2777
39   2350     248      1    55 63.30909   3482
41   2350     246      1    63 95.82540   6037
42   2350     265      1    68 55.54412   3777
43   2350     251      1    82 62.60976   5134
44   2350     234      1    85 57.21176   4863

Every value is correct except that the "swmean"s are rounded and I can't get values with the decimals fractions. I have tried as.double and have change the options(digits=7), but nothing seems to work. I have spent several hours combing manuals and archives.

Any suggestions would be appreciated.



*

Gary A. Nelson
Massachusetts Division of Marine Fisheries 30 Emerson Avenue
Gloucester, MA 01930
Phone: (978) 282-0308 x114
Fax: (617) 727-3337
Email: Gary.Nelson@state.ma.us

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Oct 20 06:26:47 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:46 EST