[R] strange error message
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Jul 1 19:22:40 CEST 2003
Michael
1) Those are not errors, but warnings. You need to use warnings() (with
the brackets) to see what they were. By typing warnings (without the
brackets) you are asking R to print out the source code for the
warnings() function.
2) try ?options and see option digits in that help file
Hope that helps a bit,
Gavin
Michael Rennie wrote:
> Hi, there
>
> I have a loop that is producing data, but is also generating an error message
> that I can't understand.
>
> Here's the loop and the error message:
>
>
>>bio<-matrix(NA, ncol=9, nrow=366)
>>W<-NULL
>>M<- length(Day) #number of days iterated
>>
>>for (i in 1:M)
>
> + {
> +
> +
> + if (Day[i]==1) W[i] <- Wo else W[i] <- (W[i-1]+(Gr[i]/Ef))
> +
> +
> + C<- p*CA*(W^CB)*(((comp[,3])^Xc)*(exp(Xc*(1-(comp[,3])))))*Pc
> +
> + ASMR<- ACT*RA*(W^RB)*(((comp[,4])^Xa)*(exp(Xa*(1-(comp[,4])))))
> +
> + SMR<- (ASMR/ACT)
> +
> + A<- (ASMR-SMR)
> +
> + F<- (FA*((comp[,2])^FB)*(exp(FG*p))*C)
> +
> + U<- (UA*((comp[,2])^UB)*(exp(UG*p))*(C-F))
> +
> + SDA<- (S*(C-F))
> +
> + Gr<- (C-(ASMR+F+U+SDA))
> +
> + bio<- cbind(W, C, ASMR, SMR, A, F, U, SDA, Gr)
> +
> + }
> There were 50 or more warnings (use warnings() to see the first 50)
>
>>warnings
>
> function (...)
> {
> if (!(n <- length(last.warning)))
> return()
> names <- names(last.warning)
> cat("Warning message", if (n > 1)
> "s", ":\n", sep = "")
> for (i in 1:n) {
> out <- if (n == 1)
> names[i]
> else paste(i, ": ", names[i], sep = "")
> if (length(last.warning[[i]])) {
> temp <- deparse(last.warning[[i]])
> out <- paste(out, "in:", temp[1], if (length(temp) >
> 1)
> " ...")
> }
> cat(out, ..., fill = TRUE)
> }
> }
>
>>dimnames (bio) <-list(NULL, c
>
> ("W", "C", "ASMR", "SMR", "A", "F", "U", "SDA", "Gr"))
>
>>
>>bio
>
> W C ASMR SMR A F U
> [1,] 9.200000 233.6647 107.5640 64.50050 43.06345 31.93755 15.840142
>
>
> Also, does anyone know why I might be getting differences in the same
> calculation between R and Excel? Is there any way to keep R from rounding your
> numbers, or to specify the # of decimal places you want for an element?
>
>
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpson at ucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list