how to extract columns from csv using a list of name
1
0
Entering edit mode
22 months 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 • 741 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
22 months 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: 2064 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