Thanks! ;) Just wanted to make sure u didn't want us to write a more generic function
that allows for different ranges of months as input......
________________________________
From: gov2001-l-bounces at
lists.fas.harvard.edu [gov2001-l-bounces at
lists.fas.harvard.edu] On Behalf Of Patrick Lam [plam at
fas.harvard.edu]
Sent: Tuesday, February 17, 2009 8:30 PM
To: gov2001-l at
lists.fas.harvard.edu
Subject: Re: [gov2001-l] Question regarding 3)
birthdays can occur in any month.
On Tue, Feb 17, 2009 at 8:23 PM, Patnaik, Sanjay <spatnaik at
hbs.edu<mailto:spatnaik at hbs.edu>> wrote:
Hi all,
When it is asked in question 3 of the problem set that the function should have the months
I am sampling from as inputs, can I assume that this will be the whole range of months
(from 1 to 12) or any range of months? (like for example May, June, July , so that my
input for months would be c(5,6,7)).
I am writing my function under the assumption that we sample from all available months and
not only a specific range, but I wanted to make sure that is is the correct assumption.
Thanks,
Sanjay
________________________________
From: gov2001-l-bounces at lists.fas.harvard.edu<mailto:gov2001-l-bounces at
lists.fas.harvard.edu> [gov2001-l-bounces at
lists.fas.harvard.edu<mailto:gov2001-l-bounces at lists.fas.harvard.edu>] On Behalf
Of Patrick Lam [plam at fas.harvard.edu<mailto:plam at fas.harvard.edu>]
Sent: Monday, February 16, 2009 10:06 PM
To: gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
Subject: Re: [gov2001-l] R command for tabulating frequency
I'm not aware of a mode function, although it doesn't mean it doesn't
exist.
good catch on the second point. you're absolutely right! for the purposes of this
problem though, ignore the fact that such an issue exists.
On Mon, Feb 16, 2009 at 8:35 PM, Lai, Ronald <rolai at hbs.edu<mailto:rolai at
hbs.edu>> wrote:
Is there simply a "Mode" function in R?
For 4d.
What is the range? Initially, I thought it would be 0 -> Inf
Since ln(0) = error and ln(Inf) = Inf.. this seems like an issue!
From: gov2001-l-bounces at lists.fas.harvard.edu<mailto:gov2001-l-bounces at
lists.fas.harvard.edu> [mailto:gov2001-l-bounces at
lists.fas.harvard.edu<mailto:gov2001-l-bounces at lists.fas.harvard.edu>] On Behalf
Of Johnathan Boysielal
Sent: Monday, February 16, 2009 8:31 PM
To: gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
Subject: Re: [gov2001-l] R command for tabulating frequency
If you have a vector like n <- c(1, 2, 3, 4, 1, 2, 3, 2, 1, 2)
q <- table(n);q # will generate a frequency table
n
1 2 3 4
3 4 2 1
You can also apply operations like max() or mean() to q, and use it to subset the original
vector. E.g.:
unique(n[q>2]) #will list all the elements of n appearing more than 2 times
[1] 1 2
Hope that helps,
John
On Mon, Feb 16, 2009 at 6:39 PM, Rachel West <rwest817 at gmail.com<mailto:rwest817
at gmail.com>> wrote:
Very elementary question, I'm sure, but I'm new to R :
What is a command in R which would return the frequency elements in a vector, and could be
applied with "any" to recognize when a threshold frequency has been achieved?
For example, if I have a vector
n <- [1, 2, 3, 4, 1, 2, 3, 2, 1, 2],
is there a command that will output the number of instances of the most frequent element
(i.e, "2" is repeated 4 times), or something similarly useful?
Thanks,
Rachel
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science, Harvard
University
http://www.people.fas.harvard.edu/~plam
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science, Harvard
University
http://www.people.fas.harvard.edu/~plam