It's rather hard to even create data like yours. We need check.names=FALSE
if we want to create data frames with names containing $
and [
, and back-ticks `
to protect the weird names when referring to them ...
best100_gene <- data.frame(
SYMBOL=c("A", "b", "c", "d", "e"),
Data_PCA_contrib=c(.26,.25,.36,.11,.35),
`Data_PCA$ind$coord[, 2]`=c(12,15,-11,-11,-11),check.names=FALSE)
This is the closest to what you wanted ...
best100_gene[best100_gene[,"Data_PCA$ind$coord[, 2]"]<0,]
You can also use
subset(best100_gene,`Data_PCA$ind$coord[, 2]`<0)
or
with(best100_gene,best100_gene[`Data_PCA$ind$coord[, 2]`<0,])
or
dplyr::filter(best100_gene,`Data_PCA$ind$coord[, 2]`<0)
It would be better to rename your column names to something easier to handle, e.g.
bb <- dplyr::rename(best100_gene,dpc2=`Data_PCA$ind$coord[, 2]`)
Or, even better, look farther back in your workflow and see where the weird names came from.