[R] how to convert non numeric data into numeric?
Peter Alspach
PAlspach at hortresearch.co.nz
Tue Apr 22 04:07:37 CEST 2008
Kakul
lapply() returns a list - as stated in the help file (in general, the
help files and documentation provided with R are very good once one gets
used to them). Lists are, potentially, complex things and it makes no
sense to add them. Presumably in your case it does make sense to add
them - in which case you must first coerce them into another form, or
use a function other than lapply() in the first place. Which might be
the better option depends upon the nature of reqdIRR.
HTH .........
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of kakul modani
> Sent: Tuesday, 22 April 2008 1:41 p.m.
> To: r-help at r-project.org
> Subject: [R] how to convert non numeric data into numeric?
>
> I am having the following error in my function
>
> function(theta,reqdIRR)
> {
> theta1<-theta[1]
> theta2<-theta[2]
> n<-length(reqdIRR)
> constant<- n*(theta1+theta2)
> sum1<-lapply(reqdIRR*exp(theta1),FUN = sum)
> sum2<-lapply(exp(theta2 - reqdIRR*exp(theta1)),FUN = sum) sum
> = sum1 + sum2 log.fcn = constant - as.numeric(sum) result = - log.fcn
> return(result)
> }
>
> *error : neg.log.gumbel(1,reqdIRR)
> Error in sum1 + sum2 : non-numeric argument to binary operator
> >
>
> how can i rectify the error?Its really urgent...
>
> *
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
The contents of this e-mail are privileged and/or confidential to the named
recipient and are not to be used by any other person and/or organisation.
If you have received this e-mail in error, please notify the sender and delete
all material pertaining to this e-mail.
More information about the R-help
mailing list