Skip to content
Prev 371525 / 398506 Next

Subset

myDF <- data.frame(a = c("<0.1", NA, 0.3, 5, "Nil"),
                   b = c("<0.1", 1, 0.3, 5, "Nil"),
                   stringsAsFactors = FALSE)

# you can subset the b-column in several ways

myDF[ , 2]
myDF[ , "b"]
myDF$b

# using the column, you make a logical vector
! is.na(as.numeric(myDF$b))


# This can be used to select the rows you want

myDF[! is.na(as.numeric(myDF$b)), ]



B.