Cannot use library LongCART

Import a dataset

heart_failure_clinical <-read.csv(file.choose(),header = TRUE)

Show whole dataset

heart_failure_clinical

Show data types

str(heart_failure_clinical)

Descriptive Statistic

summary(heart_failure_clinical)
install.packages("LongCART")
library(LongCART)

> heart_failure_clinical <-read.csv(file.choose(),header = TRUE)
> heart_failure_clinical
   id age anaemia creatinine_phosphokinase diabetes ejection_fraction
1   1  75       0                      582        0                20
2   2  55       0                     7861        0                38
3   3  65       0                      146        0                20
4   4  50       1                      111        0                20
5   5  65       1                      160        1                20
6   6  90       1                       47        0                40
7   7  75       1                      246        0                15
8   8  60       1                      315        1                60
9   9  65       0                      157        0                65
10 10  80       1                      123        0                35
11 11  75       1                       81        0                38
12 12  62       0                      231        0                25
13 13  45       1                      981        0                30
14 14  50       1                      168        0                38
15 15  49       1                       80        0                30
16 16  82       1                      379        0                50
17 17  87       1                      149        0                38
18 18  45       0                      582        0                14
19 19  70       1                      125        0                25
20 20  48       1                      582        1                55
21 21  65       1                       52        0                25
22 22  65       1                      128        1                30
23 23  68       1                      220        0                35
24 24  53       0                       63        1                60
25 25  75       0                      582        1                30
26 26  80       0                      148        1                38
27 27  95       1                      112        0                40
28 28  70       0                      122        1                45
29 29  58       1                       60        0                38
30 30  82       0                       70        1                30
31 31  94       0                      582        1                38
32 32  85       0                       23        0                45
33 33  50       1                      249        1                35
34 34  50       1                      159        1                30
35 35  65       0                       94        1                50
36 36  69       0                      582        1                35
37 37  90       1                       60        1                50
38 38  82       1                      855        1                50
39 39  60       0                     2656        1                30
40 40  60       0                      235        1                38
41 41  70       0                      582        0                20
42 42  50       0                      124        1                30
43 43  70       0                      571        1                45
44 44  72       0                      127        1                50
45 45  60       1                      588        1                60
46 46  50       0                      582        1                38
47 47  51       0                     1380        0                25
48 48  60       0                      582        1                38
49 49  80       1                      553        0                20
50 50  57       1                      129        0                30
51 51  68       1                      577        0                25
52 52  53       1                       91        0                20
53 53  60       0                     3964        1                62
54 54  70       1                       69        1                50
55 55  60       1                      260        1                38
56 56  95       1                      371        0                30
57 57  70       1                       75        0                35
58 58  60       1                      607        0                40
59 59  49       0                      789        0                20
60 60  72       0                      364        1                20
61 61  45       0                     7702        1                25
62 62  50       0                      318        0                40
63 63  55       0                      109        0                35
64 64  45       0                      582        0                35
65 65  45       0                      582        0                80
66 66  60       0                       68        0                20
67 67  42       1                      250        1                15
68 68  72       1                      110        0                25
69 69  70       0                      161        0                25
70 70  65       0                      113        1                25
71 71  41       0                      148        0                40
   high_blood_pressure platelets serum_creatinine serum_sodium gender smoking time
1                    1    265000             1.90          130      1       0    4
2                    0    263358             1.10          136      1       0    6
3                    0    162000             1.30          129      1       1    7
4                    0    210000             1.90          137      1       0    7
5                    0    327000             2.70          116      0       0    8
6                    1    204000             2.10          132      1       1    8
7                    0    127000             1.20          137      1       0   10
8                    0    454000             1.10          131      1       1   10
9                    0    263358             1.50          138      0       0   10
10                   1    388000             9.40          133      1       1   10
11                   1    368000             4.00          131      1       1   10
12                   1    253000             0.90          140      1       1   10
13                   0    136000             1.10          137      1       0   11
14                   1    276000             1.10          137      1       0   11
15                   1    427000             1.00          138      0       0   12
16                   0     47000             1.30          136      1       0   13
17                   0    262000             0.90          140      1       0   14
18                   0    166000             0.80          127      1       0   14
19                   1    237000             1.00          140      0       0   15
20                   0     87000             1.90          121      0       0   15
21                   1    276000             1.30          137      0       0   16
22                   1    297000             1.60          136      0       0   20
23                   1    289000             0.90          140      1       1   20
24                   0    368000             0.80          135      1       0   22
25                   1    263358             1.83          134      0       0   23
26                   0    149000             1.90          144      1       1   23
27                   1    196000             1.00          138      0       0   24
28                   1    284000             1.30          136      1       1   26
29                   0    153000             5.80          134      1       0   26
30                   0    200000             1.20          132      1       1   26
31                   1    263358             1.83          134      1       0   27
32                   0    360000             3.00          132      1       0   28
33                   1    319000             1.00          128      0       0   28
34                   0    302000             1.20          138      0       0   29
35                   1    188000             1.00          140      1       0   29
36                   0    228000             3.50          134      1       0   30
37                   0    226000             1.00          134      1       0   30
38                   1    321000             1.00          145      0       0   30
39                   0    305000             2.30          137      1       0   30
40                   0    329000             3.00          142      0       0   30
41                   1    263358             1.83          134      1       1   31
42                   1    153000             1.20          136      0       1   32
43                   1    185000             1.20          139      1       1   33
44                   1    218000             1.00          134      1       0   33
45                   0    194000             1.10          142      0       0   33
46                   0    310000             1.90          135      1       1   35
47                   1    271000             0.90          130      1       0   38
48                   1    451000             0.60          138      1       1   40
49                   1    140000             4.40          133      1       0   41
50                   0    395000             1.00          140      0       0   42
51                   1    166000             1.00          138      1       0   43
52                   1    418000             1.40          139      0       0   43
53                   0    263358             6.80          146      0       0   43
54                   1    351000             1.00          134      0       0   44
55                   0    255000             2.20          132      0       1   45
56                   0    461000             2.00          132      1       0   50
57                   0    223000             2.70          138      1       1   54
58                   0    216000             0.60          138      1       1   54
59                   1    319000             1.10          136      1       1   55
60                   1    254000             1.30          136      1       1   59
61                   1    390000             1.00          139      1       0   60
62                   1    216000             2.30          131      0       0   60
63                   0    254000             1.10          139      1       1   60
64                   0    385000             1.00          145      1       0   61
65                   0    263358             1.18          137      0       0   63
66                   0    119000             2.90          127      1       1   64
67                   0    213000             1.30          136      0       0   65
68                   0    274000             1.00          140      1       1   65
69                   0    244000             1.20          142      0       0   66
70                   0    497000             1.83          135      1       0   67
71                   0    374000             0.80          140      1       1   68
   DEATH_EVENT
1            1
2            1
3            1
4            1
5            1
6            1
7            1
8            1
9            1
10           1
11           1
12           1
13           1
14           1
15           0
16           1
17           1
18           1
19           1
20           1
21           0
22           1
23           1
24           0
25           1
26           1
27           1
28           1
29           1
30           1
31           1
32           1
33           1
34           0
35           1
36           1
37           1
38           1
39           0
40           1
41           1
42           1
43           1
44           0
45           1
46           1
47           1
48           1
49           1
50           1
51           1
52           1
53           1
54           1
55           1
56           1
57           0
58           0
59           1
60           1
61           1
62           1
63           0
64           1
65           0
66           1
67           1
68           1
69           1
70           1
71           0
 [ reached 'max' / getOption("max.print") -- omitted 228 rows ]
> 
> # Show data types
> str(heart_failure_clinical)
'data.frame':	299 obs. of  14 variables:
 $ id                      : int  1 2 3 4 5 6 7 8 9 10 ...
 $ age                     : int  75 55 65 50 65 90 75 60 65 80 ...
 $ anaemia                 : int  0 0 0 1 1 1 1 1 0 1 ...
 $ creatinine_phosphokinase: int  582 7861 146 111 160 47 246 315 157 123 ...
 $ diabetes                : int  0 0 0 0 1 0 0 1 0 0 ...
 $ ejection_fraction       : int  20 38 20 20 20 40 15 60 65 35 ...
 $ high_blood_pressure     : int  1 0 0 0 0 1 0 0 0 1 ...
 $ platelets               : num  265000 263358 162000 210000 327000 ...
 $ serum_creatinine        : num  1.9 1.1 1.3 1.9 2.7 2.1 1.2 1.1 1.5 9.4 ...
 $ serum_sodium            : int  130 136 129 137 116 132 137 131 138 133 ...
 $ gender                  : int  1 1 1 1 0 1 1 1 0 1 ...
 $ smoking                 : int  0 0 1 0 0 1 0 1 0 1 ...
 $ time                    : int  4 6 7 7 8 8 10 10 10 10 ...
 $ DEATH_EVENT             : int  1 1 1 1 1 1 1 1 1 1 ...
> 
> # Descriptive Statistic
> summary(heart_failure_clinical)
       id             age           anaemia       creatinine_phosphokinase
 Min.   :  1.0   Min.   :40.00   Min.   :0.0000   Min.   :  23.0          
 1st Qu.: 75.5   1st Qu.:51.00   1st Qu.:0.0000   1st Qu.: 116.5          
 Median :150.0   Median :60.00   Median :0.0000   Median : 250.0          
 Mean   :150.0   Mean   :60.84   Mean   :0.4314   Mean   : 581.8          
 3rd Qu.:224.5   3rd Qu.:70.00   3rd Qu.:1.0000   3rd Qu.: 582.0          
 Max.   :299.0   Max.   :95.00   Max.   :1.0000   Max.   :7861.0          
    diabetes      ejection_fraction high_blood_pressure   platelets     
 Min.   :0.0000   Min.   :14.00     Min.   :0.0000      Min.   : 25100  
 1st Qu.:0.0000   1st Qu.:30.00     1st Qu.:0.0000      1st Qu.:212500  
 Median :0.0000   Median :38.00     Median :0.0000      Median :262000  
 Mean   :0.4181   Mean   :38.08     Mean   :0.3512      Mean   :263358  
 3rd Qu.:1.0000   3rd Qu.:45.00     3rd Qu.:1.0000      3rd Qu.:303500  
 Max.   :1.0000   Max.   :80.00     Max.   :1.0000      Max.   :850000  
 serum_creatinine  serum_sodium       gender          smoking            time      
 Min.   :0.500    Min.   :113.0   Min.   :0.0000   Min.   :0.0000   Min.   :  4.0  
 1st Qu.:0.900    1st Qu.:134.0   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.: 73.0  
 Median :1.100    Median :137.0   Median :1.0000   Median :0.0000   Median :115.0  
 Mean   :1.394    Mean   :136.6   Mean   :0.6488   Mean   :0.3211   Mean   :130.3  
 3rd Qu.:1.400    3rd Qu.:140.0   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:203.0  
 Max.   :9.400    Max.   :148.0   Max.   :1.0000   Max.   :1.0000   Max.   :285.0  
  DEATH_EVENT    
 Min.   :0.0000  
 1st Qu.:0.0000  
 Median :0.0000  
 Mean   :0.3211  
 3rd Qu.:1.0000  
 Max.   :1.0000  
> 
> 
> install.packages("LongCART")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/user/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘cli’, ‘lifecycle’, ‘rlang’, ‘scales’, ‘vctrs’, ‘ggplot2’, ‘survminer’


  There are binary versions available but the source versions are later:
          binary source needs_compilation
cli        3.2.0  3.6.3              TRUE
lifecycle  1.0.1  1.0.4             FALSE
rlang      1.0.2  1.1.5              TRUE
scales     1.2.0  1.3.0              TRUE
vctrs      0.4.1  0.6.5              TRUE
ggplot2    3.3.5  3.5.1             FALSE
survminer  0.4.9  0.5.0             FALSE
LongCART     3.1    3.2             FALSE

  Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/cli_3.2.0.zip'
Content type 'application/zip' length 1255499 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rlang_1.0.2.zip'
Content type 'application/zip' length 1718546 bytes (1.6 MB)
downloaded 1.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/scales_1.2.0.zip'
Content type 'application/zip' length 616764 bytes (602 KB)
downloaded 602 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/vctrs_0.4.1.zip'
Content type 'application/zip' length 1569486 bytes (1.5 MB)
downloaded 1.5 MB

package ‘cli’ successfully unpacked and MD5 sums checked
package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘scales’ successfully unpacked and MD5 sums checked
package ‘vctrs’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\user\AppData\Local\Temp\RtmpADfYel\downloaded_packages
installing the source packages ‘lifecycle’, ‘ggplot2’, ‘survminer’, ‘LongCART’

trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'
Content type 'application/x-gzip' length 107656 bytes (105 KB)
downloaded 105 KB

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.5.1.tar.gz'
Content type 'application/x-gzip' length 3604371 bytes (3.4 MB)
downloaded 3.4 MB

trying URL 'https://cran.rstudio.com/src/contrib/survminer_0.5.0.tar.gz'
Content type 'application/x-gzip' length 2882134 bytes (2.7 MB)
downloaded 2.7 MB

trying URL 'https://cran.rstudio.com/src/contrib/LongCART_3.2.tar.gz'
Content type 'application/x-gzip' length 121365 bytes (118 KB)
downloaded 118 KB

* installing *source* package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'lifecycle'
* removing 'C:/Users/user/Documents/R/win-library/4.0/lifecycle'
* restoring previous 'C:/Users/user/Documents/R/win-library/4.0/lifecycle'
Warning in install.packages :
  installation of package ‘lifecycle’ had non-zero exit status
* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'ggplot2'
* removing 'C:/Users/user/Documents/R/win-library/4.0/ggplot2'
* restoring previous 'C:/Users/user/Documents/R/win-library/4.0/ggplot2'
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status
* installing *source* package 'survminer' ...
** package 'survminer' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error: package 'ggplot2' 3.3.5 was found, but >= 3.4.0 is required by 'survminer'
Execution halted
ERROR: lazy loading failed for package 'survminer'
* removing 'C:/Users/user/Documents/R/win-library/4.0/survminer'
Warning in install.packages :
  installation of package ‘survminer’ had non-zero exit status
ERROR: dependency 'survminer' is not available for package 'LongCART'
* removing 'C:/Users/user/Documents/R/win-library/4.0/LongCART'
Warning in install.packages :
  installation of package ‘LongCART’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\user\AppData\Local\Temp\RtmpADfYel\downloaded_packages’
> library(LongCART)
Error in library(LongCART) : there is no package called ‘LongCART’

Did you install the Rtools package as prompted?

If you want to keep using R 4.0.x, then you need to install Rtools, see RTools: Toolchains for building R and R packages from source on Windows

Alternatively, you can update to R 4.4.2 and then you'll probably have binary packages, almost always, and don't need Rtools.

You might also give rig a go, it will make it easier to install various R versions and also Rtools: GitHub - r-lib/rig: The R Installation Manager

I install Rtools package.

Thank you very much. I updated to R 4.4.2. Finally, I can use library LongCART.