[R] Seeming failure of options(width=60)

Yihui Xie xie at yihui.name
Mon Mar 26 04:41:58 CEST 2012


I got an error message:

> options(width=60)
> pastured <- data.frame(
+ time=c(9, 14, 21, 28, 42, 57, 63, 70, 79),
+ yield= c(8.93, 10.8, 18.59, 22.33, 39.35,
+         56.11, 61.73, 64.62, 67.08))
> regmod<-"yield ~ t1 - t2*exp(-exp(t3+t4*log(time)))"
> huetstart<-c(t1=70, t2=60, t3=0, t4=1)
> anlsx<-try(nls(regmod, start=huetstart, trace=TRUE, data=pastured))
13386.91 :  70 60  0  1
Error in nls(regmod, start = huetstart, trace = TRUE, data = pastured) :
  singular gradient
> print(anlsx)
[1] "Error in nls(regmod, start = huetstart, trace = TRUE, data =
pastured) : \n  singular gradient\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in nls(regmod, start = huetstart, trace = TRUE, data =
pastured): singular gradient>


and I see the number of characters of the message string is 94:

> nchar(anlsx)
[1] 94

options(width) is not supposed to _wrap_ your character scalars; it
cannot break a single string into several lines (use strwrap() instead
in that case). See ?options for the exact meaning of the width option.

# this may help you understand 'width'
options(width = 50)
rep(1, 100)

options(width = 90)
rep(1, 100)


Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Sun, Mar 25, 2012 at 9:17 PM, John C Nash <nashjc at uottawa.ca> wrote:
> The following example gives output with a line length of 103 on my system. It is causing a
> nuisance in creating a vignette. Is there something other than e.g., options(width=60) I
> need to set? The Sweave FAQ suggests this should work.
>
> options(width=60)
> pastured <- data.frame(
> time=c(9, 14, 21, 28, 42, 57, 63, 70, 79),
> yield= c(8.93, 10.8, 18.59, 22.33, 39.35,
>         56.11, 61.73, 64.62, 67.08))
> regmod<-"yield ~ t1 - t2*exp(-exp(t3+t4*log(time)))"
> huetstart<-c(t1=70, t2=60, t3=0, t4=1)
> anlsx<-try(nls(regmod, start=huetstart, trace=TRUE, data=pastured))
> print(anlsx)
>
>
> John Nash
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list