0

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?

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213

3 Answers3

3

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.

  • this is deleting the entire column, I want to delete only the first corner cell (inside the red circle); Moreover when I run the "heatmap" then "Error in sample.int(m, k) : vector size cannot be NA/NaN" showing – Suraj Kumar Bhagat Apr 26 '20 at 13:28
  • 1
    Rename the first col: `colnames(data)[1] <- "" ` – Michael Beck Apr 26 '20 at 13:31
2

With tidyverse, we could use column_to_rownames from tibble

library(dplyr)
library(tibble)
df <- df %>%
        column_to_rownames(var = "...1")
akrun
  • 874,273
  • 37
  • 540
  • 662
1

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

rownames(df) <- df[[1]]
df[, 1] <- NULL
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213