[R] Help Transforming sums into observations

kbrownk kbrownk at gmail.com
Wed Dec 21 00:52:11 CET 2011


Thanks for the heads up. I don't have a #. My data is as you suggest.
I tried to generalize my example because I'm open to reformatting for
the solution to my problem.

Thanks,
kbrownk

On Dec 20, 6:14 pm, Sarah Goslee <sarah.gos... at gmail.com> wrote:
> > bindata <- 1:5
> > nobs <- c(2, 3, 1, 4, 3)
> > rep(bindata, times=nobs)
>
>  [1] 1 1 2 2 2 3 4 4 4 4 5 5 5
>
> for the R part, and see below:
>
> Sarah
>
> On Tue, Dec 20, 2011 at 5:45 PM, kbrownk <kbro... at gmail.com> wrote:
> > I need to measure kurtosis, skew, and maybe dip test on some
> > distributions I have. Currently my data is in the form of 2 vectors x
> > and y. Where x is 10 bins and y is the number of observations found in
> > that bin. It seems that the measures I want to run require the actual
> > observations laid out rather than already summed like I have them. Any
> > suggestions on how to transform the data automatically? I have a semi-
> > automated method in Excel but I think r will do a better job. I
> > provide a more specific example below:
>
> > My csv file with the data looks like this:
> > Bin: 1,2,3, ... ,10     #Observations:  23,42,1,...  56
>
> Really? By default R will treat everything after the # as a comment, so
> you'll need to watch out for the comment character option when you
> import it.
>
> You're also trying to use two or maybe three separate delimiters, which
> R can't easily handle. Why not use a proper CSV file with Comma Separated
> Values?
>
> > I need this transformed into a single vector like this:
> > c(1,1,1,1...2,2,2,2...3,...10,10,10,10...) The vector would have 23
> > "1"s, 42 "2s", 1 "3", etc.
>
> > I actually have 68 of these vectors laid out in rows that I will
> > measure separately, so my csv file actually looks like this:
> > Bin: 1,2,3, ... ,10     #Observations:  23,42,1,... 56
> > Bin: 1,2,3, ... ,10     #Observations:  13,33,32,...98
> > .
> > .
> > .
> > Bin: 1,2,3, ... ,10     #Observations:  11,76,55,...46
>
> > I want to automate the process.
>
> --
> Sarah Gosleehttp://www.functionaldiversity.org
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list