Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
8.3 kB
3
Indexable
Never
 library(vcdExtra)
Ładowanie wymaganego pakietu: vcd
Ładowanie wymaganego pakietu: grid
Ładowanie wymaganego pakietu: gnm
Warning messages:
1: pakiet ‘vcdExtra’ został zbudowany w wersji R 4.1.3 
2: pakiet ‘vcd’ został zbudowany w wersji R 4.1.3 
3: pakiet ‘gnm’ został zbudowany w wersji R 4.1.3 
> 
> Detergent
, , Preference = Brand X, Water_softness = Soft

           M_User
Temperature Yes No
       High  19 29
       Low   57 63

, , Preference = Brand M, Water_softness = Soft

           M_User
Temperature Yes No
       High  29 27
       Low   49 53

, , Preference = Brand X, Water_softness = Medium

           M_User
Temperature Yes No
       High  23 33
       Low   47 66

, , Preference = Brand M, Water_softness = Medium

           M_User
Temperature Yes No
       High  47 23
       Low   55 50

, , Preference = Brand X, Water_softness = Hard

           M_User
Temperature Yes No
       High  24 42
       Low   37 68

, , Preference = Brand M, Water_softness = Hard

           M_User
Temperature Yes No
       High  43 30
       Low   52 42

> library(tidyverse)
Error: ładowanie pakietu lub przestrzeni nazw nie powiodło się dla ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 nie ma pakietu o nazwie ‘jsonlite’
In addition: Warning message:
pakiet ‘tidyverse’ został zbudowany w wersji R 4.1.3 
> Detergent.df <- data.frame(Detergent)
> View(Detergent.df)
> names(Detergent.df)
[1] "Temperature"    "M_User"         "Preference"     "Water_softness" "Freq"          
> levels(Detergent.df$M_User)
[1] "Yes" "No" 
> levels(Detergent.df$Water_softness)
[1] "Soft"   "Medium" "Hard"  
> Detergent.df%>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq)) %>%
+ library(dplyr)
Error in Detergent.df %>% group_by(Temperature) %>% summarize(n = sum(Freq)) %>%  : 
  could not find function "%>%"
> 
> Detergent.df%.%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutable(prop = n | sum(n))
Error in Detergent.df %.% group_by(Temperature) %>% summarize(n = sum(Freq)) %>%  : 
  could not find function "%>%"
> library(dplyr)

Dołączanie pakietu: ‘dplyr’

Następujący obiekt został zakryty z ‘package:vcdExtra’:

    summarise

Następujące obiekty zostały zakryte z ‘package:stats’:

    filter, lag

Następujące obiekty zostały zakryte z ‘package:base’:

    intersect, setdiff, setequal, union

Warning message:
pakiet ‘dplyr’ został zbudowany w wersji R 4.1.3 
> install.packages("dyplr")
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/
Instalowanie pakietu w ‘C:/Users/lab/Documents/R/win-library/4.1’
(ponieważ ‘lib’ nie jest określony)
Warning in install.packages :
  package ‘dyplr’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

Restarting R session...

> install.packages("dplyr")
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/
Instalowanie pakietu w ‘C:/Users/lab/Documents/R/win-library/4.1’
(ponieważ ‘lib’ nie jest określony)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/dplyr_1.0.10.zip'
Content type 'application/zip' length 1394515 bytes (1.3 MB)
downloaded 1.3 MB

package ‘dplyr’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\lab\AppData\Local\Temp\RtmpQthr1b\downloaded_packages
> library(dplyr)

Dołączanie pakietu: ‘dplyr’

Następujące obiekty zostały zakryte z ‘package:stats’:

    filter, lag

Następujące obiekty zostały zakryte z ‘package:base’:

    intersect, setdiff, setequal, union

Warning message:
pakiet ‘dplyr’ został zbudowany w wersji R 4.1.3 
> Detergent.df%.%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutable(prop = n | sum(n))
Error in mutable(., prop = n | sum(n)) : 
  could not find function "mutable"
> Detergent.df%.%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
Error in Detergent.df %.% group_by(Temperature) : 
  could not find function "%.%"
> Detergent.df%>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
# A tibble: 2 x 3
  Temperature     n prop 
  <fct>       <dbl> <lgl>
1 High          369 TRUE 
2 Low           639 TRUE 
> Detergent.df%>%filter(Water_softness == "soft")
[1] Temperature    M_User         Preference     Water_softness Freq          
<0 wierszy> (lub 'row.names' o zerowej długości)
> Detergent.df%>%
+ filter(water_softnes == "soft")
Error in `filter()`:
! Problem while computing `..1 = water_softnes == "soft"`.
Caused by error in `mask$eval_all_filter()`:
! object 'water_softnes' not found
Run `rlang::last_error()` to see where the error occurred.
> Detergent.df%>%
+ filter(water_softnes == "soft") %>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
Error in `filter()`:
! Problem while computing `..1 = water_softnes == "soft"`.
Caused by error in `mask$eval_all_filter()`:
! object 'water_softnes' not found
Run `rlang::last_error()` to see where the error occurred.
> Detergent.df%>%
+ filter(Water_softness == "soft") %>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
# A tibble: 0 x 3
# ... with 3 variables: Temperature <fct>, n <dbl>, prop <lgl>
# i Use `colnames()` to see all variable names
> Detergent.df%>%
+ filter(Water_softness == "soft") %>%
+ summarize(n=sum(Freq))%>%
+ 
+ 
+ m
Error in m(.) : could not find function "m"
> Detergent.df%>%
+ filter(Water_softness == "soft") %>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
# A tibble: 0 x 3
# ... with 3 variables: Temperature <fct>, n <dbl>, prop <lgl>
# i Use `colnames()` to see all variable names
> Detergent.df%>%
+ filter(Water_softness == "Soft") %>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
# A tibble: 2 x 3
  Temperature     n prop 
  <fct>       <dbl> <lgl>
1 High          104 TRUE 
2 Low           222 TRUE 
> Detergent.df%>%
+ filter(Water_softness == "Medium") %>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
# A tibble: 2 x 3
  Temperature     n prop 
  <fct>       <dbl> <lgl>
1 High          126 TRUE 
2 Low           218 TRUE 
> Detergent.df%>%
+ filter(Water_softness == "Hard") %>%
+ group_by(Temperature) %>%
+ summarize(n=sum(Freq))%>%
+ mutate(prop = n | sum(n))
# A tibble: 2 x 3
  Temperature     n prop 
  <fct>       <dbl> <lgl>
1 High          139 TRUE 
2 Low           199 TRUE 
> ftable(Detergent.df, col.vars = "Temperature", row.vars = "Water_softness")
               Temperature High Low
Water_softness                     
Soft                          4   4
Medium                        4   4
Hard                          4   4
> library(vcd)
Ładowanie wymaganego pakietu: grid
Warning message:
pakiet ‘vcd’ został zbudowany w wersji R 4.1.3 
> structable(Temperature~Water_softness, Detergent.df)
               Temperature High Low
Water_softness                     
Soft                          4   4
Medium                        4   4
Hard                          4   4
> structable(Temperature~Water_softness, Detergent.df)%>%addmargins()
              Temperature
Water_softness High Low Sum
        Soft      4   4   8
        Medium    4   4   8
        Hard      4   4   8
        Sum      12  12  24
> structable(Temperature+M_User~Water_softness, Detergent.df)%>%addmargins()
Error in aperm.default(X, c(s.call, s.ans)) : 
  'perm' is of wrong length 3 (!= 2)
> structable(Temperature+M_User~Water_softness, Detergent.df)
               Temperature High    Low   
               M_User       Yes No Yes No
Water_softness                           
Soft                          2  2   2  2
Medium                        2  2   2  2
Hard                          2  2   2  2
>