On Sep 12, 2010, at 10:45 AM, Natasha Asar wrote:

Greeting R helpers J
I am not familiar with R but I have to use it to analyze data set that I have
(30,000 20,000)
I want to change the structure of the dataset and I am wondering how that might
be possible in R
A main data looks like this:  some entities are empty
Age        No.         Age        No.         Age        No.
Center1     5              2              8           7

Center2      10           7              20
9              4              10
But what I want the data to look like is
Age                        1              2              3
4              5              6              7              8
9              10 …       20
Center1
2                                              7
Center2
10
 7              9

It should read the entities one by one
when j is in age column take its value and consider it as the column number for
new matrix
then go to next entity (j No. columns) and put that entity under the columns
number identified in previous step.
In other word
it should get the each element in No. columns (one by one) and place them in a new matrix under the column number which are equal to entity of age columns of
first matrix
i have tired ncol, and cbind and things like that but I guess im on the wrong path because it is not working. I am reading this fine with read.csv and
writing back the same way.
do you know how I can make this work?? Is it even possible to do something like
this?
Thank you in advance
Natasha



        [[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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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