如果有多个条件,如何创建总和

时间:2016-10-29 19:40:05

标签: r dataframe sum dplyr

我必须按多个条件的列创建“总和if”。

我试过这个:

package appium.eclipse;

import org.testng.annotations.Test;

import java.io.IOException;
import java.net.URL;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;

public class NewTest {
    AppiumDriver<WebElement> dr;

    @BeforeClass
    public void setup() throws IOException{
        DesiredCapabilities first = new DesiredCapabilities();
        first.setCapability(MobileCapabilityType.DEVICE_NAME, "donatello");
        first.setCapability(MobileCapabilityType.APP_ACTIVITY,"com.myapplication.MainActivity");
        first.setCapability(MobileCapabilityType.APP_PACKAGE,"com.myapplicationdev");
        dr=new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),first);
    }

    @Test
    public void launchapp() throws Throwable {
        Thread.sleep(9000);
        //insert pin
        for (int i =0; i<5; i ++) {
            dr.findElementByXPath("//android.view.View[@content-desc='1']").click();
            System.out.println("I clicked" + i );
            Thread.sleep(1000);
        }
        //click login
        Thread.sleep(4000);
        dr.findElementByXPath("//android.view.View[@index='2']").click();
        System.out.println("I clicked Login");
        Thread.sleep(9000);
    }
}

但它不起作用。

我该怎么办?

1 个答案:

答案 0 :(得分:1)

试试这个:

library(dplyr)
b <- DB.all %>% group_by(Family) %>% summarise(sum(x))