[英]Are there functions in R that can output all the values in a row, of a data frame, if I have a specific ID from that row
[英]extract values from a data frame based on a vector of row numbers in R
我試圖根據行號向量從數據幀中提取值向量;
df<-iris
x<-c(1,5,15,8,7,2)
我想要向量x中列出的行號的相應種類。 我試過像df$Species[x,]
和df$Species[list(x),]
這樣的東西無濟於事。 我確信答案很簡單,但我看不到它!
提前致謝
嘗試
df[x,]$Species
要么
df[,"Species"][x]
或者確實
df[x,"Species"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.