Hi All,
I am new to R studio and not sure how to handle below problem.
There are 2 datasets(name and id as below). Required output is a combination of all possible values.
How do we do this in R?
name - A1, A2, A3
id - 10, 20, 30
required output
A1 - 10
A1 - 20
A1 - 30
A2 - 10
A2 - 20
A2 - 30
A3 - 10
A3 - 20
A3 - 30
Any help on this is highly appreciated.
Thanks,
Sathya
library(magrittr)
library(tidyr)
#>
#> Attaching package: 'tidyr'
#> The following object is masked from 'package:magrittr':
#>
#> extract
dat <- data.frame(name = c("A1","A2","A3"), id = c(10,20,30))
dat %>% expand(name,id)
#> # A tibble: 9 x 2
#> name id
#> <chr> <dbl>
#> 1 A1 10
#> 2 A1 20
#> 3 A1 30
#> 4 A2 10
#> 5 A2 20
#> 6 A2 30
#> 7 A3 10
#> 8 A3 20
#> 9 A3 30
Thanks for the help. These are two different datasets.
How do I bring it together ? or are there different option available?
system
Closed
May 31, 2021, 6:14pm
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.