[Lign251] Problems with HW#2
Roger Levy
rlevy at ucsd.edu
Mon Oct 13 11:45:24 PDT 2008
Hi Simone,
Simone Hartung wrote:
> Hi Roger,
>
> I have trouble with the homework.
>
> First, is there a function in R which is able to sum the Counts for the
> different syllable numbers? or do I have to do several steps to obtain
> that?
Try using table() or xtabs(). Also, tapply() is incredibly useful...
> I tried to plot it this way, but I get an error.
>
> hist(brown1$Count, brown1$Nsyl)
> Error in hist.default(brown1$Count, brown1$Nsyl) :
> some 'x' not counted; maybe 'breaks' do not span range of 'x'
I'm not sure exactly what you are trying to do here -- you want to use
plot(), not hist(), to produce a scatterplot; try that?
>
> Then, I am not sure how to generate random variables. Is there a
> function in R to do that?
Take a look at the r*() functions. For example, rnorm() to sample from
a normal distribution, rbinom() to sample from a binomial, and so forth.
Hope this helps!
Roger
--
Roger Levy Email: rlevy at ling.ucsd.edu
Assistant Professor Phone: 858-534-7219
Department of Linguistics Fax: 858-534-4789
UC San Diego Web: http://ling.ucsd.edu/~rlevy
More information about the Lign251
mailing list