获取有条件的画家的名字

时间:2018-02-03 17:05:36

标签: r dataset

来自library(MASS)。它有数据集画家。

> painters
                Composition Drawing Colour Expression School
Da Udine                 10       8     16          3      A
Da Vinci                 15      16      4         14      A
Del Piombo                8      13     16          7      A
Del Sarto                12      16      9          8      A
Fr. Penni                 0      15      8          0      A
Guilio Romano            15      16      4         14      A
Michelangelo              8      17      4          8      A
Perino del Vaga          15      16      7          6      A
Perugino                  4      12     10          4      A

如何获得具有组合= 10

的画家的名字 我这样做了:

painters$Composition[painters$Composition==10]
[1] 10 10 10 10 10 10

painters$Composition==10
 [1]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE
[14] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[27] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[40] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
[53] FALSE FALSE

1 个答案:

答案 0 :(得分:1)

> rownames(painters[painters$Composition == 10 ,])
[1] "Da Udine"    "F. Zucarro"  "Parmigiano"  "Josepin"    
[5] "J. Jordaens" "Bourdon"

给出:

painters$Composition == 10
> painters$Composition == 10
[1]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
[12] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
[23] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[34] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[45]  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE

说明: 你快到了。首先,您需要根据所需条件识别行的索引:

> painters[painters$Composition == 10 ,]
Composition Drawing Colour Expression School
Da Udine             10       8     16          3      A
F. Zucarro           10      13      8          8      B
Parmigiano           10      15      6          6      B
Josepin              10      10      6          2      C
J. Jordaens          10       8     16          6      G
Bourdon              10       8      8          4      H

接下来,我们使用这些索引对数据框进行子集化:

public class VerifyTitle {

ExtentReports report;
ExtentTest logger;
WebDriver driver;

@Test
public void verifyBlogTitle() {
    driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("https://pt-br.facebook.com/");
    String title = driver.getTitle();
    Assert.assertTrue(title.contains("Facebook"));  
}
@AfterMethod
public void tearDown(ITestResult result) {
    if (result.getStatus() == ITestResult.FAILURE) {


    }
}

最后,我们得到了名字。