[R] Extracting portions of one vector to create others
Paul Zachos
p@z @end|ng |rom @c@@e@org
Mon Sep 1 16:09:56 CEST 2025
Dear Colleagues,
I have a vector which indicates membership of subjects in one of 5 Classes
Beth$CLASS
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
[37] 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 7 7 7 7 7 7 7 7 7 7
[73] 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 1
For purposes of an analysis (using linear models based on Ward and Jennings) I would like to create 5 new vectors
The values in vector CLASS1 will be ‘1’ if the corresponding value in Beth$CLASS is equal to ‘1’; ‘0’ otherwise
The values in vector CLASS2 will be ‘1’ if the corresponding value in Beth$CLASS is equal to ‘2’; ‘0’ otherwise
The values in vector CLASS4 will be ‘1’ if the corresponding value in Beth$CLASS is equal to ‘4’; ‘0’ otherwise
The values in vector CLASS7 will be ‘1’ if the corresponding value in Beth$CLASS is equal to ‘7’; ‘0’ otherwise
The values in vector CLASS9 will be ‘1’ if the corresponding value in Beth$CLASS is equal to ‘9’; ‘0’ otherwise
How would I go about this using R
Thank you
_________________
Paul Zachos, PhD
Director, Research and Evaluation
Association for the Cooperative Advancement of Science and Education (ACASE)
110 Spring Street Saratoga Springs, NY 12866 |
paz using acase.org | www.acase.org
[[alternative HTML version deleted]]
More information about the R-help
mailing list