0

I'm using read_excel to import data into R. Some of the cells in the excel file are empty. I want R to skip these, currently it is reading them into the variable as NA.

file.dat <- read_excel("File.xlsx", sheet = 3)

Alternatively, can read the data into another variable and remove the NA values, at that step?

myData <-file.dat$MyData #how do I skip NA when reading in the MyData variable?

Snapshot of excel file:

enter image description here

Current output in R:

enter image description here I'd like to remove the "NA's". I don't need to retain the index.

Amaranth
  • 55
  • 1
  • 10
  • 1
    What do you mean by "skip" exactly? Data frames in R are rectangular so each row has to have the same number of columns. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Right now it's unclear exactly what your data looks like and exactly what you want in R. – MrFlick Jul 25 '20 at 06:02
  • 1
    @Amarnath you want to delete entire rows with NA observation – simar Jul 25 '20 at 06:06
  • @simar, I need to retain the other rows, just "skip" the blank cells, thanks – Amaranth Jul 25 '20 at 06:12

1 Answers1

0

myData <-file.dat$MyData #read the variable

myData<-na.omit(myData) #remove the n/a

Amaranth
  • 55
  • 1
  • 10