Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use subset to judge and filter data according to the conditions of the data box

Shulou Source: shulou.com Published: 2022-06-01 06:34:18 09月30日 Update

This article is about how to use subset to judge and filter data according to the conditions of the data box. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Use subset to select qualified data from the data box

Subset (x,...)

X represents a data frame to be filtered

For example, there are the following data:

> dat Samples group treatment Time1 GSM1625995 con6h control 6h2 GSM1625996 con6h control 6h3 GSM1625997 con6h control 6h4 GSM1625998 con12h control 12h5 GSM1625999 con12h control 12h6 GSM1626000 con12h control 12h7 GSM1626001 con24h control 24h8 GSM1626002 con24h control 24h9 GSM1626003 con24h control 24h10 GSM1626004 hm6h treat 6h11 GSM1626005 hm6h treat 6h12 GSM1626006 hm6h treat 6h13 GSM1626007 hm12h treat 12h14 GSM1626008 hm12h treat 12h15 GSM1626009 hm12h treat 12h16 GSM1626010 hm24h treat 24h17 GSM1626011 hm24h treat 24h18 GSM1626012 hm24h treat for 24 hours

One selection condition: select all con6h data in the data box (group column)

> con6h = subset (dat,group = = "con6h") > con6h Samples group treatment Time1 GSM1625995 con6h control 6h2 GSM1625996 con6h control 6h3 GSM1625997 con6h control 6h >

Multiple conditional selection: select control for 24 hours (according to treatment and Time columns)

> con24h = subset (dat,treatment== "control" & Time = = "24 hours") > con24h Samples group treatment Time7 GSM1626001 con24h control 24h8 GSM1626002 con24h control 24h9 GSM1626003 con24h control 24 hours

Extract the specified area after judgment

> con24h = subset (dat,treatment== "control" & Time = = "24h", select = c ("Samples", "group")) > con24h Samples group7 GSM1626001 con24h8 GSM1626002 con24h9 GSM1626003 con24h Thank you for reading! On "how to use subset to judge and filter data according to the conditions of the data box" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Tags: Data conditions selection content more articles good practical regions articles read knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology OPPO Reno Shulou Tech Info Linux Xiaomi