Suraj Kumar Bhagat
Suraj Kumar Bhagat

Reputation: 47

How to delete the very first column-first row in R as per this shows in attached pic

I have uploaded the excel file into the R environment when I view(data) then this shows like this

this red circle has "...1" which is not actually in the excel sheet, so how to delete it in the R?

Upvotes: 0

Views: 3355

Answers (3)

akrun
akrun

Reputation: 887098

With tidyverse, we could use column_to_rownames from tibble

library(dplyr)
library(tibble)
df <- df %>%
        column_to_rownames(var = "...1")

Upvotes: 2

Ronak Shah
Ronak Shah

Reputation: 388982

You can add the first column as rowname and then delete the first column.

rownames(df) <- df[[1]]
df[, 1] <- NULL

Upvotes: 1

Michael Beck
Michael Beck

Reputation: 76

If you just want to rename the first column:

colnames(data)[1] <- ""

Otherwise you can either sett it to Null

data[1] <- NULL 

... or subset the dataframe ...

data <- data[,-1]

... but there are lots of ways to do this.

Upvotes: 3

Related Questions