a shorter example:

> n <- 4
> x <- data.frame(id=1:n, x1=sample(n), x2=sample(n), s1=1, s2=2, s3=3,
s4=4)
> require(reshape)
> z <- melt(x, id=1:3)  # first three columns are ids
> x
  id x1 x2 s1 s2 s3 s4
1  1  3  1  1  2  3  4
2  2  4  2  1  2  3  4
3  3  1  4  1  2  3  4
4  4  2  3  1  2  3  4
> z  # should be what you want
   id x1 x2 variable value
1   1  3  1       s1     1
2   2  4  2       s1     1
3   3  1  4       s1     1
4   4  2  3       s1     1
5   1  3  1       s2     2
6   2  4  2       s2     2
7   3  1  4       s2     2
8   4  2  3       s2     2
9   1  3  1       s3     3
10  2  4  2       s3     3
11  3  1  4       s3     3
12  4  2  3       s3     3
13  1  3  1       s4     4
14  2  4  2       s4     4
15  3  1  4       s4     4
16  4  2  3       s4     4
>


On Sun, May 31, 2009 at 2:06 PM, Christian Schmitt <
christian_...@hotmail.com> wrote:

>
> Hi,
>
>
>
> i have to reshape a dataset. my data have the following format:
>
>
>
> ID; x1; x2; x3; x4; v1; ... v20
>
> 1; 0.1; 0.3; 0.4; 0.2; 2; ... 3
>
> 2; 0.3; 0.7; 0.1; 0.2; 1; ... 4
> ...
> 999; 0.9; 0.6; 0.3; 0.1; 4; ... 2
> 1000; 0.2; 0.6; 0.7; 0.8; 1; ... 5
>
>
>
> ID is the number of persons (here 1000 persons)
>
> x are descriptive variables
>
> and v1-v20 are values of satisfaction on holidays for 20 days
>
>
>
> and now i should reshape the data such that each record contains only one
> participiant on one day
>
>
>
> could somebody help me? i don't know how to do this?!
>
>
>
> thank you
>
> _________________________________________________________________
> [[elided Hotmail spam]]
> [[elided Hotmail spam]]
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to