Skip to content

Good Evening,

3 messages · Joy Kissoon, Rui Barradas, Jim Lemon

#
I contacted Martin Maechler (maechler at stat.math.ethz.ch) and was advised to
contact you for input on the question below...thanks!

I am very new with the R experience, all I know is that it's computer
language & coding... I'm trying to plot a regression graph for runif (100,
1000, 10000). What am I not getting here, I can get the values in R no
problem, but no idea how to turn it into a graph... No idea how to
determine the X or Y axis...etc.
Any assistance will be appreciated...Much Thanks!
Thanks,
*Joy (B.) Kissoon* (Ba.So.Sc.-Criminal Justice, Nurse, Artist)
Best Regards,
*Joy (B.) Kissoon* (Ba.So.Sc.-Criminal Justice, Nurse, Artist)


<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Thu, Oct 29, 2020 at 10:32 AM Joy Kissoon <kissoonjoy at gmail.com> wrote:

            

  
  
#
Hello,

To plot a graph you don't need to compute the axis, R will do it for you:

# create data
set.seed(2020)    # Make the results reproducible
x <- runif(100, 1000, 10000)


This is not very intuitive but the following will plot the x values in 
the y axis, along the x axis values 1 to 100.


plot(x)


To plot a regression line you will need a regression model and that 
means you need a response variable.

y <- x + rnorm(100)

model <- lm(y ~ x)
plot(x, y)
abline(model, col = "red")



The question is very basic, you should focus on learning a bit more of 
R. Start with R-intro.pdf that comes with R. There are also many texts 
online that cover this and lots of other graphics stuff.


Hope this helps,

Rui Barradas

?s 14:49 de 29/10/20, Joy Kissoon escreveu:
#
Hi Joy,
As Rui noted, you can get a plot with:

jk.dat<-runif(100,1000,10000)
plot(jk.dat,type="l")

This plots your vector of 100 uniformly distributed numbers against their
"index" (the order in which they appear in the vector). I suspect your
problem is that you want to define a vector of "x" values that will attach
them to a real set of observations. Say that you are preparing to work with
the daily counts of cosmic rays for a neutron monitor.

obs_dates<-as.Date(as.Date("2020-07-23"):as.Date("2020-10-30"),
 origin=as.Date("1970-01-01"))
plot(obs_dates,jk.dat,type="l",main="Daily CR counts")

That may give you some ideas.

Jim
On Fri, Oct 30, 2020 at 3:38 AM Joy Kissoon <kissoonjoy at gmail.com> wrote: