[R] hi, i have a problem in R
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Thu Aug 6 00:34:52 CEST 2009
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Gina Liao
> Sent: Wednesday, August 05, 2009 7:15 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] hi, i have a problem in R
>
>
> Hi, I'm new to R language.
>
> There is a problem I couldn't understand.
>
> Hope you can answer my question.
>
>
>
> when i type
>
>
>
> >for (i in 1:10){
>
> + print(sample(9,4,replace=T))
>
> +}
>
>
>
> and it shows ten of four numbers
>
> and how do I do to calculate the frequencies in each list?
>
>
>
> I know there is a hint; list10<-vector(mode="list",length=4)
>
>
>
> But I don't know how to use it.
>
> How do I name each list?
>
>
>
> There are my problems.
>
> Thanks!!
>
>
>
> Best Regards,
>
> vie
>
It is not clear to me what you are trying to calculate frequencies for. Are you trying to get 10 sets of 4 random digits, or 4 sets of ten random digits? What frequencies are you trying to calculate?
To generate 10 rows of 4 digits I would probably do something like
digits <- matrix(sample(9,40,replace=T), nrow=10)
Then you could get frequencies of digits by row or by column. But I am not sure what you want.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
More information about the R-help
mailing list