Als ein kurzes Beispiel, wenn combn(1:5,2)
ausgeführt wird, bekomme ich eine Matrix aus 2 Zeilen und 10 Spalten. Ich weiß, ich kann die Ausgangsmatrix zu einem Datenrahmen konvertieren, aber ist es möglich, (eine Option innerhalb combn
) die Ausgabe ohne weiteres in Form eines vertikalen Datenrahmen von Spalten und Reihen zu haben? Danke.Formatierung R-Combn-Ausgabe
-1
A
Antwort
1
einfach transponieren die Matrix mit t()
:
data.frame(t(combn(1:5, 2)))
Ausbeuten:
X1 X2
1 1 2
2 1 3
3 1 4
4 1 5
5 2 3
6 2 4
7 2 5
8 3 4
9 3 5
10 4 5
+0
OK, danke! Ich werde dies tun, da es scheint, dass keine Optionen in combn (*: *, *) verfügbar sind, um direkt einen vertikalen Datenrahmen auszugeben ... – Andrew
Verwandte Themen
- 1. console Formatierung vs Textfile Formatierung
- 2. R Shiny- Formatierung über Formatierung
- 3. bedingte Formatierung oder Formatierung mit VBA
- 4. Chart.js V2 Formatierung/Formatierung von Beschriftungen
- 5. Logger.info Formatierung
- 6. ComboBox Formatierung
- 7. Textbox-Formatierung
- 8. StyleCop Formatierung
- 9. Namen Formatierung
- 10. Codelite-Formatierung
- 11. PHPExcel Formatierung
- 12. cout Formatierung
- 13. FileOutputStream Formatierung?
- 14. Excel Formatierung
- 15. HTML-Formatierung
- 16. Zeitspanne Formatierung
- 17. Wettervorhersage Formatierung
- 18. Formatierung Arraydaten
- 19. PHP DateTime-Formatierung funktioniert, aber DateInterval-Formatierung funktioniert nicht
- 20. Get Resharper-Formatierung, um Visual Studio-Formatierung zu entsprechen
- 21. Python-String Formatierung
- 22. PHP IMAP Formatierung
- 23. HTML-Formatierung für TextView
- 24. jqGrid Spalte DateTime Formatierung
- 25. Formatierung der Eigenschaftenrasterfeldnummer
- 26. C# Formatierung Nummer
- 27. Excel Interop Bedingte Formatierung
- 28. Automatische Formatierung für vi?
- 29. ReSharper: Delegierten Formatierung
- 30. NLog Zeit Formatierung
Wahrscheinlich einfachsten ist 'data.frame (t (combn (1: 5,2)))'. – lmo