Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
r数据帧中的IF语句_R_If Statement_Dataframe - Fatal编程技术网

r数据帧中的IF语句

r数据帧中的IF语句,r,if-statement,dataframe,R,If Statement,Dataframe,如何编写带有两个条件的IF语句来检索相应的值,例如满足这些条件的人的姓名 以下是我的声明: if(any((Basketball$TwoPoint >= 45) && (Basketball$ThreePoint >= 45))) { print(Basketball$Person == (Basketball$TwoPoint >= 45) && (Basketball$ThreePoint >= 45)) } 我知道我有两个人从

如何编写带有两个条件的IF语句来检索相应的值,例如满足这些条件的人的姓名

以下是我的声明:

if(any((Basketball$TwoPoint >= 45) && (Basketball$ThreePoint >= 45))) 
{
  print(Basketball$Person == (Basketball$TwoPoint >= 45) && (Basketball$ThreePoint >= 45))
}

我知道我有两个人从2点和3点的射门超过45[%],因为这个数据框只有7行7列,所以我能够验证这是真的

数据帧很好,因为您可以在数据帧内完成

df <- df[which(df$col1 == 'val1' & df$col2 == 'val2'),]

df甚至不需要
which()
df$col1=='val1'&df$col2=='val2'
将给出一个逻辑向量,该向量将对行进行子集。感谢您的回复,Eric和LateMail!我一定会调查dplyr。