Hi Chris,
how about this:
constant<-function(x) rep(7,length(x))
curve(constant,-1000,100)
cheers.
Am 07.03.2012 06:41, schrieb Chris Waggoner:> Is it possible to define a constant function (for example the zero
function) in R?
>
> I found the following unsatisfying hack to create the "seven
function":
>
> constant <- stepfun( x = -100:100, y = rep(7, 201) )
>
>
> This is mathematically unsatisfying because the domain is artificially
restricted to [-100,100] rather than (-Inf,Inf).
>
> Additionally, unless I use pch="n" there are ugly dots on the
plot (and again this feels hackish).
>
>
> Any suggestions on what else to do?
>
>
>
> Thanks in advance.
>
> ______________________________________________
> 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.
--
Eik Vettorazzi
Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf
Martinistr. 52
20246 Hamburg
T ++49/40/7410-58243
F ++49/40/7410-57790
--
Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und
Genossenschaftsregister sowie das Unternehmensregister (EHUG):
Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts;
Gerichtsstand: Hamburg
Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr.
Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus