Re: [R] how to convert non numeric data into numeric?

From: Peter Alspach <PAlspach_at_hortresearch.co.nz>
Date: Tue, 22 Apr 2008 14:07:37 +1200

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.



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. Received on Tue 22 Apr 2008 - 02:23:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Apr 2008 - 02:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive