graphics - Plot a function with several arguments in R -
Suppose I want to plot an R function:
weibull & lt; - Function (ALPHA, Lambaa, T) {alpha * lambada * (T ^ (alpha -1)}}
Then the function takes the arguments of alpha, lambda and t. Plot I want to create a plot in alpha = 0.5, time of 0 to 2 and lambda = 1, 2, 4, 8, 16 and second, alpha = 1, time 0 to 2 and lambda = 1, 2, 4 , 8, 16.
In order to plot the work with just one argument in the past, I have used the curve and then have done the ADD = true if I am the same On a curve. For example, I've used it in the past:
lambda < - 0.5 pdf & lt; - Function (x) {lambda * XP (-Lamda * x)} Survival & lt; - Work (X) {exp (-lambda * x)} plot (curve (pdf, 0, 6), type = "l", ylim = c (0, 1), lwd = 3, ylab = "", xlab = "Xaxs =" i ", yaxs =" i ", main = expression (paste (" exponential distribution ", lambda," = 0.5 "), cex.main = 2, cex.axis = 2, cex.lab = 2) Curve (existence, 0, 6, plus = true, col = "plum4", lwd = 3)
But in this example, there is only one argument in the function, which is x. Whereas, now I want to vary Lambda, T and Alpha.The curve function does not work and I'm not sure how and how it will reach.
"http: //i.stack.imgur.com/Sv6lN.png" Alt = "Enter image details here">
weibull & lt; - function (alpha, lambda, time) {data .frame (time = time, value = alpha * lambda * (time) ^ (Alpha-1)) Library (PLR) Library (GG Plot 2) Parameters & lt; - Detailed Grid (lambda = C (1, 2, 4, 8, 16), alpha = C (0.5, 1)) All facet_wrap (~ alpha, scale =), and all-in-one (m, plus, "Free", n Col = 2) + geom_line ()
Comments
Post a Comment