plotting log base 10

Hello there! I am having difficulty plotting a log(10) formula on to existing data points. I derived a logarithmic function based on a list of data where "Tout_F_6am" is my independent variable and "clo" is my dependent variable.
When I go to plot it, I am getting the error that lengths x and y are different. Can someone please help me figure out whats going wrong?

logKT=lm(log10(clo)~ Tout_F_6am,data=passive)
summary(logKT) #r2=0.12
coef(logKT)

plot(passive$Tout_F_6am,passive$clo) #plot data points
x=seq(53,84, length=6381)#match length of x variable
y=logKT
lines(x,y,type="l",lwd=2,col="red")

length(passive$Tout_F_6am) #6381
length(passive$clo) #6381
logKT=lm(log10(clo)~ Tout_F_6am,data=passive)
y=logKT
lines(x,y,type="l",lwd=2,col="red")

You're attempting to use a function in the y argument of lines(), but this argument can either be left NULL or you can set a coordinate vector. Check out the documentation here! https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/lines

Here's a simple worked example using plot() and lines() that should help answer some more questions about your use-cases here.
https://mathinsight.org/plotting_line_graphs_in_r

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.