![](/img/trans.png)
[英]Is there a way to create a data frame from two vectors to find all of the possible combinations between the vectors? (In r)
[英]Create data frame with all possible combinations of vectors x and y?
我有2個向量, x
和y
:
x <- seq(from=21.6, to=22, by=0.01)
y <- seq(from=58.77, to=58.93, by=0.01)
我想創建一個數據框df1<-data.frame(x,y)
,其中包含x
和y
所有可能組合。 我怎樣才能做到這一點?
我們可以使用expand.grid
來獲得兩個向量之間的所有可能組合。
expand.grid(x,y)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.