我想獲取資料集的特定值。例如:
df <-read.table(header=TRUE, text="id
A187
A180
C168
H897
D987
C098
Q897
P987
L876")
假設我有一個 vector V = 1 4 5。我基本上想選擇 id 的第一個和第四個元素,例如:
df_new <-read.table(header=TRUE, text="id
A187
H897
D987")
uj5u.com熱心網友回復:
使用Vas 行索引并指定drop = FALSEas 有一個單列,它是一個data.frame(以避免drop = TRUE默認情況下洗掉維度)
df[V, , drop = FALSE]
-輸出
id
1 A187
4 H897
5 D987
資料
V <- c(1, 4, 5)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/332886.html
