示例数据:
set.seed(145)
df <- data.frame(Age=sample(c(1:10),20,replace=TRUE),
Rank=sample(c("Extremely","Very","Slightly","Not At All"),
20,replace=TRUE),
Percent=(runif(10,0,.01)))
df.plot <- ggplot(df,aes(x=Age,y=Percent,fill=Rank))+
geom_bar(stat="identity")+
coord_flip()
df.plot
在ggplot中,如何通过Ranks&#34;极其&#34;的总和重新排序x=Age
。和&#34;非常&#34;只要?
我尝试使用下面的内容,没有成功。
df.plot <- ggplot(df,aes(x=reorder(Age,Rank=="Extremely",sum),y=Percent,fill=Rank))+
geom_bar(stat="identity")+
coord_flip()
df.plot
答案 0 :(得分:3)
几个笔记:
package com.provider;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ProApp extends BaseClass{
@Test
public void setUpConnection() throws ClassNotFoundException, SQLException, FileNotFoundException, InterruptedException, IOException {
String driver_DBPath = "jdbc:oracle:thin:@Host:Port:SID";
String DB_username = "*****";
String DB_password = "*****";
String Query = "select * from Table";
Connection con = DriverManager.getConnection(driver_DBPath, DB_username, DB_password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(Query);
while(rs.next()){
String Email = rs.getString("CLAIM_NUMBER");
String Pwd = rs.getString("INDIVIDUAL_NUM");
testUserNamePassword(Email, Pwd);
}
}
@Test(priority=1)
public void clickLoginLink() throws InterruptedException, IOException {
Properties obj = new Properties();
FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\\src\\com\\provider\\Object.Properties");
obj.load(objfile);
Thread.sleep(1000);
driver.findElement(By.xpath(obj.getProperty("ClickOnLoginLink"))).click();
Thread.sleep(1000);
}
@Test(priority=2)
public void testUserNamePassword(String Email1, String Pwd1) throws InterruptedException, IOException {
Thread.sleep(1000);
Properties obj = new Properties();
FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\\src\\com\\provider\\Object.Properties");
obj.load(objfile);
Thread.sleep(1000);
driver.findElement(By.xpath(obj.getProperty("Email"))).clear();
Thread.sleep(1000);
driver.findElement(By.xpath(obj.getProperty("Email"))).sendKeys(Email1);
Thread.sleep(1000);
driver.findElement(By.xpath(obj.getProperty("Pwd"))).clear();
Thread.sleep(1000);
driver.findElement(By.xpath(obj.getProperty("Pwd"))).sendKeys(Pwd1);
Thread.sleep(1000);
driver.findElement(By.xpath(obj.getProperty("Submit"))).click();
Thread.sleep(1000);
}
@Test(priority=3)
public void loginVerify() throws InterruptedException, IOException{
Properties obj = new Properties();
FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\\src\\com\\provider\\Object.Properties");
obj.load(objfile);
Assert.assertEquals("Wel Come To Testing World!!!", driver.findElement(By.xpath(obj.getProperty("WelComeToTestingWorld"))).getText());
}
@Test(priority=4)
public void logonVerify() throws InterruptedException, IOException{
Properties obj = new Properties();
FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\\src\\com\\provider\\Object.Properties");
obj.load(objfile);
WebElement DashboardHeader = driver.findElement(By.xpath(obj.getProperty("WelComeToTestingWorld")));
DashboardHeader.getText().equals("Wel Come To Testing World!!!");
}
}
调用。这解耦了排序逻辑并允许任意排序逻辑。 以下是我认为您正在寻找的内容:
factor
哪个代码产生: