# [R] Help Transforming sums into observations

Sarah Goslee sarah.goslee at gmail.com
Wed Dec 21 00:14:15 CET 2011

```> 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 <kbrownk 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 Goslee
http://www.functionaldiversity.org

```