如何根据每行的3个观察结果返回真或错误?
看起来像这样
ID | 抗原 | 浓度 |
---|---|---|
C001 | A1 | 0.291259335 |
C001 | A2 | 0.580050639 |
C001 | A3 | 0.002235505 |
C001 | A4 | 0.848792002 |
C002 | C002 | 我 |
数据 | C002 | 的 |
有一个 | A1 | C002 |
: | 集 | 0.194151877 |
C003 | A1 | 0.0142237 |
C003 | A2 A2 | 0.027409926 |
C003 | A3 A3 A3 | 0.000117995 |
C003 | A4 | 0.042202259 |
每个参与者具有4个与IT相关的抗原,并且每个抗原的平均浓度在每个抗原中都在每个特定的范围内,这是不同的,这是每个抗原的范围都在每个范围内,这是属于每个抗原的量。
我正在尝试创建一个函数,其中每个参与者 - 抗原浓度组合都会检查,并在新列中返回一个真/错误。例如,如果参与者= C001,抗原= A1,浓度在0.77至1.43之间,则返回true。如果对于参与者和抗原的任何组合,浓度不超出范围,请返回错误。
我尝试使用循环,如果其他功能和其他效率低下的方式,但效果不足。我认为我不会尽我所能地接近这一点,因此,如果有人可以将我指向任何有用的功能或文档的方向,我将非常感激。
先感谢您!
I have a dataset that looks like this:
ID | antigen | concentration |
---|---|---|
C001 | a1 | 0.291259335 |
C001 | a2 | 0.580050639 |
C001 | a3 | 0.002235505 |
C001 | a4 | 0.848792002 |
C002 | a1 | 0.066808174 |
C002 | a2 | 0.130661773 |
C002 | a3 | 0.000530089 |
C002 | a4 | 0.194151877 |
C003 | a1 | 0.0142237 |
C003 | a2 | 0.027409926 |
C003 | a3 | 0.000117995 |
C003 | a4 | 0.042202259 |
Each participant has 4 antigens associated with it, and the mean concentration for each antigen has to fall within a specific range, which is different for each antigen.
I'm trying to create a function where each participant-antigen-concentration combination is checked and a TRUE/FALSE is returned in a new column. For example if Participant = C001, antigen = a1, and Concentration is between 0.77 and 1.43, return TRUE. If for any combination of participant and antigen the concentration is out of range, return FALSE.
I've tried using for loops, if else functions and other inefficient ways but have come up short. I don't think I'm approaching this in as logical way as I should so if anyone could point me in the direction of any useful functions or documentation for this kind of problem I'd be very grateful.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
case_when
:输出:
You could use
case_when
:Output: