how to extract columns from csv using a list of name
1
0
Entering edit mode
7 weeks ago

I have a list of name, c <- ("a","c","e"), which is a subset of the column names from a matrix(let's say the column names are "a","b","c","d","e","f"). Now I want to use the list of name to extract corresponding columns from this matrix, how should I do this in R.

R excel • 292 views
ADD COMMENT
1
Entering edit mode

Simply use yourmatrix[,your list]

ADD REPLY
0
Entering edit mode

invalid subscript type 'list'

ADD REPLY
1
Entering edit mode

Sorry I do not speak robot

ADD REPLY
0
Entering edit mode
7 weeks ago
caleb_dume ▴ 60

I would recommend looking up the select function of the dplyr package, convert your matrix to a data frame first. There are many ways to do this, type your question in to google.

ADD COMMENT

Login before adding your answer.

Traffic: 1838 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6