Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6872759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:58:12+00:00 2026-05-27T03:58:12+00:00

I have a simple data set with two columns of data- K and SwStr

  • 0

I have a simple data set with two columns of data- K and SwStr.

K = c(.259, .215, .224, .223, .262, .233)
SwStr = c(.130, .117, .117, .114, .113, .111)

I plotted the data using:

plot(res$K, res$SwStr)

I want to plot the result of a linear model, using SwStr to predict K. I try to do that using:

graphic<-lm(K~SwStr-1, data=res)
P=predict(graphic)

plot(res$K, res$SwStr)
lines(P, lty="dashed", col="green", lwd=3)

But when I do this, I don’t get any line plotted. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:58:13+00:00Added an answer on May 27, 2026 at 3:58 am

    (1) You are inverting the axes of the original plot. If you want SwStr on the x axis and K on the y axis you need

    plot(res$SwStr, res$K)
    

    or

    with(res,plot(K~SwStr))
    

    If you check the actual values of the plotted points on the graph, this might be obvious (especially if K and SwStr have different magnitudes) …

    For lm fits you can also use abline(graphic,...)

    edit: (2) You also have to realize that predict gives just the predicted y values, not the x values. So you want something like this:

    K=c(.259, .215, .224, .223, .262, .233)
    SwStr=c(.130, .117, .117, .114, .113, .111)
    g <- lm(K~SwStr-1)
    par(las=1,bty="l")  ## my favourites
    plot(K~SwStr)
    P <- predict(g)
    lines(SwStr,P)
    

    Depending on the situation, you may also want to use the newdata argument to predict to specify a set of evenly spaced x values …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data set with latitude and longitude coordinates (two separate decimal columns).
I have a data set that has two tab delimited columns that I plot
I have a simple data model of two tables, email and recipients, email can
I have a list L of data frames with two columns each...a key, and
I have two simple stored procedures in SqlServer: SetData(@id int, @data varchar(10)) GetData(@id int)
I have only simple data types in method signature of service (such as int,
I have a simple WCF Data Services service and I want to expose a
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package where I import data from flat file into SQL
If I have a simple piece of data to store (an integer or string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.