-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path5-operaciones-con-funciones-en-R.R
More file actions
71 lines (46 loc) · 1.07 KB
/
5-operaciones-con-funciones-en-R.R
File metadata and controls
71 lines (46 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO
# Facultad de Economía
# Matemáticas I 2021-1
# Profesor: Cesar Hernández
# PRÁCTICA 5: OPERACIONES CON FUNCIONES EN R
# Borrar objetos y variables
rm(list=ls())
# Creamos un dominio para nuestras funciones
x<-(-5:5)
# Creamos las funciones f(x) y g(x)
fx<-5*x+2
gx<-3*x-1
fx
gx
plot(x,fx, type="o")
plot(x,gx, type="o")
# Suma
fmasg<-fx+gx
fmasg
plot(x,fmasg, type="o")
# Resta
fmenosg<-fx-gx
fmenosg
plot(x,fmenosg, type="o")
# Multiplicación
fporg<-fx*gx
fporg
plot(x,fporg, type="o")
# División
fentreg<-fx/gx
fentreg
plot(x,fentreg, type="o")
secuencia<- seq(-2, 2, 0.05)
secuencia
y1 <- pnorm(secuencia)
y2 <- pnorm(secuencia, 1, 1)
y1
y2
plot(secuencia, y1, type = "l", col = "red")
plot(secuencia, y2, type = "l", col = "green")
dffx<-data.frame(x,fx)
dfgx<-data.frame(x,gx)
p<-ggplot() + geom_line(data = dffx, aes(x = x, y = fx), color = "blue") +
geom_line(data = dfgx, aes(x = x, y = gx), color = "red") + xlab("x") +
ylab("y")
print(p)