[R] Re :argument is not numeric or logical

David Winsemius dwinsemius at comcast.net
Sun May 2 20:17:46 CEST 2010


On May 2, 2010, at 2:10 PM, Mohan L wrote:

>
>
> I have no way to determining  _why_ it is not numeric, but it simply  
> is ... not. Your input method turned it into a factor. Perhaps there  
> was one missing delimiter, or there was a stray character in one of  
> the entries in the file. Who knows. Why waste time arguing? Follow  
> the directions for fixing the problem.
>
> Hi David,
>
> Thanks for your time.
>
> I thinks it works  now.
>
> > str(assame$Login)
>  Factor w/ 419 levels ".00","1.00","10.00",..: 114 283 217 216 14 1  
> 2 2 407 327 ...
>
> > is.numeric(assame$Login)
> [1] FALSE
>
> >as.numeric(assame$Login)  //convert to numerics


NOOOOooooooo. You did not do what what I suggested earlier. Do not  
reach for your keyboard in the R console until you have read the FAQ  
section regarding converting factors to numeric. If you don't want to  
read the FAQ, but instead want to read the help page then type:

?factor            # and read slowly and carefully until you finish  
the page.

Those two sites of information are slightly different but both "work".  
I happen to think you should bring up the FAQ and read the rest of it  
as well.

>
> > str(as.numeric(assame$Login))
>  num [1:35943] 114 283 217 216 14 1 2 2 407 327 ...
>
> the I did some thing like this :
>
> > avglog <- with(assame, tapply(as.numeric(Login), stdate, mean) )
>
> > avglog
> 01/11/09 00:00 02/11/09 00:00 03/11/09 00:00 04/11/09 00:00 05/11/09  
> 00:00
>       145.0176       135.5207       133.0390       131.1457        
> 132.3732
> 06/11/09 00:00 07/11/09 00:00
>       129.6357       133.4521
>
> Am I right ?
>
>
>
> Thanks & Rg
> Mohan L
>
>
>
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list