Linked Questions

78 votes
2 answers
225k views

List all column except for one in R [duplicate]

Possible Duplicate: Drop Columns R Data frame Let's say I have a dataframe with column c1, c2, c3. I want to list just c1 and c2. How do I do that? I've tried: head(data[column!="c3"]) head(...
mythicalprogrammer's user avatar
18 votes
1 answer
93k views

How to delete a column in R dataframe [duplicate]

Possible Duplicate: Drop Columns R Data frame Suppose, I have the following dataframe, and want to delete column "dataB" what would be R command for that? y <- data.frame(k1=c(101,102,103,104,...
M.Qasim's user avatar
  • 1,888
13 votes
1 answer
87k views

How to subset a Data frame column wise using column names? [duplicate]

I have created a data frame named z. a = c(1,1,1); b = c(2,2,2); c = c(3,3,3); d = c(4,4,4); z = data.frame(a,b,c,d); I want to remove column c and d from data frame z. I tried this code ...
Nikhil Singhal's user avatar
2 votes
3 answers
10k views

Subset data frame based on character vector of column names [duplicate]

Rookie question - thanks in advance for patience... I have a dataframe: vals <- c(1,1,1,1) testdf <- data.frame("var1"=vals, "var2"=vals, "var3"=vals) I have a character vector of variable ...
Rocinante's user avatar
  • 635
2 votes
1 answer
9k views

Drop a list of columns from data frame [duplicate]

Possible Duplicate: Drop Columns R Data frame I have a list of variables I would like to drop from IRIS table as follow: dropList <- c("Sepal.Length", "Sepal.Width") How I can use this list to ...
AdamNYC's user avatar
  • 20.5k
-1 votes
2 answers
10k views

Dropping Columns by name in R [duplicate]

So I have a data-frame structured as: > head(peakQ) STATION_NUMBER DATA_TYPE YEAR PEAK_CODE PRECISION_CODE MONTH DAY HOUR MINUTE TIME_ZONE PEAK SYMBOL 1 05EE006 Q 1983 H ...
Cuylar Conly's user avatar
1 vote
1 answer
4k views

R: Unselect matrix or data.frame columns by name [duplicate]

Possible Duplicate: Drop Columns R Data frame Assuming a matrix with 3 named columns "A", "B", C", I can unselect columns "B" and "C" like this: df[, -c(2, 3)] But what if I want to use column ...
Robert Kubrick's user avatar
0 votes
2 answers
5k views

How to remove unwanted column from excel file in R? [duplicate]

I have read excel files that has two sheets in R, where first sheet has four column and second sheet has only one column. after I read first sheet in R, but still not well structured. I want to get ...
user avatar
1 vote
2 answers
667 views

Removing columns from data frame using R [duplicate]

I am trying to remove columns, from data frame say a, of whose names are present in array, say x. a <- data.frame( ab = 1:3, ac = 4:6, ad = 7:9, ae = 10:12, af = 13:15, ag=c("a", "b", "c")) x <...
mandy-jubl's user avatar
0 votes
2 answers
887 views

How to remove multiple columns from a dataframe with column list [duplicate]

I have a variable list with column names and a dataframe . I would like to remove columns from the dataframes when the column names match the variable list. columns -> "a","c" dataframe-> a b c d ...
renuka kallepalli's user avatar
1 vote
2 answers
775 views

Unable to delete Columns in R [duplicate]

I want to delete 2 columns named-ItemID_na and Item.Type1_na. I have below code to delete. test_input<-subset(test_input,select = -c(ItemId_na, Item.Type1_na)) i am getting below error- ...
Arpit Sisodia's user avatar
1 vote
2 answers
830 views

I want to match a column from one table with another table and replace those matching values [duplicate]

i have a table say,Table A : uid pid code 1 1 aaa 2 1 ccc 3 4 ddd 4 2 eee i have another table, Table B: pid msg 1 good 2 inspiring 3 thing to wtch 4 terrible now, i ...
Prajna's user avatar
  • 159
1 vote
2 answers
711 views

Drop Columns of Another Dataframe from Main Dataframe [duplicate]

I have 2 dataframes, df1 <- data.frame(a = c(1,2,3,4,9), b = c(1,2,3,4,5) , c = c(1,2,3,4,9), d = c(1,2,3,4,5) ) df2 <- data.frame( c = c(1,2,3,4,5) ,a = c(1,2,3,4,5) ) I want to drop all ...
determinator's user avatar
2 votes
1 answer
212 views

Gentle way for removing named variable from dataframe [duplicate]

Is there possibility to write function f(), which I can use for subsetting columns set which we can use strictly like this : data[, f(c("var1", "var2", "var3"))] without using data as argument,f() ...
Qbik's user avatar
  • 6,205
-1 votes
1 answer
405 views

Select matrix columns using vector of names [duplicate]

One list of names: names = c(col1, col2, col6) matrix like this: col1 col2 col3 col4 col5 col6 1 4 5 2 7 2 4 5 7 2 8 1 in order to have this: col1 col2 col6 1 ...
F.Lira's user avatar
  • 663

15 30 50 per page