2017-02-11 81 views
2

我有一個數據幀基於另一列從數據框列提取值?

Name score1 score2 Total 
john 5  15  20 
doe 10  20  30 

我知道我們可以使用框架$ score1拿到1分,但基於其他列可以我查詢。

我想在那裏total > 25 and score2 > 15並獲得score1

結果:

score1 
    10 

回答

2

它可以通過創建使用&>運營商的邏輯載體來完成,摘錄在此基礎上的「score1的價值觀vector

with(df1, score1[Total > 25 & score2 > 15]) 
1

您也可以這樣做:

df$score1[df$Total > 25 & df$score2 > 15] 
相關問題