You are on page 1of 19

PS C:\Users\Luix_xD\Desktop> R

Set-Location -literalPath 'C:\Users\Luix_xD\Desktop'


PS C:\Users\Luix_xD\Desktop> R
Set-Location -literalPath 'C:\Users\Luix_xD\Desktop'
PS C:\Users\Luix_xD\Desktop> R.exe

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"


Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R es un software libre y viene sin GARANTIA ALGUNA.


Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.


Escriba 'contributors()' para obtener m�s informaci�n y
'citation()' para saber c�mo citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line de ayuda,


o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

[Previously saved workspace restored]

> ls()
[1] "a" "corre" "i" "lty" "notas"
> q()
Guardar imagen de �rea de trabajo? [y/n/c]: n
PS C:\Users\Luix_xD\Desktop> cd..
PS C:\Users\Luix_xD> r.exe

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"


Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R es un software libre y viene sin GARANTIA ALGUNA.


Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.


Escriba 'contributors()' para obtener m�s informaci�n y
'citation()' para saber c�mo citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line de ayuda,


o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

[Previously saved workspace restored]

> ls()
[1] "binomial" "combina"
> binomial()
n= x= p= q= link=
> binomial(5,1,0.1)

0.32805
0.1 0.9
> binomial(5,1:5,0.1)
0.32805 0.0729 0.0081 0.00045 1e-05
0.1 0.9
> binomial(5,1:5,0.1)

0.32805 0.0729 0.0081 0.00045 1e-05


0.1 0.9
> sum(binomial(5,1:5,0.1))

0.32805 0.0729 0.0081 0.00045 1e-05


0.1 0.9
[1] 0
> binomial(5,1:5,0.1))
Error: inesperado ')' in "binomial(5,1:5,0.1))"
> binomial(5,1:5,0.1)

0.32805 0.0729 0.0081 0.00045 1e-05


0.1 0.9
> 0.32805+ 0.0729+ 0.0081+ 0.00045 +1e-05
[1] 0.40951
> binomial(5,2,0.1)

0.0729
0.1 0.9
> 0.32805+ 0.0729+ 0.0081+ 0.00045 +1e-05
[1] 0.40951
> + 0.0729+ 0.0081+ 0.00045 +1e-05
[1] 0.08146
> + 0.0081+ 0.00045 +1e-05
[1] 0.00856
> binomial
function(n, x, p = 1 - q, q = 1 - p){
cat("\n", choose(n,x)*p**x*q**(n-x))
cat("\n", p, q,"\n")
}
<bytecode: 0x000000001d69a8b8>
> binomial <- edit(binomial)
> binomial(5,2,0.1)

0.0729
0.1 0.9

? Se rechaza la H0
> 0.32805+ 0.0729+ 0.0081+ 0.00045 +1e-05
[1] 0.40951
> binomial(5,1:2,0.1)

0.32805 0.0729
0.1 0.9

? Se rechaza la H0
Warning message:
In if (go > level) cat("\n ? Se acepta la H0\n") else cat("\n ? Se rechaza la
H0\n") :
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
> binomial(5,1,0.1)

0.32805
0.1 0.9
? Se rechaza la H0
> binomial(5,1:2,0.1)

0.32805 0.0729
0.1 0.9

? Se rechaza la H0
Warning message:
In if (go > level) cat("\n ? Se acepta la H0\n") else cat("\n ? Se rechaza la
H0\n") :
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
> binomial(5,2,0.1)

0.0729
0.1 0.9

? Se rechaza la H0
> binomial(5,3,0.1)

0.0081
0.1 0.9

? Se rechaza la H0
> binomial(5,4,0.1)

0.00045
0.1 0.9

? Se rechaza la H0
> binomial(5,5,0.1)

1e-05
0.1 0.9

? Se rechaza la H0
> binomial <- edit(binomial)
> binomial(5,5,0.1)

1e-05
0.1 0.9

? Se rechaza la H0
> binomial(5,1,0.1)

0.32805
0.1 0.9

? Se acepta la H0
> binomial(5,1,0.1,level=0.01)

0.32805
0.1 0.9

? Se acepta la H0
> binomial <- edit(binomial)
> arr
arrangeWindows array arrayInd arrows
> array()
[1] NA
> binomial(5,1:5,0.1,level=0.01)
Error in binomial(5, 1:5, 0.1, level = 0.01) :
dims [producto 1] no coincide con la longitud del objeto [5]
> binomial <- edit(binomial)
> binomial(5,1:5,0.1,level=0.01)

0.32805 0.0729 0.0081 0.00045 1e-05


0.1 0.9

? Se acepta la H0
Warning message:
In if (go > level) cat("\n ? Se acepta la H0\n") else cat("\n ? Se rechaza la
H0\n") :
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
> binomial <- edit(binomial)
> binomial(5,1:5,0.1,level=0.01)
[1] 0.40951

0.32805 0.0729 0.0081 0.00045 1e-05


0.1 0.9

? Se acepta la H0
Warning message:
In if (go > level) cat("\n ? Se acepta la H0\n") else cat("\n ? Se rechaza la
H0\n") :
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
> binomial(5,2:5,0.1,level=0.01)
[1] 0.08146

0.0729 0.0081 0.00045 1e-05


0.1 0.9

? Se acepta la H0
Warning message:
In if (go > level) cat("\n ? Se acepta la H0\n") else cat("\n ? Se rechaza la
H0\n") :
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
> binomial(5,3:5,0.1,level=0.01)
[1] 0.00856

0.0081 0.00045 1e-05


0.1 0.9

? Se rechaza la H0
Warning message:
In if (go > level) cat("\n ? Se acepta la H0\n") else cat("\n ? Se rechaza la
H0\n") :
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
> binomial <- edit(binomial)
> binomial(5,2:5,0.1,level=0.01)
[1] 0.08146

0.0729 0.0081 0.00045 1e-05


0.1 0.9

? Se acepta la H0
> binomial(5,5,0.1,level=0.01)
[1] 1e-05
1e-05
0.1 0.9

? Se rechaza la H0
> binomial(90,90,0.75)
[1] 5.695262e-12

5.695262e-12
0.75 0.25

? Se rechaza la H0
> choose
function (n, k)
.Internal(choose(n, k))
<bytecode: 0x000000001dad4228>
<environment: namespace:base>
> binomial(90,90,0.75,)
n= x= p= q= level= link=
> binomial(90,90,0.75)
[1] 5.695262e-12

5.695262e-12
0.75 0.25

? Se rechaza la H0
> 90*0.75
[1] 67.5
> 90*0.75*0.25
[1] 16.875
> binomial <- edit(binomial)
> binomial()
n= x= p= q= level= link=
> binomial(link=F)
Error in binomial(link = F) : unused argument (link = F)
> binomial(link=2)
Error in binomial(link = 2) : unused argument (link = 2)
> binomial(90,90,0.75,lin)
link= line linearizeMlist lines lines.default
> binomial(90,90,0.75,lin)
link= line linearizeMlist lines lines.default
> binomial(90,90,0.75,link=2)
Error in binomial(90, 90, 0.75, link = 2) : unused argument (link = 2)
> binomial(90,90,0.75,link=F)
Error in binomial(90, 90, 0.75, link = F) : unused argument (link = F)
> binomial(90,90,0.75,link=T)
Error in binomial(90, 90, 0.75, link = T) : unused argument (link = T)
> binomial(90,90,0.75)
[1] 5.695262e-12

5.695262e-12
0.75 0.25

? Se rechaza la H0
> binomial(90,1:90,0.75)
[1] 1

1.761832e-52 2.352046e-50 2.0698e-48 1.350545e-46 6.968811e-45 2.961745e-43


1.066228e-41 3.318635e-40 9.070936e-39 2.204237e-37 4.809245e-36 9.498259e-35
1.709687e-33 2.820983e-32 4.287894e-31 6.029851e-30 7.874276e-29 9.580369e-28
1.089137e-26 1.159931e-25 1.159931e-24 1.091389e-23 9.680148e-23 8.107124e-22
6.420842e-21 4.815632e-20 3.424449e-19 2.311503e-18 1.48255e-17 9.043557e-17
5.251098e-16 2.904513e-15 1.531471e-14 7.702397e-14 3.69715e-13 1.694527e-12
7.419282e-12 3.104384e-11 1.241753e-10 4.749707e-10 1.737698e-09 6.081942e-09
2.036743e-08 6.526837e-08 2.001563e-07 5.874153e-07 1.649762e-06 4.433736e-06
1.140103e-05 2.804654e-05 6.599187e-05 0.0001484817 0.0003193757 0.0006564946
0.001289117 0.002417094 0.004325326 0.007382883 0.01201283 0.01861988 0.02747196
0.03854936 0.05139915 0.06505204 0.07806245 0.08870733 0.09532728 0.09672916
0.09252354 0.08327119 0.07037002 0.0557096 0.04120984 0.02840137 0.01817688
0.01076263 0.005870523 0.002935262 0.001337588 0.0005517549 0.0002043537 6.728718e-
05 1.945653e-05 4.864134e-06 1.030052e-06 1.796602e-07 2.478072e-08 2.534392e-09
1.708579e-10 5.695262e-12
0.75 0.25

? Se acepta la H0
> binomial(90,3:90,0.75)
[1] 1

2.0698e-48 1.350545e-46 6.968811e-45 2.961745e-43 1.066228e-41 3.318635e-40


9.070936e-39 2.204237e-37 4.809245e-36 9.498259e-35 1.709687e-33 2.820983e-32
4.287894e-31 6.029851e-30 7.874276e-29 9.580369e-28 1.089137e-26 1.159931e-25
1.159931e-24 1.091389e-23 9.680148e-23 8.107124e-22 6.420842e-21 4.815632e-20
3.424449e-19 2.311503e-18 1.48255e-17 9.043557e-17 5.251098e-16 2.904513e-15
1.531471e-14 7.702397e-14 3.69715e-13 1.694527e-12 7.419282e-12 3.104384e-11
1.241753e-10 4.749707e-10 1.737698e-09 6.081942e-09 2.036743e-08 6.526837e-08
2.001563e-07 5.874153e-07 1.649762e-06 4.433736e-06 1.140103e-05 2.804654e-05
6.599187e-05 0.0001484817 0.0003193757 0.0006564946 0.001289117 0.002417094
0.004325326 0.007382883 0.01201283 0.01861988 0.02747196 0.03854936 0.05139915
0.06505204 0.07806245 0.08870733 0.09532728 0.09672916 0.09252354 0.08327119
0.07037002 0.0557096 0.04120984 0.02840137 0.01817688 0.01076263 0.005870523
0.002935262 0.001337588 0.0005517549 0.0002043537 6.728718e-05 1.945653e-05
4.864134e-06 1.030052e-06 1.796602e-07 2.478072e-08 2.534392e-09 1.708579e-10
5.695262e-12
0.75 0.25

? Se acepta la H0
> binomial(90,1:2,0.75)
[1] 2.369664e-50

1.761832e-52 2.352046e-50
0.75 0.25

? Se rechaza la H0
> 90*0.75*0.25
[1] 16.875
> 90*0.75
[1] 67.5
> ((90-0.5)-67.5)/sqrt(16.875)
[1] 5.355509
> binomial <- edit(binomial)
> binomial(90,3:90,0.75)
ota> binomial(29,3:90,0.75)
[1] 1

3.422887e-13 6.67463e-12 1.001194e-10 1.201433e-09 1.18427e-08 9.770227e-08


6.839159e-07 4.103496e-06 2.126357e-05 9.568605e-05 0.0003753838 0.00128703
0.00386109 0.01013536 0.02325171 0.04650342 0.0807691 0.1211537 0.155769 0.1699298
0.1551533 0.116365 0.06981898 0.03222415 0.01074138 0.002301725 0.0002381095 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0.75 0.25

? Se acepta la H0
> binomial(90,3:90,0.75)
ota> binomial <- edit(binomial)
> binomial(90,90,0.75)
ota> binomial <- edit(binomial)
> binomial(90,90,0.75)

5.355509> binomial <- edit(binomial)


> binomial(90,90,0.75)

5.355509> binomial(90,90,0.75)

5.355509> binomial
function(n, x, p = 1 - q, q = 1 - p, level = 0.05){
if(n>30)
{
if(x > (n*p))
z <- ((x-0.5)-(n*p))/sqrt(n*p*q)
else z <- ((x+0.5)-(n*p))/sqrt(n*p*q)
cat ("\n",z)
}else{
go <- choose(n,x)*p**x*q**(n-x)
su <- sum(go)
print(su)
cat("\n", go)
cat("\n", p, q,"\n")
if(su > level ) cat("\n ? Se acepta la H0\n")
else cat("\n ? Se rechaza la H0\n")
}
}
<bytecode: 0x000000000690d660>
> binomial <- edit(binomial)
> q()
Guardar imagen de �rea de trabajo? [y/n/c]: y
PS C:\Users\Luix_xD> r
r.exe
r : Error fatal: se debe especificar '--save',
'--no-save' o '--vanilla'
En l�nea: 1 Car�cter: 1
+ r
+ ~
+ CategoryInfo : NotSpecified: (Err
or fatal: se...' o '--vanilla':String) [Invo
ke-History], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
,Microsoft.PowerShell.Commands.InvokeHistory
Command

r :
En l�nea: 1 Car�cter: 1
+ r
+ ~
+ CategoryInfo : NotSpecified: (:)
[Invoke-History], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Message,Microsoft.PowerShell.Commands.Invoke
HistoryCommand

PS C:\Users\Luix_xD> R.exe

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"


Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R es un software libre y viene sin GARANTIA ALGUNA.


Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.


Escriba 'contributors()' para obtener m�s informaci�n y
'citation()' para saber c�mo citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line de ayuda,


o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

[Previously saved workspace restored]

> ls()
[1] "binomial" "combina"
> binomial
function(n, x, p = 1 - q, q = 1 - p, level = 0.05){
if(n>30)
{
if(x > (n*p))
z <- ((x-0.5)-(n*p))/sqrt(n*p*q)
else z <- ((x+0.5)-(n*p))/sqrt(n*p*q)
cat ("\n",z,"\n")

}else{
go <- choose(n,x)*p**x*q**(n-x)
su <- sum(go)
print(su)
cat("\n", go)
cat("\n", p, q,"\n")
if(su > level ) cat("\n ? Se acepta la H0\n")
else cat("\n ? Se rechaza la H0\n")
}
}
> scan()
1: 12
2: 1231
3: 13212
4: 123
5: 12
6: 3423
7: 456
8: 34
9: 45
10: 34
11:
Read 10 items
[1] 12 1231 13212 123 12 3423 456 34 45 34
> jitter
function (x, factor = 1, amount = NULL)
{
if (length(x) == 0L)
return(x)
if (!is.numeric(x))
stop("'x' must be numeric")
z <- diff(r <- range(x[is.finite(x)]))
if (z == 0)
z <- abs(r[1L])
if (z == 0)
z <- 1
if (is.null(amount)) {
d <- diff(xx <- unique(sort.int(round(x, 3 - floor(log10(z))))))
d <- if (length(d))
min(d)
else if (xx != 0)
xx/10
else z/10
amount <- factor/5 * abs(d)
}
else if (amount == 0)
amount <- factor * (z/50)
x + stats::runif(length(x), -amount, amount)
}
<bytecode: 0x000000001de7cc18>
<environment: namespace:base>
> sum(1,2)
[1] 3
> sum(1,2,3)
[1] 6
> sum()
...= na.rm=
> sum()
...= na.rm=
> sum
function (..., na.rm = FALSE) .Primitive("sum")
> for(i in c(4,8,2,2,4)) {
+ (i-4)**2/4}
> for(i in c(4,8,2,2,4)) {
+ a<-(i-4)**2/4;sum(a)}
> a<-(i-4)**2/4;print(sum(a))}
Error: inesperado '}' in "print(sum(a))}"
> a<-(i-4)**2/4;print(sum(a))}
Error: inesperado '}' in "print(sum(a))}"
> a<-(i-4)**2/4 ; print(a)}
Error: inesperado '}' in " print(a)}"
> for(i in c(4,8,2,2,4)) {
+ a<-(i-4)**2/4;print(sum(a))}
[1] 0
[1] 4
[1] 1
[1] 1
[1] 0
> for(i in c(4,8,2,2,4)) {
+ a<-(i-4)**2/4;print(sum(a))}
[1] 0
[1] 4
[1] 1
[1] 1
[1] 0
> a<-(i-4)**2/4;print(sum(a))}
Error: inesperado '}' in "print(sum(a))}"
> sum(a)
[1] 0
> a<-(i-4)**2/4 + a;print(sum(a))}
Error: inesperado '}' in "print(sum(a))}"
> for(i in c(4,8,2,2,4)) {
+ a<-(i-4)**2/4 + a;print(sum(a))}
[1] 0
[1] 4
[1] 5
[1] 6
[1] 6
> for(i in c(4,8,2,2,4)) {
+ a = 0; a<-(i-4)**2/4 + a;print((a))}
[1] 0
[1] 4
[1] 1
[1] 1
[1] 0
> a<-(i-4)**2/4;print((a))
[1] 0
> for(i in c(4,8,2,2,4)) {
+ a<-(i-4)**2/4;print((a))}
[1] 0
[1] 4
[1] 1
[1] 1
[1] 0
> a
[1] 0
> a<-sum(i-4)**2/4;print((a))}
Error: inesperado '}' in "print((a))}"
> for(i in c(4,8,2,2,4)) {
+ a<-sum(i-4)**2/4;print((a))}
[1] 0
[1] 4
[1] 1
[1] 1
[1] 0
> a<-sum((i-4)**2/4);print((a))}
Error: inesperado '}' in "print((a))}"
> for(i in c(4,8,2,2,4)) {
+ a<-sum((i-4)**2/4);print((a))}
[1] 0
[1] 4
[1] 1
[1] 1
[1] 0
> chi
chickwts chisq.test
> chi
chickwts chisq.test
> chi
chickwts chisq.test
> chisq.test
function (x, y = NULL, correct = TRUE, p = rep(1/length(x), length(x)),
rescale.p = FALSE, simulate.p.value = FALSE, B = 2000)
{
DNAME <- deparse(substitute(x))
if (is.data.frame(x))
x <- as.matrix(x)
if (is.matrix(x)) {
if (min(dim(x)) == 1L)
x <- as.vector(x)
}
if (!is.matrix(x) && !is.null(y)) {
if (length(x) != length(y))
stop("'x' and 'y' must have the same length")
DNAME2 <- deparse(substitute(y))
xname <- if (length(DNAME) > 1L || nchar(DNAME, "w") >
30)
""
else DNAME
yname <- if (length(DNAME2) > 1L || nchar(DNAME2, "w") >
30)
""
else DNAME2
OK <- complete.cases(x, y)
x <- factor(x[OK])
y <- factor(y[OK])
if ((nlevels(x) < 2L) || (nlevels(y) < 2L))
stop("'x' and 'y' must have at least 2 levels")
x <- table(x, y)
names(dimnames(x)) <- c(xname, yname)
DNAME <- paste(paste(DNAME, collapse = "\n"), "and",
paste(DNAME2, collapse = "\n"))
}
if (any(x < 0) || anyNA(x))
stop("all entries of 'x' must be nonnegative and finite")
if ((n <- sum(x)) == 0)
stop("at least one entry of 'x' must be positive")
if (simulate.p.value) {
setMETH <- function() METHOD <<- paste(METHOD, "with simulated p-value\n\t
(based on",
B, "replicates)")
almost.1 <- 1 - 64 * .Machine$double.eps
}
if (is.matrix(x)) {
METHOD <- "Pearson's Chi-squared test"
nr <- as.integer(nrow(x))
nc <- as.integer(ncol(x))
if (is.na(nr) || is.na(nc) || is.na(nr * nc))
stop("invalid nrow(x) or ncol(x)", domain = NA)
sr <- rowSums(x)
sc <- colSums(x)
E <- outer(sr, sc, "*")/n
v <- function(r, c, n) c * r * (n - r) * (n - c)/n^3
V <- outer(sr, sc, v, n)
dimnames(E) <- dimnames(x)
if (simulate.p.value && all(sr > 0) && all(sc > 0)) {
setMETH()
tmp <- .Call(C_chisq_sim, sr, sc, B, E)
STATISTIC <- sum(sort((x - E)^2/E, decreasing = TRUE))
PARAMETER <- NA
PVAL <- (1 + sum(tmp >= almost.1 * STATISTIC))/(B +
1)
}
else {
if (simulate.p.value)
warning("cannot compute simulated p-value with zero marginals")
if (correct && nrow(x) == 2L && ncol(x) == 2L) {
YATES <- min(0.5, abs(x - E))
if (YATES > 0)
METHOD <- paste(METHOD, "with Yates' continuity correction")
}
else YATES <- 0
STATISTIC <- sum((abs(x - E) - YATES)^2/E)
PARAMETER <- (nr - 1L) * (nc - 1L)
PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
}
}
else {
if (length(dim(x)) > 2L)
stop("invalid 'x'")
if (length(x) == 1L)
stop("'x' must at least have 2 elements")
if (length(x) != length(p))
stop("'x' and 'p' must have the same number of elements")
if (any(p < 0))
stop("probabilities must be non-negative.")
if (abs(sum(p) - 1) > sqrt(.Machine$double.eps)) {
if (rescale.p)
p <- p/sum(p)
else stop("probabilities must sum to 1.")
}
METHOD <- "Chi-squared test for given probabilities"
E <- n * p
V <- n * p * (1 - p)
STATISTIC <- sum((x - E)^2/E)
names(E) <- names(x)
if (simulate.p.value) {
setMETH()
nx <- length(x)
sm <- matrix(sample.int(nx, B * n, TRUE, prob = p),
nrow = n)
ss <- apply(sm, 2L, function(x, E, k) {
sum((table(factor(x, levels = 1L:k)) - E)^2/E)
}, E = E, k = nx)
PARAMETER <- NA
PVAL <- (1 + sum(ss >= almost.1 * STATISTIC))/(B +
1)
}
else {
PARAMETER <- length(x) - 1
PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
}
}
names(STATISTIC) <- "X-squared"
names(PARAMETER) <- "df"
if (any(E < 5) && is.finite(PARAMETER))
warning("Chi-squared approximation may be incorrect")
structure(list(statistic = STATISTIC, parameter = PARAMETER,
p.value = PVAL, method = METHOD, data.name = DNAME, observed = x,
expected = E, residuals = (x - E)/sqrt(E), stdres = (x -
E)/sqrt(V)), class = "htest")
}
<bytecode: 0x000000000acf3f10>
<environment: namespace:stats>
> chisq.test()
Error in is.data.frame(x) :
el argumento "x" est� ausente, sin valor por omisi�n
> chisq.test()
x= y= correct= p=
rescale.p= simulate.p.value= B=
> ?chisq.test()
starting httpd help server ... done
> M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
> dimnames(M) <- list(gender = c("F", "M"),
+ party = c("Democrat","Independent", "Republican"))
> (Xsq <- chisq.test(M)) # Prints test summary

Pearson's Chi-squared test

data: M
X-squared = 30.07, df = 2, p-value = 2.954e-07

> m
Error: objeto 'm' no encontrado
> M
party
gender Democrat Independent Republican
F 762 327 468
M 484 239 477
> class(M)
[1] "table"
> try
function (expr, silent = FALSE, outFile = getOption("try.outFile",
default = stderr()))
{
tryCatch(expr, error = function(e) {
call <- conditionCall(e)
if (!is.null(call)) {
if (identical(call[[1L]], quote(doTryCatch)))
call <- sys.call(-4L)
dcall <- deparse(call)[1L]
prefix <- paste("Error in", dcall, ": ")
LONG <- 75L
msg <- conditionMessage(e)
sm <- strsplit(msg, "\n")[[1L]]
w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L],
type = "w")
if (is.na(w))
w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
type = "b")
if (w > LONG)
prefix <- paste0(prefix, "\n ")
}
else prefix <- "Error : "
msg <- paste0(prefix, conditionMessage(e), "\n")
.Internal(seterrmessage(msg[1L]))
if (!silent && identical(getOption("show.error.messages"),
TRUE)) {
cat(msg, file = outFile)
.Internal(printDeferredWarnings())
}
invisible(structure(msg, class = "try-error", condition = e))
})
}
<bytecode: 0x000000001cdbac70>
<environment: namespace:base>
> try()
Error in tryCatch(expr, error = function(e) { :
el argumento "expr" est� ausente, sin valor por omisi�n
> try(
+ chisq.test(x, p = p) # gives an error
+ )
Error in is.data.frame(x) : objeto 'x' no encontrado
> chisq.test(x, p = p) # gives an etry(
> try(
+ chisq.test(x, p = p) # gives an error
+ )
Error in is.data.frame(x) : objeto 'x' no encontrado
> chisq.test(x, p = p) # gives an etry(
try(
+ chisq.test(x, p = p) # gives an error
+ )
+ %%
+ %<%
Error: inesperado SPECIAL in:
"%%
%<%"
> %>%
Error: inesperado SPECIAL in "%>%"
> %>%
Error: inesperado SPECIAL in "%>%"
> %<%
Error: inesperado SPECIAL in "%<%"
> chisq
Error: objeto 'chisq' no encontrado
> chi
chickwts chisq.test
> chickwts
weight feed
1 179 horsebean
2 160 horsebean
3 136 horsebean
4 227 horsebean
5 217 horsebean
6 168 horsebean
7 108 horsebean
8 124 horsebean
9 143 horsebean
10 140 horsebean
11 309 linseed
12 229 linseed
13 181 linseed
14 141 linseed
15 260 linseed
16 203 linseed
17 148 linseed
18 169 linseed
19 213 linseed
20 257 linseed
21 244 linseed
22 271 linseed
23 243 soybean
24 230 soybean
25 248 soybean
26 327 soybean
27 329 soybean
28 250 soybean
29 193 soybean
30 271 soybean
31 316 soybean
32 267 soybean
33 199 soybean
34 171 soybean
35 158 soybean
36 248 soybean
37 423 sunflower
38 340 sunflower
39 392 sunflower
40 339 sunflower
41 341 sunflower
42 226 sunflower
43 320 sunflower
44 295 sunflower
45 334 sunflower
46 322 sunflower
47 297 sunflower
48 318 sunflower
49 325 meatmeal
50 257 meatmeal
51 303 meatmeal
52 315 meatmeal
53 380 meatmeal
54 153 meatmeal
55 263 meatmeal
56 242 meatmeal
57 206 meatmeal
58 344 meatmeal
59 258 meatmeal
60 368 casein
61 390 casein
62 379 casein
63 260 casein
64 404 casein
65 318 casein
66 352 casein
67 359 casein
68 216 casein
69 222 casein
70 283 casein
71 332 casein
> chisq.test(x, p = p) # gives an e)
>
>
> dchisq
function (x, df, ncp = 0, log = FALSE)
{
if (missing(ncp))
.Call(C_dchisq, x, df, log)
else .Call(C_dnchisq, x, df, ncp, log)
}
<bytecode: 0x000000000ad9ad88>
<environment: namespace:stats>
> ?dchisq()
> Z0 <- rchisq(100, df = 0, ncp = 2.)
> z0
Error: objeto 'z0' no encontrado
> zO
Error: objeto 'zO' no encontrado
> zo
Error: objeto 'zo' no encontrado
> Z0
[1] 3.17468804 3.02134101 5.84739476 8.34405998 2.12459014 3.91412032
[7] 0.00000000 4.70664472 0.34610170 0.47787403 0.00000000 0.00000000
[13] 0.00000000 2.45261923 3.15310957 9.20299921 0.00000000 0.00000000
[19] 8.43718189 1.50339009 0.00000000 0.00000000 3.53832556 0.01011589
[25] 0.00000000 0.00000000 0.87440078 0.00000000 0.00000000 0.39042476
[31] 0.64917995 4.49246605 0.00000000 0.00000000 0.00000000 0.00000000
[37] 1.06074790 0.00000000 0.00000000 0.00000000 2.81148440 1.14091721
[43] 0.72365324 0.01278537 0.00000000 0.00000000 0.00000000 5.27182300
[49] 0.00000000 2.85195689 3.09034279 0.00000000 1.15525202 3.22246888
[55] 0.00000000 0.00000000 2.41983228 0.61793950 0.00000000 0.00000000
[61] 5.22131279 0.00000000 0.40466356 6.70845661 0.00000000 0.00000000
[67] 3.44785390 0.00000000 0.29923380 5.01027217 0.51333107 0.00000000
[73] 0.00000000 2.05910563 0.00000000 0.00000000 4.89860543 0.00000000
[79] 0.00000000 1.02115265 0.11576413 3.68888894 0.00000000 1.73174536
[85] 4.53028946 0.00000000 0.00000000 0.00000000 2.33164660 4.27941758
[91] 1.82253371 5.58234278 5.66019767 2.45990268 3.66344435 2.28659398
[97] 0.00000000 0.00000000 6.13063233 1.22040870
> Z0 <- rchisq(100, df = 4, ncp = 2.)
> rchisq(100, df = 4, ncp = 2.)
[1] 5.6886556 2.9325299 5.2024570 0.8568114 15.3232557 5.3617725
[7] 6.3570722 7.6320101 7.2500683 7.4234641 6.9113019 10.6287059
[13] 4.6049907 1.8128854 5.2070214 9.6706869 6.9888815 1.9665522
[19] 9.2021346 10.7847117 9.6697566 5.5356577 1.1270793 5.8219829
[25] 10.4457117 4.0252941 3.4438476 5.2039508 6.8310029 6.0431433
[31] 3.2084289 6.9342677 2.0835015 6.7245028 2.3585315 5.4642910
[37] 1.7960344 2.2791457 1.7102645 9.6086313 8.5504168 3.3227809
[43] 7.1695441 7.0173527 5.1016311 4.4938289 4.6123939 1.4172567
[49] 5.3268688 1.7818756 2.9720552 4.7277195 12.3104049 1.8613613
[55] 3.1335261 7.5865718 2.7323445 7.1012968 3.7057637 4.1132163
[61] 3.3572324 6.8087926 13.2216767 4.1002464 10.4608516 1.6569774
[67] 4.3716459 0.3755435 11.2615629 14.7322311 1.6753322 9.5421621
[73] 6.0586097 4.4701671 5.3176927 10.1961723 11.3466892 8.8528774
[79] 8.3591191 6.8619753 11.8298685 7.9175253 3.2986638 8.2763157
[85] 9.7926725 1.2329085 14.5712266 7.9483415 0.3950020 14.3071111
[91] 2.5634080 7.3366833 0.4965348 2.5727562 6.2015742 3.0710700
[97] 1.9502389 6.9174724 3.7946634 9.3976036
> rchisq(100, df = 4, ncp = 2.)
[1] 4.5350706 10.9346695 4.0448467 3.6125944 7.9407853 4.7564805
[7] 1.6518579 2.6451972 6.3140087 3.4138495 1.7895980 2.9765165
[13] 2.2889534 4.5371374 1.3098082 7.2564269 8.6245301 12.6558309
[19] 1.4180762 4.4971879 3.2209785 5.6730621 2.7891548 3.5448908
[25] 10.8746249 2.3231659 4.8987521 7.1276467 6.0112915 4.2663666
[31] 5.5704033 5.7176400 6.9147589 1.7097233 13.9127989 5.2138566
[37] 5.3471464 4.4619166 9.5724677 8.5074268 3.4178051 5.5184697
[43] 4.3527835 6.5546721 2.7275586 7.0540381 11.1345458 1.6649901
[49] 8.3628832 1.9040378 9.5765541 7.1947196 4.8959441 7.0716865
[55] 8.4799320 17.8143181 8.6909272 3.3612653 6.9737694 1.0089475
[61] 6.1852438 8.1757480 5.2403706 11.1223322 1.0087086 6.5142274
[67] 11.3406455 3.1096453 1.5376352 8.5330789 4.9366471 6.1665521
[73] 0.8842883 8.4814170 4.8629583 0.8268696 7.8000279 7.0543509
[79] 3.9801589 5.7844265 7.2403792 8.1529421 4.5289058 14.2049051
[85] 17.1701710 13.3107441 3.5825719 5.6017042 5.1837120 0.9221051
[91] 6.4375272 3.5322208 8.6555868 4.0430470 0.3224223 7.3301040
[97] 10.9312111 5.3370740 1.8063593 4.2491151
> rchisq(6, df = 4, ncp = 2.)
[1] 10.967492 3.070864 4.262878 8.027533 2.430991 19.234833
> rchisq(6, df = 4)
[1] 1.2530940 3.1833391 0.4947035 0.3950518 2.4306224 0.9595288
> library(Rcmdr)
Loading required package: splines
Loading required package: RcmdrMisc
Loading required package: car
Loading required package: sandwich
Loading required package: effects
Loading required package: carData

Attaching package: 'carData'

The following objects are masked from 'package:car':

Guyer, UN, Vocab

lattice theme set by effectsTheme()


See ?effectsTheme for details.

Versi�n del Rcmdr 2.4-2

> pchisq(6, df=4, lower.tail=FALSE)


[1] 0.1991483
> pchisq(6, df=4)
[1] 0.8008517
> pchisq(6, df=4, lower.tail=FALSE)
[1] 0.1991483
> pchisq(6, df=4, lower.tail=T)
[1] 0.8008517
> pchisq(6, df=4, lower.tail=F)
[1] 0.1991483
> pchisq(5.54, df=4, lower.tail=F)
[1] 0.2362358
> a<-c(1/2)
> a
[1] 0.5
> a<-c(1/5,2/5,3/5,4/5,1)
> b<-c(4/20,12/20,14/20,16/20,1)
> abs(a-b)
[1] 0.0 0.2 0.1 0.0 0.0
> length(a,b)
Error in length(a, b) : 2 arguments passed to 'length' which requires 1
> length(a)
[1] 5
> length(b)
[1] 5
> abs(a-b)
[1] 0.0 0.2 0.1 0.0 0.0
> abs(sum(a)-sum(b))
[1] 0.3
> max(abs(a-b))
[1] 0.2
> k
kappa kappa.default kappa.lm kappa.qr kernapply
kernel kernHAC kmeans knitrP knots
kronecker kruskal.test ks.test ksmooth kweights
knitr::
> tools::
tools::vignetteDepends
tools::SIGHUP
tools::checkTnF
tools::SIGSTOP
tools::xgettext
tools::parseLatex
tools::texi2pdf
tools::checkRdaFiles
tools::SIGCONT
tools::read.00Index

[...truncated]
> tools::
tools::vignetteDepends
tools::SIGHUP
tools::checkTnF
tools::SIGSTOP
tools::xgettext
tools::parseLatex
tools::texi2pdf
tools::checkRdaFiles
tools::SIGCONT
tools::read.00Index

[...truncated]
> min(abs(a-b))
[1] 0
> min}
Error: inesperado '}' in "min}"
> min
function (..., na.rm = FALSE) .Primitive("min")
> max
function (..., na.rm = FALSE) .Primitive("max")
> max(abs(a-b))
[1] 0.2
> tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8) 21.9)
Error: unexpected numeric constant in "tres <- c(21.6 13.4"
> tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 max(abs(a-b))
tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 21
tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 21max(abs(a-b))
)
[1] 0.2

> tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 21.9
Error: unexpected numeric constant in "tres <- c(21.6 13.4"
> tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 max(abs(a-b))
tres <- c(21.6 13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 21tres <- c(21.6
13.4 20.4 16.4 23.5 26.8 24.8 19.3 23.4 9.4 16.8 21max(abs(a-b))
length(a,b)
Error in length(a, b) : 2 arguments passed to 'length' which requires 1
> tres<-c(21.6 ,13.4, 20.4 ,16.4 ,23.5 ,26.8 ,24.8 ,19.3 ,23.4, 9.4 ,16.8, 21.9
+ 24.9, 15.6 ,20.1 ,16.2 ,18.7 ,18.1, 19.1, 18.1)
Error: unexpected numeric constant in:
"tres<-c(21.6 ,13.4, 20.4 ,16.4 ,23.5 ,26.8 ,24.8 ,19.3 ,23.4, 9.4 ,16.8, 21.9
24.9"
> tres<-c(21.6 ,13.4, 20.4 ,16.4 ,23.5 ,26.8 ,24.8 ,19.3 ,23.4, 9.$.4 ,23.5 ,26.8 ,
24.8 ,19.3 ,23.4, 9.4 ,16.8, 21.9, tres<-c(21.6 ,13.4, 20.4 ,16.4 ,
23.5 ,26.8 ,24.8 ,19.3 ,23.4, 9.4 ,16.8, 21.$
+ 24.9, 15.6 ,20.1 ,16.2 ,18.7 ,18.1, 19.1, 18.1)
> summary(tres)
Min. 1st Qu. Median Mean 3rd Qu. Max.
9.40 16.70 19.20 19.43 22.27 26.80
> length(tres)
[1] 20
> sort(tres)
[1] 9.4 13.4 15.6 16.2 16.4 16.8 18.1 18.1 18.7 19.1 19.3 20.1 20.4 21.6 21.9
[16] 23.4 23.5 24.8 24.9 26.8
> tres[tres>19.20]
[1] 21.6 20.4 23.5 26.8 24.8 19.3 23.4 21.9 24.9 20.1
> [tres>19.20]
Error: inesperado '[' in "["
> tres>19.20
[1] TRUE FALSE TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE TRUE
[13] TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
> tres>median(tres)
[1] TRUE FALSE TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE TRUE
[13] TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
> moment

You might also like