Quantcast

Re :argument is not numeric or logical

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re :argument is not numeric or logical

mohan L
Hi all,

I have data size of :

> dim(sample)
[1] 35943    17

The first column is "stdate"  - is date  ( 01/11/2009 00:00:00,02/11/2009
00:00:00,02/11/2009 00:00:00 etc... )
Login is 13th column - is numbers (12,0,1 erc...)

The below operation return the following error.

> sample1 <- read.csv(file="sample1.csv",sep=",",header=TRUE)
> avglog <- with(sample1, tapply(Login, stdate, mean))

Warning messages:
1: In mean.default(X[[1L]], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(X[[2L]], ...) :
  argument is not numeric or logical: returning NA
3: In mean.default(X[[3L]], ...) :
  argument is not numeric or logical: returning NA
4: In mean.default(X[[4L]], ...) :
  argument is not numeric or logical: returning NA
5: In mean.default(X[[5L]], ...) :
  argument is not numeric or logical: returning NA
6: In mean.default(X[[6L]], ...) :
  argument is not numeric or logical: returning NA
7: In mean.default(X[[7L]], ...) :
  argument is not numeric or logical: returning NA


> 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
            NA             NA             NA             NA             NA

How to fix this issue?

Thanks & Rg
Mohan L

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

David Winsemius

On May 2, 2010, at 9:39 AM, Mohan L wrote:

> Hi all,
>
> I have data size of :
>
>> dim(sample)
> [1] 35943    17

Your code has a different name for the sample object. And it would be  
more informative if you offered str on "sample1".

--
David.

>
> The first column is "stdate"  - is date  ( 01/11/2009  
> 00:00:00,02/11/2009
> 00:00:00,02/11/2009 00:00:00 etc... )
> Login is 13th column - is numbers (12,0,1 erc...)
>
> The below operation return the following error.
>
>> sample1 <- read.csv(file="sample1.csv",sep=",",header=TRUE)
>> avglog <- with(sample1, tapply(Login, stdate, mean))
>
> Warning messages:
> 1: In mean.default(X[[1L]], ...) :
>  argument is not numeric or logical: returning NA
> 2: In mean.default(X[[2L]], ...) :
>  argument is not numeric or logical: returning NA
> 3: In mean.default(X[[3L]], ...) :
>  argument is not numeric or logical: returning NA
> 4: In mean.default(X[[4L]], ...) :
>  argument is not numeric or logical: returning NA
> 5: In mean.default(X[[5L]], ...) :
>  argument is not numeric or logical: returning NA
> 6: In mean.default(X[[6L]], ...) :
>  argument is not numeric or logical: returning NA
> 7: In mean.default(X[[7L]], ...) :
>  argument is not numeric or logical: returning NA
>
>
>> 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
>            NA             NA             NA              
> NA             NA
>
> How to fix this issue?
>
> Thanks & Rg
> Mohan L
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

mohan L
>
> Your code has a different name for the sample object. And it would be more
> informative if you offered str on "sample1".
>

This is the result of str on "sample1".
> str(sample1)
'data.frame':    35943 obs. of  17 variables:
 $ stdate     : Factor w/ 7 levels "01/11/09 00:00",..: 1 1 1 1 1 1 1 1 1 1
...
 $ domain     : Factor w/ 15 levels "Assamese","Bengali",..: 1 1 1 1 1 1 1 1
1 1 ...
 $ gender     : Factor w/ 2 levels "FeMale","Male": 1 1 1 1 1 1 1 1 2 2 ...
 $ postedby   : Factor w/ 10 levels "Brother","Daughter",..: 2 6 6 7 7 7 7 9
1 5 ...
 $ caste      : Factor w/ 424 levels "","Caste no bar",..: 1 171 189 130 182
214 394 32 394 373 ...
 $ age        : Factor w/ 15 levels "20","<20","21",..: 7 15 8 9 11 12 4 9 9
10 ...
 $ occupation : Factor w/ 54 levels "","Accounts/Finance Professional",..:
43 43 3 2 43 33 43 53 36 14 ...
 $ religion   : Factor w/ 17 levels "","Buddhist",..: 11 7 7 7 7 7 13 7 14
10 ...
 $ city       : Factor w/ 561 levels "","24 Parganas",..: 365 202 116 365
135 143 202 339 404 1 ...
 $ country    : Factor w/ 115 levels "Afghanistan",..: 47 47 47 47 47 47 47
47 47 11 ...
 $ education  : Factor w/ 12 levels "","Bachelors - Arts/ Science/ Commerce/
Others",..: 2 5 8 2 2 8 2 2 9 9 ...
 $ profiletype: Factor w/ 1 level "Free": 1 1 1 1 1 1 1 1 1 1 ...
 $ Login      : Factor w/ 419 levels ".00","1.00","10.00",..: 114 283 217
216 14 1 2 2 407 327 ...
 $ EISent     : Factor w/ 250 levels ".00","1.00","10.00",..: 1 132 23 132 2
1 1 1 1 2 ...
 $ EIReceived : num  12 5 43 0 8 2 11 12 4 0 ...
 $ PMSent     : Factor w/ 298 levels ".00","1.00","10.00",..: 1 1 1 1 1 1 1
1 1 1 ...
 $ PMReceived : num  8 4 61 1 12 8 0 9 1 0 ...


What I am trying is:  I have 7 days data in .csv format. I need to the
average Login for first day(1/11/2009) , from this average I have to
calculate index divisor(ID). Then I have to calculate the average Login for
all 7 days and need to multiple each day Login average with   index
divisor(ID), like this

stdate             LoginAverage       Index
1/11/2009          29.50                     LoginAverage*ID

This what I am trying? Any help will be appreciated

Thanks for your time.

Thanks & Rg
Mohan L

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

David Winsemius

On May 2, 2010, at 10:22 AM, Mohan L wrote:

>
>
>
>
> Your code has a different name for the sample object. And it would  
> be more informative if you offered str on "sample1".
>
> This is the result of str on "sample1".
> > str(sample1)
> 'data.frame':    35943 obs. of  17 variables:
>  $ stdate     : Factor w/ 7 levels "01/11/09 00:00",..: 1 1 1 1 1 1  
> 1 1 1 1 ...

So stdate is not a date variable but that is probably not your problem  
since it looks like the time portion of your not-dates are all  
"00:00". tapply can work with this information

>
snipped

>  $ Login      : Factor w/ 419 levels ".00","1.00","10.00",..: 114  
> 283 217 216 14 1 2 2 407 327 ...

So "Login" is not a numeric class variable. Read the FAQ about the  
proper way to convert that variable to numeric without loosing  
information.

--
David.


>  $ EISent     : Factor w/ 250 levels ".00","1.00","10.00",..: 1 132  
> 23 132 2 1 1 1 1 2 ...
>  $ EIReceived : num  12 5 43 0 8 2 11 12 4 0 ...
>  $ PMSent     : Factor w/ 298 levels ".00","1.00","10.00",..: 1 1 1  
> 1 1 1 1 1 1 1 ...
>  $ PMReceived : num  8 4 61 1 12 8 0 9 1 0 ...
>
>
> What I am trying is:  I have 7 days data in .csv format. I need to  
> the average Login for first day(1/11/2009) , from this average I  
> have to calculate index divisor(ID). Then I have to calculate the  
> average Login for all 7 days and need to multiple each day Login  
> average with   index divisor(ID), like this
>
> stdate             LoginAverage       Index
> 1/11/2009          29.50                     LoginAverage*ID
>
> This what I am trying? Any help will be appreciated
>
> Thanks for your time.
>
> Thanks & Rg
> Mohan L
>
>
>

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

mohan L
>> Your code has a different name for the sample object. And it would be more
>> informative if you offered str on "sample1".
>>
>> This is the result of str on "sample1".
>> > str(sample1)
>> 'data.frame':    35943 obs. of  17 variables:
>>  $ stdate     : Factor w/ 7 levels "01/11/09 00:00",..: 1 1 1 1 1 1 1 1 1
>> 1 ...
>>
>
> So stdate is not a date variable but that is probably not your problem
> since it looks like the time portion of your not-dates are all "00:00".
> tapply can work with this information
>
>
>>  snipped
>
>
>   $ Login      : Factor w/ 419 levels ".00","1.00","10.00",..: 114 283 217
>> 216 14 1 2 2 407 327 ...
>>
>
> So "Login" is not a numeric class variable. Read the FAQ about the proper
> way to convert that variable to numeric without loosing information.
>

The Login column contain all numeric values . I don't understand why I need
to convert that variable to numeric?

login column contain data like this :

> sample$Login

[35881] .00      1.00     .00      1.00     .00      .00      1.00
2.00
[35889] 1.00     3.00     .00      .00      .00      1.00     .00
32.00
[35897] 2.00     4.00     .00      17.00    3.00     1.00     12.00
.00
[35905] 8.00     .00      3.00     7.00     .00      17.00    .00
4.00
[35913] 16.00    4.00     20.00    7.00     .00      22.00    18.00
1.00
[35921] 3.00     3.00     .00      .00      37.00    3.00     12.00
3.00
[35929] 2.00     11.00    .00      5.00     77.00    1.00     4.00
1.00
[35937] 9.00     18.00    3.00     3.00     4.00     14.00    2.00

The mode of Login is numeric only :

> mode(sample$Login)
[1] "numeric"
>

 And I am also using as.numeric(as.character(sample$Login), still it has
some warning and NA . I don't understand why this is happening.  could you
explain?

> avglog <- with(sample1, tapply(as.numeric(as.character(sample$Login)),
stdate, mean))
Warning message:
In tapply(as.numeric(as.character(sample$Login)), stdate, mean) :
  NAs introduced by coercion
> 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
      22.04866       16.65358             NA       15.84970       16.58600
06/11/09 00:00 07/11/09 00:00
      16.20743       18.52379

Thanks & Rg
Mohan L

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

David Winsemius

On May 2, 2010, at 11:22 AM, Mohan L wrote:

>
>
>
>
> Your code has a different name for the sample object. And it would  
> be more informative if you offered str on "sample1".
>
> This is the result of str on "sample1".
> > str(sample1)
> 'data.frame':    35943 obs. of  17 variables:
>  $ stdate     : Factor w/ 7 levels "01/11/09 00:00",..: 1 1 1 1 1 1  
> 1 1 1 1 ...
>
> So stdate is not a date variable but that is probably not your  
> problem since it looks like the time portion of your not-dates are  
> all "00:00". tapply can work with this information
>
>
> snipped
>
>
>  $ Login      : Factor w/ 419 levels ".00","1.00","10.00",..: 114  
> 283 217 216 14 1 2 2 407 327 ...
>
> So "Login" is not a numeric class variable. Read the FAQ about the  
> proper way to convert that variable to numeric without loosing  
> information.
>
> The Login column contain all numeric values . I don't understand why  
> I need to convert that variable to numeric?

BECAUSE IT"S NOT NUMERIC.

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. Once you do so, location of the  
element causing the problem may become more clear, since then the non-
numeric coercible elements will get turned into "NA"'s or "NaN"'s.


>
> login column contain data like this :
>
> > sample$Login
>
> [35881] .00      1.00     .00      1.00     .00      .00      
> 1.00     2.00
> [35889] 1.00     3.00     .00      .00      .00      1.00     .
> 00      32.00
> [35897] 2.00     4.00     .00      17.00    3.00     1.00      
> 12.00    .00
> [35905] 8.00     .00      3.00     7.00     .00      17.00    .
> 00      4.00
> [35913] 16.00    4.00     20.00    7.00     .00      22.00    
> 18.00    1.00
> [35921] 3.00     3.00     .00      .00      37.00    3.00      
> 12.00    3.00
> [35929] 2.00     11.00    .00      5.00     77.00    1.00      
> 4.00     1.00
> [35937] 9.00     18.00    3.00     3.00     4.00     14.00    2.00

Factor variables can have labels that look like numbers.

>
> The mode of Login is numeric only :

So what?

 > mode(factor(c("a", "v", "c"))  )
[1] "numeric"

Modes are not the same as classes. Factors are represented internally  
as integers.


>
> > mode(sample$Login)
> [1] "numeric"
> >
>
>  And I am also using as.numeric(as.character(sample$Login), still it  
> has some warning and NA . I don't understand why this is happening.  
> could you explain?

I already did explain. You are bordering on magical thinking here.  
Since the class of sample$Login is "factor", your fervent desire to  
make it "numeric" will accomplish nothing useful.

--
David.

>
> > avglog <- with(sample1, tapply(as.numeric(as.character(sample
> $Login)), stdate, mean))
> Warning message:
> In tapply(as.numeric(as.character(sample$Login)), stdate, mean) :
>   NAs introduced by coercion
> > 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
>       22.04866       16.65358             NA       15.84970        
> 16.58600
> 06/11/09 00:00 07/11/09 00:00
>       16.20743       18.52379
>
> Thanks & Rg
> Mohan L
>

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

mohan L
>
> 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

> 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

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

David Winsemius

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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

mohan L
>
>> >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


Hi David,
Now I understand the trick :

as.numeric(as.character(Login))


> avglog <-
with(assame,tapply(as.numeric(as.character(Login)),stdate,mean))> > avglog
01/11/09 00:00 02/11/09 00:00 04/11/09 00:00 05/11/09 00:00 06/11/09 00:00
      22.04866       16.65358       15.84970       16.58600       16.20743
07/11/09 00:00
      18.52379

But still it will not work :

> avglog <-
with(assame,tapply(as.numeric(levels(Login)[as.integer(Login)]),stdate,mean))
Error in tapply(as.numeric(levels(Login)[as.integer(Login)]), stdate,  :
  arguments must have same length


Thanks & Rg
Mohan L

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

David Winsemius

On May 2, 2010, at 3:27 PM, Mohan L wrote:

>
>
> >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
>
> Hi David,
> Now I understand the trick :
>
> as.numeric(as.character(Login))
>
>
> > avglog <-  
> with(assame,tapply(as.numeric(as.character(Login)),stdate,mean))> >  
> avglog
> 01/11/09 00:00 02/11/09 00:00 04/11/09 00:00 05/11/09 00:00 06/11/09  
> 00:00
>       22.04866       16.65358       15.84970       16.58600        
> 16.20743
> 07/11/09 00:00
>       18.52379
>
> But still it will not work :
>
> > avglog <- with(assame,tapply(as.numeric(levels(Login)
> [as.integer(Login)]),stdate,mean))

Sometimes using with(. , .) does not work when the variable name is  
buried deep in a nested set of functions. Furthermore mean needs an  
na.rm argument if, as I suspect, you now have some some NA's in the  
new variable. What happens when you:

assame$Login.num <- as.numeric(as.character(assame$Login))
avglog <- with(assame,  tapply(Login2, stdate, mean, na.rm=TRUE) )
avglog


Untested of course since we STILL have no reproducible example. Had  
you used dput on head(sample, 40) or head(sample2, 40) or head(assame,  
40) we would not still be here guessing at what you really are working  
with.

--
David.

> Error in tapply(as.numeric(levels(Login)[as.integer(Login)]),  
> stdate,  :
>   arguments must have same length
>
>
> Thanks & Rg
> Mohan L
>
>
>
>

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re :argument is not numeric or logical

David Winsemius

On May 2, 2010, at 4:25 PM, David Winsemius wrote:

>
> On May 2, 2010, at 3:27 PM, Mohan L wrote:
>
>>
>>
>> >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
>>
>> Hi David,
>> Now I understand the trick :
>>
>> as.numeric(as.character(Login))
>>
>>
>> > avglog <-  
>> with(assame,tapply(as.numeric(as.character(Login)),stdate,mean))> >  
>> avglog
>> 01/11/09 00:00 02/11/09 00:00 04/11/09 00:00 05/11/09 00:00  
>> 06/11/09 00:00
>>      22.04866       16.65358       15.84970       16.58600        
>> 16.20743
>> 07/11/09 00:00
>>      18.52379
>>
>> But still it will not work :
>>
>> > avglog <- with(assame,tapply(as.numeric(levels(Login)
>> [as.integer(Login)]),stdate,mean))

>
> Sometimes using with(. , .) does not work when the variable name is  
> buried deep in a nested set of functions. Furthermore mean needs an  
> na.rm argument if, as I suspect, you now have some some NA's in the  
> new variable. What happens when you:
>
> assame$Login.num <- as.numeric(as.character(assame$Login))
> avglog <-
> avglog
>

Meant to type:

avglog <- with(assame,  tapply(Login.num, stdate, mean, na.rm=TRUE) )

>
> Untested of course since we STILL have no reproducible example. Had  
> you used dput on head(sample, 40) or head(sample2, 40) or  
> head(assame, 40) we would not still be here guessing at what you  
> really are working with.
>
> --
> David.
>
>> Error in tapply(as.numeric(levels(Login)[as.integer(Login)]),  
>> stdate,  :
>>  arguments must have same length
>>
>>
>> Thanks & Rg
>> Mohan L
>>
>>
>>
>>
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> [hidden email] 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Loading...