1

I'm trying to fit a graph using R on power BI via these commands:

    dataset <- data.frame(IDName, Value, Setpoints)
    dataset <- unique(dataset)
    dat <- aggregate(Value ~ Setpoints, dataset, mean)
    x <- dat$Value
    y <- dat$Setpoints
    plot(x,y, main ="Turbidity Frequency Distribution",xlab="% Time < Turbidity level", ylab="Turbidity (NTU)")
    lines(x,y)

This averages my data points but I want to add in an extra parameter - IDName, so instead of it aggregating the value depending on setpoint, it aggregates the value depending on the setpoint for each IDName independant (so it will result in that many points for the amount of IDNames)

I am also trying to fit a curved upwards line, I tried this:

dat <- aggregate(Value ~ Setpoints, dataset, mean)
x <- dat$Value
y <- dat$Setpoints
lo <- loess(y~x)
plot(x,y)
xl <- seq(min(x),max(x), (max(x)-min(x))/1000)
lines(xl,predict(lo,xl),col='red',lwd=2)

and it works to fit a curved line but it curves up then down whereas I just want it to be an upward curve.

When this graph is done it should have multiple scatterplots for each IDName that make up and upwards curve.

It's a bit hard to explain since I'm new to stackoverflow and cannot embed images.

Thanks

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 1
    Hi Ashling, welcome to Stack Overflow. You can indeed add images to your post, but they must be links rather than inline. Simply paste them into the post editor. Additionally, it will be extremely challenging to answer your question without at least a sample of your data. Please edit your question with the output of `dput(dataset)` or `dput(head(dataset))` if your data is very large. See [How to make a great R reproducible example](https://stackoverflow.com/a/5963610/) for more. – Ian Campbell Dec 16 '20 at 02:36

0 Answers0