Clase de Markdown

Clase de Markdown

x=c(1,4,2,3,5,6,4,3)
plot(x,col="orange")

cH=3E-7
pH=-log10(cH)
print(pH)
## [1] 6.522879

Segunda Parte

x=seq(0,2,0.1)
y=exp(-3*x)
plot(x,y,col="blue",main="Función de Decaimiento Exponencial",xlab="tiempo(min)",ylab="Absorbancia")
lines(x,y,lty=1,col="orange",lwd=2)
abline(v=0.5,lty=3,col="black",lwd=1)
abline(h=0.8,lty=3,col="black",lwd=1)

x=seq(-4,4,0.1)
y=3*exp(-x^2)
plot(x,y,col="blue",main="Función Gaussiana",xlab="tiempo(min)",ylab="Frecuencia",ylim=c(0,4),xlim=c(-3,3))
lines(x,y,lty=1,col="orange",lwd=2)
abline(v=0.0,lty=3,col="black",lwd=1)
abline(h=2.0,lty=3,col="black",lwd=1)
text(x = 2.5, y = 3.5, labels = "máximo",cex=1.0,col="red")
arrows(x0 = 2.0, y0 = 3.5,x1 = 0, y1 = 3,length = 0.1)

# Crear datos de ejemplo
x <- 1:10
y <- x^2

# Crear el gráfico base
plot(x, y,
     main = "Gráfico con diferentes tipos de texto",
     xlab = "Eje X",
     ylab = "Eje Y",
     pch = 16)

# 1. Texto simple
text(x = 5, y = 80, labels = "Texto simple")

# 2. Texto con diferentes características
text(x = 3, y = 60, 
     labels = "Texto rojo en italica", 
     col = "red",
     font = 3)  # 3 = itálica

# 3. Texto con ángulo
text(x = 7, y = 40, 
     labels = "Texto rotado", 
     srt = 45)  # rotación de 45 grados

# 4. Texto con diferentes tamaños
text(x = 2, y = 20, 
     labels = "Texto grande", 
     cex = 1.5)  # 50% más grande

# 5. Agregar flechas y anotaciones
arrows(x0 = 8, y0 = 70, 
       x1 = 9, y1 = 80,
       length = 0.1)
text(x = 7, y = 70, 
     labels = "Punto importante",
     pos = 2)  # pos = 2 coloca el texto a la izquierda del punto

# 6. Texto con diferentes fuentes
text(x = 4, y = 90, 
     labels = "Texto en negrita", 
     font = 2)  # 2 = negrita

# 7. Agregar expresiones matemáticas
text(x = 6, y = 30, 
     labels = expression(alpha + beta == gamma))

x=seq(0,10,1.0)
x2=seq(0,10,0.1)
y=sin(x)
y2=sin(x2)
plot(x,y)
lines(x2,y2)

# Generar 1000 puntos con distribución normal
# mean = 0, sd = 1 (distribución normal estándar)
datos <- rnorm(n = 1000, mean = 0, sd = 1)

# Crear un histograma básico con más características
hist(datos,
     breaks = 30,  # Número de intervalos
     probability = TRUE,  # Para que el área total sea 1
     col = "lightblue",  # Color de las barras
     border = "white",   # Color del borde de las barras
     main = "Histograma de Distribución Normal",
     xlab = "Valores",
     ylab = "Densidad",
     )

# Agregar la curva de densidad teórica
curve(dnorm(x, mean = mean(datos), sd = sd(datos)), 
      add = TRUE,    # Agregar al gráfico existente
      col = "red",   # Color de la línea
      lwd = 2)       # Grosor de la línea

# Agregar una leyenda
legend("topright", 
       legend = c("Histograma", "Densidad normal"),
       fill = c("lightblue", NA),
       col = c(NA, "red"),
       lwd = c(NA, 2),
       border = c("white", NA))

# Agregar texto con estadísticas básicas
text(-2, 0.35, 
     paste("Media:", round(mean(datos), 3), "\n",
           "Desv. Est.:", round(sd(datos), 3)),
     pos = 4)

# Opcional: Agregar líneas verticales para la media y ±1 desviación estándar
abline(v = mean(datos), col = "darkblue", lty = 2)
abline(v = mean(datos) + sd(datos), col = "darkblue", lty = 3)
abline(v = mean(datos) - sd(datos), col = "darkblue", lty = 3)