One approach is to use rownames()
to select rows with the [
form of the extract operator as follows.
textData <- "Rownames|Age
Player 1|27
Player 2|28
Player 3|25"
data <- read.csv(text=textData,row.names="Rownames",header=TRUE,sep="|")
At this point the data
data frame has three observations with one column. Each row has a row name.
# print data to show that data frame has one column, and player
# info is stored as rownames
data
> data
Age
Player 1 27
Player 2 28
Player 3 25
Next, we'll subset the data frame.
data[!rownames(data) %in% c("Player 1","Player 2"),]
...and the output, which prints as a vector since there is only one column in the input data frame:
> data[!rownames(data) %in% c("Player 1","Player 2"),]
[1] 25
Combining this technique with subset()
results in a single row data frame:
subset(data,!rownames(data) %in% c("Player 1","Player 2"))
...and the output:
> subset(data,!rownames(data) %in% c("Player 1","Player 2"))
Age
Player 3 25
>