Re: [R] Histograms with strings,

From: jim holtman <jholtman_at_gmail.com>
Date: Thu, 17 Mar 2011 22:06:26 -0400

names(which.max(table(x)))

This is a 'named' vector

On Thu, Mar 17, 2011 at 8:58 PM, Khanvilkar, Shashank <skhanvil_at_qualcomm.com> wrote:
> Thanks
>
>> which.max(table(x))
> 129.46.71.19
>          10
>
> How do I get only "129.46.71.19" back as a str...
>
>
> -----Original Message-----
> From: jim holtman [mailto:jholtman@gmail.com]
> Sent: Thursday, March 17, 2011 4:39 PM
> To: Khanvilkar, Shashank
> Cc: r-help
> Subject: Re: [R] Histograms with strings,
>
> try this:
>
>> x
>  [1] "74.125.224.38" "74.125.224.38" "129.46.71.19"  "129.46.71.19"
> "129.46.71.19"  "129.46.71.19"
>  [7] "129.46.71.19"  "129.46.71.19"  "129.46.71.19"  "129.46.71.19"
> "129.46.71.19"  "129.46.71.19"
>> table(x)
> x
>  129.46.71.19 74.125.224.38
>           10             2
>> which.max(table(x))
> 129.46.71.19
>           1
>
>
> On Thu, Mar 17, 2011 at 6:06 PM, Khanvilkar, Shashank
> <skhanvil_at_qualcomm.com> wrote:
>> Hello,
>> Thanks in advance for any help,
>>
>> I have read a CSV file in which there is a column for an IP addr as in:
>>
>> tmpInFile$V2
>>  [1] "74.125.224.38" "74.125.224.38" "129.46.71.19"  "129.46.71.19"
>>  [5] "129.46.71.19"  "129.46.71.19"  "129.46.71.19"  "129.46.71.19"
>>  [9] "129.46.71.19"  "129.46.71.19"  "129.46.71.19"  "129.46.71.19"
>>
>> If I want to find the IP addr that has the highest occurrence (129.46.71.19, in this case), is there a simple way to do this?
>>
>> Thanks

>> Shank

>>
>>        [[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.
>>
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>

-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

______________________________________________
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 Fri 18 Mar 2011 - 02:16:41 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 Fri 18 Mar 2011 - 02:30:22 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