mercredi 1 avril 2015

choose the specific variable in r

There are data like this table.



v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15

4 0 0 2 0 0 0 0 0 0 0 0 0 0 0

1 0 0 1 0 0 0 0 0 0 0 0 0 0 0

2 0 0 1 0 0 0 0 0 0 0 0 0 0 0

1 0 0 1 0 0 0 0 0 0 0 0 0 0 0

2 0 0 3 0 0 0 0 0 0 0 0 0 0 0


and I wish to make new matrix with the specific variable column which have the numerical value not zero(in this case the specific variable colum are v1 and v4)


I know the subset function but I cannot find the way to choose conditional columns by using "if statement".


I mean.. how can I make the matrix with the only specific columns that have numerical number by using "if statement"?


Please help me to solve my problem.


Aucun commentaire:

Enregistrer un commentaire