You are on page 1of 16

CODIGO COMPLETO 1 Y 2

> x <- c (3.1 ,4.9 ,2.8 ,3.6 ,4.5 ,3.5 ,2.8 ,4.1 ,2.9 ,2.1 ,3.7 ,4.1 ,2.7 ,4.2 ,
3.5 ,3.7 ,3.8 ,2.2 ,4.4 ,2.9 ,5.1 ,1.8 ,2.5 ,6.2 ,2.5 ,3.6 ,5.6 ,4.8 ,3.6 ,6.1,
5.1, 3.9, 4.3, 5.7, 4.7, 4.6, 5.1, 4.9, 4.2, 3.1)
>x
[1] 3.1 4.9 2.8 3.6 4.5 3.5 2.8 4.1 2.9 2.1 3.7 4.1 2.7 4.2 3.5 3.7
[17] 3.8 2.2 4.4 2.9 5.1 1.8 2.5 6.2 2.5 3.6 5.6 4.8 3.6 6.1 5.1 3.9
[33] 4.3 5.7 4.7 4.6 5.1 4.9 4.2 3.1
> m <- c(1.5,2.5,3.5,4.5,5.5,6.5)
> mp <- c(0.5,m,7.5)
> mp
[1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5
> q=hist(x,m)
>q
$breaks
[1] 1.5 2.5 3.5 4.5 5.5 6.5

$counts
[1] 5 9 14 8 4

$density
[1] 0.125 0.225 0.350 0.200 0.100

$mids
[1] 2 3 4 5 6

$xname
[1] "x"

$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
> q=hist(x,6,m)
Warning messages:
1: In if (freq) x$counts else x$density :
la condici'on tiene longitud > 1 y s'olo el primer elemento ser'a usado
2: In if (!freq) "Density" else "Frequency" :
la condici'on tiene longitud > 1 y s'olo el primer elemento ser'a usado
>q
$breaks
[1] 1 2 3 4 5 6 7

$counts
[1] 1 9 11 12 5 2

$density
[1] 0.025 0.225 0.275 0.300 0.125 0.050

$mids
[1] 1.5 2.5 3.5 4.5 5.5 6.5

$xname
[1] "x"

$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
> fa <- c(0,1,9,11,12,5,2,0)
> mp
[1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5
> lines(fa,mp)
> lines(mp,fa)
>
>
>
>
>
>
> c <- c(1,2,3,4,5,6,7)
> f=hist(x,m)
>q
$breaks
[1] 1 2 3 4 5 6 7
$counts
[1] 1 9 11 12 5 2

$density
[1] 0.025 0.225 0.275 0.300 0.125 0.050

$mids
[1] 1.5 2.5 3.5 4.5 5.5 6.5

$xname
[1] "x"

$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
> F=cumsum(q)
Error: el objeto (list) no puede ser coercionado a 'double'
> q <- c(1,9,11,12,5,2)
> F=cumsum(q)
>F
[1] 1 10 21 33 38 40
> Fo <- c(0,F)
> plot(c,Fo)
> lines(c,Fo)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> persp(c,Fo)
Error in persp.default(c, Fo) : argumento 'z' inv'alido
> persp(c,fa)
Error in persp.default(c, fa) : increasing 'x' and 'y' values expected
> hist(x,m)
> hist(x,6,m)
Warning messages:
1: In if (freq) x$counts else x$density :
la condici'on tiene longitud > 1 y s'olo el primer elemento ser'a usado
2: In if (!freq) "Density" else "Frequency" :
la condici'on tiene longitud > 1 y s'olo el primer elemento ser'a usado
> persp(x,6,m)
Error in persp.default(x, 6, m) : increasing 'x' and 'y' values expected
> persp(hist(x,6,m))
Error in persp.default(hist(x, 6, m)) : argumento 'x' inv'alido
Adem'as: Warning messages:
1: In if (freq) x$counts else x$density :
la condici'on tiene longitud > 1 y s'olo el primer elemento ser'a usado
2: In if (!freq) "Density" else "Frequency" :
la condici'on tiene longitud > 1 y s'olo el primer elemento ser'a usado
3: In is.na(z) :
is.na() aplicado a un objeto que no es (lista o vector) de tipo 'NULL
4: In min(x, na.rm = na.rm) :
ning'un argumento finito para min; retornando Inf
5: In max(x, na.rm = na.rm) :
ningun argumento finito para max; retornando -Inf
6: In min(x, na.rm = na.rm) :
ning'un argumento finito para min; retornando Inf
7: In max(x, na.rm = na.rm) :
ningun argumento finito para max; retornando -Inf
8: In persp.default(hist(x, 6, m)) : NAs introducidos por coerci'on
>
> persp(hist(x,m))
Error in persp.default(hist(x, m)) : argumento 'x' inv'alido
Adem'as: Warning messages:
1: In is.na(z) :
is.na() aplicado a un objeto que no es (lista o vector) de tipo 'NULL
2: In min(x, na.rm = na.rm) :
ning'un argumento finito para min; retornando Inf
3: In max(x, na.rm = na.rm) :
ningun argumento finito para max; retornando -Inf
4: In min(x, na.rm = na.rm) :
ning'un argumento finito para min; retornando Inf
5: In max(x, na.rm = na.rm) :
ningun argumento finito para max; retornando -Inf
6: In persp.default(hist(x, m)) : NAs introducidos por coerci'on
>
>
>
>
>
>
>
>
>
>
>
>
> hist3D(x,6,m)
Error: no se pudo encontrar la funci'on "hist3D"
> example("persp")

persp> require(grDevices) # for trans3d

persp> ## More examples in demo(persp) !!


persp> ## -----------
persp>
persp> # (1) The Obligatory Mathematical surface.
persp> # Rotated sinc function.
persp>
persp> x <- seq(-10, 10, length= 30)

persp> y <- x

persp> f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }

persp> z <- outer(x, y, f)


persp> z[is.na(z)] <- 1

persp> op <- par(bg = "white")

persp> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col =


"lightblue")
<Enter> para ver el pr'oximo gr'afico:

persp> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col =


"lightblue",
persp+ ltheta = 120, shade = 0.75, ticktype = "detailed",
persp+ xlab = "X", ylab = "Y", zlab = "Sinc( r )"
persp+ ) -> res
<Enter> para ver el pr'oximo gr'afico:

persp> round(res, 3)
[,1] [,2] [,3] [,4]
[1,] 0.087 -0.025 0.043 -0.043
[2,] 0.050 0.043 -0.075 0.075
[3,] 0.000 0.074 0.042 -0.042
[4,] 0.000 -0.273 -2.890 3.890

persp> # (2) Add to existing persp plot - using trans3d() :


persp>
persp> xE <- c(-10,10); xy <- expand.grid(xE, xE)

persp> points(trans3d(xy[,1], xy[,2], 6, pmat = res), col = 2, pch = 16)

persp> lines (trans3d(x, y = 10, z = 6 + sin(x), pmat = res), col = 3)

persp> phi <- seq(0, 2*pi, len = 201)

persp> r1 <- 7.725 # radius of 2nd maximum

persp> xr <- r1 * cos(phi)

persp> yr <- r1 * sin(phi)

persp> lines(trans3d(xr,yr, f(xr,yr), res), col = "pink", lwd = 2)


persp> ## (no hidden lines)
persp>
persp> # (3) Visualizing a simple DEM model
persp>
persp> z <- 2 * volcano # Exaggerate the relief

persp> x <- 10 * (1:nrow(z)) # 10 meter spacing (S to N)

persp> y <- 10 * (1:ncol(z)) # 10 meter spacing (E to W)

persp> ## Don't draw the grid lines : border = NA


persp> par(bg = "slategray")

persp> persp(x, y, z, theta = 135, phi = 30, col = "green3", scale =


FALSE,
persp+ ltheta = -120, shade = 0.75, border = NA, box = FALSE)
<Enter> para ver el pr'oximo gr'afico:

persp> # (4) Surface colours corresponding to z-values


persp>
persp> par(bg = "white")

persp> x <- seq(-1.95, 1.95, length = 30)

persp> y <- seq(-1.95, 1.95, length = 35)

persp> z <- outer(x, y, function(a, b) a*b^2)

persp> nrz <- nrow(z)

persp> ncz <- ncol(z)

persp> # Create a function interpolating colors in the range of specified


colors
persp> jet.colors <- colorRampPalette( c("blue", "green") )

persp> # Generate the desired number of colors from this palette


persp> nbcol <- 100

persp> color <- jet.colors(nbcol)


persp> # Compute the z-value at the facet centres
persp> zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]

persp> # Recode facet z-values into color indices


persp> facetcol <- cut(zfacet, nbcol)

persp> persp(x, y, z, col = color[facetcol], phi = 30, theta = -30)


<Enter> para ver el pr'oximo gr'afico:

persp> par(op)
>
>
>
> install.packages("scatterplot3d")
Installing package into '/Users/Camila/Library/R/3.3/library'
(as 'lib' is unspecified)
probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/scatterplot3d
_0.3-40.tgz'
Content type 'application/x-gzip' length 304642 bytes (297 KB)
===========================================
=======
downloaded 297 KB

tar: Failed to set default locale

The downloaded binary packages are in


/
var/folders/hc/c3thc0rj3vgfgwy7cjnld_r80000gp/T//RtmpwVwxSN/downlo
aded_packages
> library(scatterplot3d)
> scatterplot3d(x,m)
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, :
'x', 'y' and 'z' lengths differ
> scatterplot3d(fa,m)
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, :
'x', 'y' and 'z' lengths differ
> scatterplot3d(fa,q)
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, :
'x', 'y' and 'z' lengths differ
> scatterplot3d(m,fa)
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, :
'x', 'y' and 'z' lengths differ
> scatterplot3d(m,q)
> scatterplot3d(m,FreqAbs,type="h",lwd=5)
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, :
objeto 'FreqAbs' no encontrado
> scatterplot3d(m,q,type="h",lwd=5)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> scatterplot3d(m,1)
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, :
'x', 'y' and 'z' lengths differ
> scatterplot3d(m,q)
> scatterplot3d(m,q,type="h",lwd=5)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> install.packages("ggplot2")
Installing package into '/Users/Camila/Library/R/3.3/library'
(as 'lib' is unspecified)
also installing the dependencies 'stringi', 'magrittr', 'colorspace', 'Rcpp',
'stringr', 'RColorBrewer', 'dichromat', 'munsell', 'labeling', 'rlang', 'digest',
'gtable', 'plyr', 'reshape2', 'scales', 'tibble', 'lazyeval'

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/stringi_1.1.5.
tgz'
Content type 'application/x-gzip' length 12650570 bytes (12.1 MB)
===========================================
=======
downloaded 12.1 MB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/magrittr_1.5.
tgz'
Content type 'application/x-gzip' length 145876 bytes (142 KB)
===========================================
=======
downloaded 142 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/colorspace_1.
3-2.tgz'
Content type 'application/x-gzip' length 432604 bytes (422 KB)
===========================================
=======
downloaded 422 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/Rcpp_0.12.12
.tgz'
Content type 'application/x-gzip' length 3056068 bytes (2.9 MB)
===========================================
=======
downloaded 2.9 MB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/stringr_1.2.0.
tgz'
Content type 'application/x-gzip' length 139879 bytes (136 KB)
===========================================
=======
downloaded 136 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/RColorBrewer
_1.1-2.tgz'
Content type 'application/x-gzip' length 24183 bytes (23 KB)
===========================================
=======
downloaded 23 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/dichromat_2.
0-0.tgz'
Content type 'application/x-gzip' length 145405 bytes (141 KB)
===========================================
=======
downloaded 141 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/munsell_0.4.
3.tgz'
Content type 'application/x-gzip' length 133635 bytes (130 KB)
===========================================
=======
downloaded 130 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/labeling_0.3.t
gz'
Content type 'application/x-gzip' length 39153 bytes (38 KB)
===========================================
=======
downloaded 38 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/rlang_0.1.2.t
gz'
Content type 'application/x-gzip' length 459124 bytes (448 KB)
===========================================
=======
downloaded 448 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/digest_0.6.12
.tgz'
Content type 'application/x-gzip' length 148265 bytes (144 KB)
===========================================
=======
downloaded 144 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/gtable_0.2.0.
tgz'
Content type 'application/x-gzip' length 57163 bytes (55 KB)
===========================================
=======
downloaded 55 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/plyr_1.8.4.tgz
'
Content type 'application/x-gzip' length 805071 bytes (786 KB)
===========================================
=======
downloaded 786 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/reshape2_1.4
.2.tgz'
Content type 'application/x-gzip' length 202343 bytes (197 KB)
===========================================
=======
downloaded 197 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/scales_0.4.1.t
gz'
Content type 'application/x-gzip' length 307642 bytes (300 KB)
===========================================
=======
downloaded 300 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/tibble_1.3.3.t
gz'
Content type 'application/x-gzip' length 350788 bytes (342 KB)
===========================================
=======
downloaded 342 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/lazyeval_0.2.
0.tgz'
Content type 'application/x-gzip' length 122487 bytes (119 KB)
===========================================
=======
downloaded 119 KB

probando la URL
'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/ggplot2_2.2.
1.tgz'
Content type 'application/x-gzip' length 2760842 bytes (2.6 MB)
===========================================
=======
downloaded 2.6 MB

tar: Failed to set default locale


tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale

The downloaded binary packages are in


/
var/folders/hc/c3thc0rj3vgfgwy7cjnld_r80000gp/T//RtmpwVwxSN/downlo
aded_packages
>
>
>
>
>
> ggplot2::GeomBar(m,q)
Error: tentativa de aplicar una no-funci'on
> ggplot2::GeomBarm,q
Error: inesperado ',' in "ggplot2::GeomBarm,"
> library(ggplot2)
> ggplot(m,q)
Error: Mapping should be created with `aes() or `aes_()`.
> qplot(m,q)
> pie(m,q)
>
Punto 333333
Punto 4444

You might also like