Question: I have the following method to create a new user in Azure Active Directory using the Graph API:

```
public static async Task AddUserAsync(User user)
{
    Microsoft.Azure.ActiveDirectory.GraphClient.ActiveDirectoryClient adClient = 
        GetActiveDirectoryClient();

    await adClient.Users.AddUserAsync(user);
}

```

After the user is created using this method, I need to automatically log the user in.

I'm looking for something like the [SignInManager.SignInAsync](https://msdn.microsoft.com/en-us/library/mt173757(v=vs.108).aspx) or [SignInManager.PasswordSignInAsync](https://msdn.microsoft.com/en-us/library/mt173779(v=vs.108).aspx) methods.

Answer: 
The `dcast` method of data.table works fine on this example:

```
ppn1 = read.table(text='Officer,Company
Robert Abernathy,Goldman Sachs
Robert Abernathy,Walmart
Robert Abernathy,CVS
Rex Adams,Goldman Sachs
Rex Adams,Dell
Marc Abramowitz,Samsung', header=T, sep=',')

```

Thanks to @Frank, we have the following that works:

```
dcast(ppn1, Officer~rowid(Officer, prefix="Company"))

```

Giving:

```
           Officer      Company1 Company2 Company3
1  Marc Abramowitz       Samsung     <NA>     <NA>
2        Rex Adams Goldman Sachs     Dell     <NA>
3 Robert Abernathy Goldman Sachs  Walmart      CVS

```
You could make your column headers first as a new column then reshape:

```r
df <- readr::read_csv('Officer,Company
Robert Abernathy,Goldman Sachs
Robert Abernathy,Walmart
Robert Abernathy,CVS
Rex Adams,Goldman Sachs
Rex Adams,Dell
Marc Abramowitz,Samsung')
df
#> # A tibble: 6 x 2
#>            Officer       Company
#>              <chr>         <chr>
#> 1 Robert Abernathy Goldman Sachs
#> 2 Robert Abernathy       Walmart
#> 3 Robert Abernathy           CVS
#> 4        Rex Adams Goldman Sachs
#> 5        Rex Adams          Dell
#> 6  Marc Abramowitz       Samsung

# Add column headers as new column (using grouped row number)
library(dplyr)
df %>% 
  group_by(Officer) %>% 
  mutate(ColName = paste0('Company', row_number())) %>% 
  tidyr::spread(ColName, Company)
#> # A tibble: 3 x 4
#> # Groups:   Officer [3]
#>            Officer      Company1 Company2 Company3
#> *            <chr>         <chr>    <chr>    <chr>
#> 1  Marc Abramowitz       Samsung     <NA>     <NA>
#> 2        Rex Adams Goldman Sachs     Dell     <NA>
#> 3 Robert Abernathy Goldman Sachs  Walmart      CVS

```