Skip to content

Latest commit

 

History

History
90 lines (63 loc) · 783 Bytes

12.md

File metadata and controls

90 lines (63 loc) · 783 Bytes

12

a

Power = function() {
    2^3
}
print(Power())
## [1] 8

b

Power2 = function(x, a) {
    x^a
}
Power2(3, 8)
## [1] 6561

c

Power2(10, 3)
## [1] 1000
Power2(8, 17)
## [1] 2.252e+15
Power2(131, 3)
## [1] 2248091

d

Power3 = function(x, a) {
    result = x^a
    return(result)
}

e

x = 1:10
plot(x, Power3(x, 2), log = "xy", ylab = "Log of y = x^2", xlab = "Log of x", 
    main = "Log of x^2 versus Log of x")

plot of chunk 12e

f

PlotPower = function(x, a) {
    plot(x, Power3(x, a))
}
PlotPower(1:10, 3)

plot of chunk 12f