我有数据
subtype <- c("ar","sub")
height <- c("0","1")
我正在使用expand.grid(子类型,高度),但我得到了
Var1 Var2
ar 0
sub 0
ar 1
sub 1
我需要
Var1 Var2
ar 0
sub 1
ar 1
sub 0
ar 0
sub 0
ar 1
sub 1
答案 0 :(得分:2)
我认为这会提供您想要的数据(只是以不同的顺序)
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
public class Main {
private void initAndShowGUI() {
// This method is invoked on the EDT thread
JFrame frame = new JFrame("Swing and JavaFX");
frame.setSize(1000, 1000);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new BorderLayout(0, 0));
frame.getContentPane().add(panel, BorderLayout.CENTER);
JButton button = new JButton("button");
panel.add(button, BorderLayout.CENTER);
final JFXPanel fxPanel = new JFXPanel();
panel.add(fxPanel, BorderLayout.CENTER);
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX(fxPanel);
}
});
}
private WebView webView;
private void initFX(JFXPanel fxPanel) {
// This method is invoked on the JavaFX thread
Scene scene = createScene();
fxPanel.setScene(scene);
GridPane.setHgrow(webView, Priority.ALWAYS);
GridPane.setVgrow(webView, Priority.ALWAYS);
}
private Scene createScene() {
Group root = new Group();
Scene scene = new Scene(root, Color.ALICEBLUE);
webView = new WebView();
GridPane.setHgrow(webView, Priority.ALWAYS);
GridPane.setVgrow(webView, Priority.ALWAYS);
WebEngine webEngine = webView.getEngine();
webEngine.load("http://www.google.com");
root.getChildren().add(webView);
GridPane.setHgrow(webView, Priority.ALWAYS);
GridPane.setVgrow(webView, Priority.ALWAYS);
return scene;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Main().initAndShowGUI();
}
});
}
}