GitHubからRの実行環境に資源を取得するときは、remotes::install_github（"githubのリポジトリ名"）を使う


#結論

```R
install.packages("remotes")
libarary(remotes)
remotes::install_github("githubのリポジトリ名")
```

__で取得できます。__

###（ 参考 ）

- [RパッケージをGitHubからインストールする場合はPersonal Access Tokenを取得・設定しておきましょう](https://uribo.hatenablog.com/entry/2019/01/11/082000)

##実行例

###1. *remotes*パッケージのインストールと呼び出し

```R:RStudio
> install.packages("remotes")
 URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/remotes_2.2.0.tgz' を試しています 
Content type 'application/x-gzip' length 385641 bytes (376 KB)
==================================================
downloaded 376 KB


The downloaded binary packages are in
	/var/folders/dw/kq_8pwps5s771nklvc8krws40000gn/T//RtmpwaZ17t/downloaded_packages
```

```R:RStudio
> library(remotes)
```

###次のGitHubリポジトリから資源を取得します

- [（GitHub）experimentdatar](https://github.com/itamarcaspi/experimentdatar)

> The experimentdatar data package contains publicly available datasets that were used in Susan Athey and Guido Imbens’ course “Machine Learning and Econometrics” (AEA continuing Education, 2018). The datasets are conveniently packed for R users.
>
> __Installation__
>You can install the development version from GitHub
>
>```
># install.packages("devtools")
>devtools::install_github("itamarcaspi/experimentdatar")
>```
>
> __Usage__
>Load experimentdatar and other required libraries
>
>```
>library(dplyr)
>library(experimentdatar)
>```
>

###2. *install_github()*関数を実行

```R:RStudio
> remotes::install_github("itamarcaspi/experimentdatar")
Downloading GitHub repo itamarcaspi/experimentdatar@HEAD
✓  checking for file ‘/private/var/folders/dw/kq_8pwps5s771nklvc8krws40000gn/T/RtmpwaZ17t/remotes13e51d0a4814/itamarcaspi-experimentdatar-f71a9d0/DESCRIPTION’ ...
─  preparing ‘experimentdatar’:
✓  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘experimentdatar_0.0.0.9000.tar.gz’
   
* installing *source* package ‘experimentdatar’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (experimentdatar)
> 
```
###3. 取得したデータの中身

```R:RStudio
> library(experimentdatar)
> library(dplyr)
> 
> data(social)
> summary(social)
      sex             yob           g2000            g2002            g2004       p2000            p2002       
 Min.   :0.000   Min.   :1900   Min.   :0.0000   Min.   :0.0000   Min.   :1   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:0.000   1st Qu.:1946   1st Qu.:1.0000   1st Qu.:1.0000   1st Qu.:1   1st Qu.:0.0000   1st Qu.:0.0000  
 Median :1.000   Median :1955   Median :1.0000   Median :1.0000   Median :1   Median :0.0000   Median :0.0000  
 Mean   :0.503   Mean   :1955   Mean   :0.8655   Mean   :0.8344   Mean   :1   Mean   :0.2648   Mean   :0.4082  
 3rd Qu.:1.000   3rd Qu.:1964   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1   3rd Qu.:1.0000   3rd Qu.:1.0000  
 Max.   :1.000   Max.   :1986   Max.   :1.0000   Max.   :1.0000   Max.   :1   Max.   :1.0000   Max.   :1.0000  
                                                                                                               
    cluster         votedav             dem              nov              aug              city       
 Min.   :    1   Min.   :0.00000   Min.   :  0.00   Min.   :  3.00   Min.   :  0.00   Min.   :  0.00  
 1st Qu.: 2500   1st Qu.:0.00000   1st Qu.:  3.00   1st Qu.: 83.00   1st Qu.: 33.00   1st Qu.:  1.00  
 Median : 5000   Median :0.00000   Median : 18.00   Median : 90.00   Median : 50.00   Median :  2.00  
 Mean   : 5000   Mean   :0.03093   Mean   : 22.48   Mean   : 85.06   Mean   : 49.44   Mean   : 13.88  
 3rd Qu.: 7500   3rd Qu.:0.00000   3rd Qu.: 40.00   3rd Qu.: 96.00   3rd Qu.: 70.00   3rd Qu.: 12.00  
 Max.   :10000   Max.   :1.00000   Max.   :100.00   Max.   :100.00   Max.   :100.00   Max.   :100.00  
                                                                                                      
     hh_id           hh_size      totalpopulation_estimate  percent_male   percent_female    median_age   
 Min.   :     1   Min.   :1.000   Min.   :  554            Min.   :40.90   Min.   :23.30   Min.   :21.40  
 1st Qu.: 45001   1st Qu.:1.000   1st Qu.: 8971            1st Qu.:48.30   1st Qu.:49.60   1st Qu.:37.40  
 Median : 90000   Median :2.000   Median :19822            Median :49.20   Median :50.80   Median :40.00  
 Mean   : 90000   Mean   :1.911   Mean   :20561            Mean   :49.43   Mean   :50.57   Mean   :39.93  
 3rd Qu.:135000   3rd Qu.:2.000   3rd Qu.:30035            3rd Qu.:50.40   3rd Qu.:51.70   3rd Qu.:42.40  
 Max.   :180000   Max.   :8.000   Max.   :63332            Max.   :76.70   Max.   :59.10   Max.   :60.80  
 NA's   :2                                                                                                
 percent_under5years percent_5to9years percent_10to14years percent_15to19years percent_20to24years
 Min.   : 1.000      Min.   : 0.800    Min.   : 1.000      Min.   : 0.900      Min.   : 0.400     
 1st Qu.: 5.000      1st Qu.: 5.800    1st Qu.: 6.300      1st Qu.: 6.300      1st Qu.: 4.400     
 Median : 5.900      Median : 6.600    Median : 7.200      Median : 7.100      Median : 5.400     
 Mean   : 5.898      Mean   : 6.664    Mean   : 7.176      Mean   : 7.213      Mean   : 5.838     
 3rd Qu.: 6.800      3rd Qu.: 7.500    3rd Qu.: 8.000      3rd Qu.: 7.900      3rd Qu.: 6.500     
 Max.   :11.000      Max.   :14.200    Max.   :11.200      Max.   :21.600      Max.   :34.600     
                                                                                                  
 percent_25to34years percent_35to44years percent_45to54years percent_55to59years percent_60to64years
 Min.   : 3.60       Min.   : 3.10       Min.   : 6.50       Min.   : 2.900      Min.   : 1.200     
 1st Qu.: 9.20       1st Qu.:12.30       1st Qu.:14.70       1st Qu.: 6.100      1st Qu.: 4.900     
 Median :10.80       Median :13.40       Median :16.00       Median : 6.900      Median : 5.700     
 Mean   :10.93       Mean   :13.46       Mean   :16.07       Mean   : 7.049      Mean   : 5.818     
 3rd Qu.:12.30       3rd Qu.:14.50       3rd Qu.:17.30       3rd Qu.: 7.900      3rd Qu.: 6.500     
 Max.   :24.90       Max.   :21.80       Max.   :26.00       Max.   :15.400      Max.   :15.100     
                                                                                                    
 percent_65to74years percent_75to84years percent_85yearsandolder percent_18yearsandolder percent_21yearsandover
 Min.   : 1.900      Min.   : 0.80       Min.   :0.000           Min.   :60.60           Min.   :53.00         
 1st Qu.: 6.200      1st Qu.: 3.40       1st Qu.:1.200           1st Qu.:73.60           1st Qu.:69.50         
 Median : 7.100      Median : 4.50       Median :1.600           Median :75.70           Median :71.70         
 Mean   : 7.502      Mean   : 4.56       Mean   :1.815           Mean   :75.71           Mean   :71.75         
 3rd Qu.: 8.400      3rd Qu.: 5.50       3rd Qu.:2.400           3rd Qu.:77.80           3rd Qu.:74.00         
 Max.   :27.300      Max.   :16.00       Max.   :6.300           Max.   :92.60           Max.   :92.20         
                                                                                                               
 percent_62yearsandover percent_65yearsandover percent_white    percent_black    percent_amindian_alaskan
 Min.   : 4.40          Min.   : 3.40          Min.   : 36.00   Min.   : 0.000   Min.   : 0.000          
 1st Qu.:14.20          1st Qu.:11.20          1st Qu.: 89.10   1st Qu.: 0.900   1st Qu.: 0.600          
 Median :16.70          Median :13.50          Median : 95.70   Median : 2.200   Median : 0.900          
 Mean   :17.14          Mean   :13.88          Mean   : 92.52   Mean   : 4.288   Mean   : 1.142          
 3rd Qu.:19.30          3rd Qu.:15.60          3rd Qu.: 97.80   3rd Qu.: 5.300   3rd Qu.: 1.400          
 Max.   :46.70          Max.   :39.70          Max.   :100.00   Max.   :64.200   Max.   :42.900          
                                                                                                         
 percent_asian    percent_nativeandother percent_other_nativeandother percent_hispanicorlatino percent_race_other
 Min.   : 0.000   Min.   :0.00000        Min.   :0.1000               Min.   : 0.000           Min.   : 0.000    
 1st Qu.: 0.600   1st Qu.:0.00000        1st Qu.:0.1000               1st Qu.: 1.700           1st Qu.: 0.400    
 Median : 1.300   Median :0.00000        Median :0.2000               Median : 2.600           Median : 0.700    
 Mean   : 2.587   Mean   :0.06119        Mean   :0.2833               Mean   : 3.772           Mean   : 1.374    
 3rd Qu.: 2.900   3rd Qu.:0.10000        3rd Qu.:0.3000               3rd Qu.: 4.100           3rd Qu.: 1.400    
 Max.   :27.900   Max.   :2.40000        Max.   :4.4000               Max.   :37.600           Max.   :16.800    
                                                                                                                 
 median_income     mean_income       employ_16      unemploy_16    unemploy_20to64  employ_20to64  
 Min.   : 26155   Min.   : 34865   Min.   :18.80   Min.   : 2.30   Min.   : 0.000   Min.   :19.70  
 1st Qu.: 47000   1st Qu.: 58382   1st Qu.:54.60   1st Qu.: 7.90   1st Qu.: 7.000   1st Qu.:67.90  
 Median : 55659   Median : 69143   Median :59.50   Median : 9.60   Median : 8.800   Median :72.50  
 Mean   : 59780   Mean   : 74014   Mean   :58.35   Mean   :10.06   Mean   : 9.235   Mean   :71.31  
 3rd Qu.: 68539   3rd Qu.: 83743   3rd Qu.:62.60   3rd Qu.:11.90   3rd Qu.:10.900   3rd Qu.:75.30  
 Max.   :138884   Max.   :175372   Max.   :74.30   Max.   :28.00   Max.   :28.600   Max.   :86.30  
                                                                                                   
 employ_rename_20to64   hsorhigher    bach_orhigher    less9thgrade      grade9to12       highschool   
 Min.   : 1.300       Min.   :70.70   Min.   : 2.30   Min.   : 0.000   Min.   : 1.000   Min.   : 6.20  
 1st Qu.: 2.200       1st Qu.:88.40   1st Qu.:17.60   1st Qu.: 1.600   1st Qu.: 4.100   1st Qu.:24.40  
 Median : 2.600       Median :91.80   Median :27.20   Median : 2.400   Median : 5.800   Median :30.10  
 Mean   : 3.067       Mean   :91.01   Mean   :28.88   Mean   : 2.709   Mean   : 6.276   Mean   :29.88  
 3rd Qu.: 3.500       3rd Qu.:93.90   3rd Qu.:36.20   3rd Qu.: 3.200   3rd Qu.: 8.400   3rd Qu.:36.70  
 Max.   :11.000       Max.   :98.70   Max.   :77.00   Max.   :14.500   Max.   :19.900   Max.   :55.10  
                                                                                                       
  somecollege        assoc          bachelors          grad       outcome_voted    treatment_dum    treat_hawthorne 
 Min.   : 8.80   Min.   : 1.800   Min.   : 1.40   Min.   : 0.00   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:21.50   1st Qu.: 7.500   1st Qu.:11.60   1st Qu.: 5.80   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000  
 Median :23.80   Median : 8.900   Median :17.80   Median : 8.90   Median :0.0000   Median :0.0000   Median :0.0000  
 Mean   :23.46   Mean   : 8.799   Mean   :17.96   Mean   :10.92   Mean   :0.3247   Mean   :0.4445   Mean   :0.1111  
 3rd Qu.:25.70   3rd Qu.:10.000   3rd Qu.:23.10   3rd Qu.:13.10   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.0000  
 Max.   :34.50   Max.   :17.200   Max.   :38.00   Max.   :51.40   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
                                                                                                                    
  treat_civic     treat_neighbors    treat_self         randn              oneperhh     p2004       
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000031   Min.   :1   Min.   :0.0000  
 1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.1426294   1st Qu.:1   1st Qu.:0.0000  
 Median :0.0000   Median :0.0000   Median :0.0000   Median :0.3170897   Median :1   Median :0.0000  
 Mean   :0.1111   Mean   :0.1111   Mean   :0.1111   Mean   :0.3644871   Mean   :1   Mean   :0.4184  
 3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:0.5508658   3rd Qu.:1   3rd Qu.:1.0000  
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :0.9999971   Max.   :1   Max.   :1.0000  
                                                                                                    
> 
> social %>% select(outcome_voted, treatment_neighbors) %>% head()
 エラー: Can't subset columns that don't exist.
x Column `treatment_neighbors` doesn't exist.
Run `rlang::last_error()` to see where the error occurred.
> 
> social %>% select(outcome_voted, treat_neighbors) %>% head()
# A tibble: 6 x 2
  outcome_voted treat_neighbors
          <int>           <int>
1             0               0
2             1               0
3             1               0
4             0               0
5             0               0
6             0               0
> 
```