I want to create a vector of functions with two parameters where one parameter is over a continuous range of values and the other runs over a fixed number of numerical values saved in the column vector dat[,2]
.
# Example functions
icc <- function(year, x) {
z = exp(year - x)
inf = z / (1 + z)
return (inf)
}
# Example data
year <- seq(-4, 4, 0.1)
x1 <- dat[1, 2]
x2 <- dat[2, 2]
# Plots
plot(t, icc(year, x1), type = "l")
plot(t, icc(year, x2), type = "l")
The issues are
dat[,2]
has more than just 2 values and I want to be able to plot all the corresponding functions on the same plot but with different colors- manually assigning colors to each line is difficult as there are a large number of lines
- dat[,1] stores the corresponding label to each plot; would it be possible to add them over each line?
I have something like this in mind-
UPDATE: dat
is simply a 40 x 2 table storing strings in the first column and numerical values in the second. By 'a vector of functions', I mean an array containing functions with parameter values unique to each row. For example- if t^i
is the function then, element 1 of the array is the function t^1
, element 2 is t^2
and so on where t is a 'range'. (Label and color are extras and not too important. If unanswered, I'll post another question for them).