说有一个向量:
v1 <- c("ab", "bc", "cd", "ef", "yolo", "da", "sm", "ez-de")
v2 <- c("ab", "bc", "cd", "ef", "yolo-da", "sm", "ez", "de")
如何合并上面的两个向量,以便我们得到以下内容?
c("ab", "bc", "cd", "ef", "yolo-da", "sm", "ez-de")
请注意,上面的两个向量具有相同的长度..
答案 0 :(得分:1)
如果不关注值的顺序,我们可以尝试这样做:
driver.manage().window().maximize();
driver.findElement(By.id("T1")).sendKeys("test@gmail.com");
driver.findElement(By.id("T2")).sendKeys("test@1234");
WebDriverWait wait = new WebDriverWait(driver, 20);
WebDriverWait wait1 = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("loginbtn"))));
System.out.println("Is Visible");
wait1.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.id("loginbtn"))));
System.out.println("Is clickable");
driver.findElement(By.id("loginbtn")).click();
答案 1 :(得分:0)
解决方案的逐步方法;一旦理解,步骤可以减少
# case 1.
a=c("ab", "bc", "cd", "ef", "yolo", "da", "sm", "ez-de")
b=c("ab", "bc", "cd", "ef", "yolo-da", "sm", "ez", "de")
# [1] "ab" "bc" "cd" "ef" "sm" "yolo-da" "ez-de"
# case 2.
a = c("lol", "it","is", "now", " jab-time")
b = c("lol", "it-is", " now", "jab", " time")
# [1] "lol" "now" "it-is" "jab-time"
a = trimws(a) # since observed that case 2 . "now" had whitespaces
b = trimws(b) # these 2 steps are unnecessary, just check if that was a typo
c = intersect(a, b) # extract the common values from both vectors
a = a[!(a %in% c)] # keep only those which are not there in c
b = b[!(b %in% c)] # keep only those which are not there in c
d = grep("-", c(a, b), value = TRUE) # this returns only those having "-" in it
ans <- c(c , d)
答案 2 :(得分:0)
我的方法:
library(dplyr)
a=c("ab", "bc", "cd", "ef", "yolo", "da", "sm", "ez-de")
b=c("ab", "bc", "cd", "ef", "yolo-da", "sm", "ez", "de")
ab <- c(a,b)
ab_unique <- unique(ab)
ab
ab_unique