heitor
1
Hi everyone,
I have this situation:
BC_partes = function(w) {
ifelse(w < 12.38 & w >= 0, 0.3806,
ifelse(w >= 12.38, 0.0921 + ((0.2885)/((0.0808*w)^0.4330))))
}
library(ggplot2)
library(dplyr)
DF <- data.frame(Xval = seq(0, 1500, 10), Yval = funcao_partes(seq(0, 1500,10)))
ggplot(data = DF, mapping = aes(x = Xval, y = Yval)) + geom_point()+
geom_line(data = filter(DF, Xval < 12.38 & Xval >= 0, color = 'green')) +
geom_line(data = filter(DF, Xval >= 12.38, color = 'red'))
Whe i run this code, this mensage apear:
Error in ifelse(w >= 12.38, 0.0921 + ((0.2885)/((0.0808 * w)^0.433))) :
missing "no" argument, no default.
What i need to do?
BC_partes = function(w) {
ifelse(w < 12.38 & w >= 0, 0.3806, 0.0921 + ((0.2885)/((0.0808*w)^0.4330)))
}
heitor
3
And how can i create a graphyc like my example?
FJCC
4
All I did is use @nirgrahamuk's version of the function, use that function name within data.frame(), and move the ) in geom_line()
BC_partes = function(w) {
ifelse(w < 12.38 & w >= 0, 0.3806, 0.0921 + ((0.2885)/((0.0808*w)^0.4330)))
}
BC_partes(3)
library(ggplot2)
library(dplyr)
DF <- data.frame(Xval = seq(0, 1500, 10), Yval = BC_partes(seq(0, 1500,10)))
ggplot(data = DF, mapping = aes(x = Xval, y = Yval)) + geom_point()+
geom_line(data = filter(DF, Xval < 12.38 & Xval >= 0), color = 'green') +
geom_line(data = filter(DF, Xval >= 12.38), color = 'red')
system
Closed
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.