Dear S+ users,
Hopefully this is a simple question.
I have a problem creating a factor from continous data. Here the
lowest possible value for the factor I want to create, and later
plot, is not realized in the continous variable. Creating a
factor with all possible levels results in a factor with the
lowest occuring value in the continous variable being the lowest
factor level. However, I want this to be the second lowest level.
The variable containing the continous data has the following values and
frequencies:
> table(rep$ALTER1)
2 3 4 5 6
2 32 17 16 10
Although possible values are 1 to 7, which do not appear in the current
data-set.
Operating with the cut and ordered functions, I get the following factor
and frequencies:
> x <-
ordered(cut(rep$ALTER1,breaks=c(1,2,3,4,5,6,7)),levels=c("1","2","3","4","5","6","7"))
> table(x)
1 2 3 4 5 6 7
2 32 17 16 10 0 0
Obviously cut does the reasonable thing and assigns the lowest
occuring value in the data-set to the lowest factor level.
However, my table for the data should look like this:
1 2 3 4 5 6 7
0 2 32 17 16 10 0
How do I do this trick?
Thanks for any ideas and comments.
wolfgang
*********************************************
Wolfgang Hannoever
Forschungsstelle fuer Psychotherapie
Christian-Belser-Str. 79a
70597 Stuttgart
Tel.: 0711 / 6781-407 Fax:0711 / 6876902
e-mail:hann@psyres-stuttgart.de
*********************************************
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|