Error Bar Issues

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Error Bar Issues

beloitstudent
Hello all,

I am an undergraduate student who is having syntax issues trying to get error bars on my graph.  

This is the data, which I assigned the name "Saline" to.
 Time       Average       SEM
1   -20      0.000000     0.0000000
2
3    30      0.000000     0.0000000
4    45      3.227902     0.7462524
5    60      5.066664     1.1623944
6    80      6.107491     1.5027762
7   110     6.968231     1.3799637
8   140     7.325713     1.2282053
9   200     7.875194     1.1185175
10  260    6.513927     0.5386359
11  320    4.204342     0.6855906

This is the command that I typed in to get my error bars.

plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y, pch=21, pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005, xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12), yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1, font.lab=2, add=TRUE)

And this is the error message I keep getting
Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw = uiw,  :
  object 'uiw' not found
In addition: Warning message:
In if (err == "y") z <- y else z <- x :
  the condition has length > 1 and only the first element will be used


Now, to me, the command seems correct.
I want the error bars to show up where the points on my graph are...so the x coordinates should be my time (aka Saline [1]) and the y coordinates should be my Averages (aka Saline [2])  and my upper and lower limits to my confidence interval should be the SEM from Saline [3], but something is wrong with this and I cannot figure out what it is.  If anyone has suggestions I would be very grateful.  Thanks for your help!

beloitstudent
Reply | Threaded
Open this post in threaded view
|

Re: Error Bar Issues

Joris FA Meys
you can't refer to an argument within a function call. Try

uiw <- Saline[,3]

plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
font.lab=2, add=TRUE)

Cheers
Joris

On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent <[hidden email]> wrote:

>
> Hello all,
>
> I am an undergraduate student who is having syntax issues trying to get
> error bars on my graph.
>
> This is the data, which I assigned the name "Saline" to.
>  Time       Average       SEM
> 1   -20      0.000000     0.0000000
> 2
> 3    30      0.000000     0.0000000
> 4    45      3.227902     0.7462524
> 5    60      5.066664     1.1623944
> 6    80      6.107491     1.5027762
> 7   110     6.968231     1.3799637
> 8   140     7.325713     1.2282053
> 9   200     7.875194     1.1185175
> 10  260    6.513927     0.5386359
> 11  320    4.204342     0.6855906
>
> This is the command that I typed in to get my error bars.
>
> plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y, pch=21,
> pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
> xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
> yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
> font.lab=2, add=TRUE)
>
> And this is the error message I keep getting
> Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw =
> uiw,  :
>  object 'uiw' not found
> In addition: Warning message:
> In if (err == "y") z <- y else z <- x :
>  the condition has length > 1 and only the first element will be used
>
> Now, to me, the command seems correct.
> I want the error bars to show up where the points on my graph are...so the x
> coordinates should be my time (aka Saline [1]) and the y coordinates should
> be my Averages (aka Saline [2])  and my upper and lower limits to my
> confidence interval should be the SEM from Saline [3], but something is
> wrong with this and I cannot figure out what it is.  If anyone has
> suggestions I would be very grateful.  Thanks for your help!
>
> beloitstudent
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
[hidden email]
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error Bar Issues

beloitstudent
Thanks for the suggestion...but R still doesn't like it.  Now I have 3 error messages.  It seems to dislike my err=y command.  I'm going to continue trying.  Thanks for your help!  If you happen to spot anything else, please let me know!

thanks!
beloitstudent


On Sat, Jun 5, 2010 at 5:16 PM, Joris FA Meys [via R] <[hidden email]> wrote:
you can't refer to an argument within a function call. Try

uiw <- Saline[,3]

plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
font.lab=2, add=TRUE)

Cheers
Joris

On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent <[hidden email]> wrote:

>
> Hello all,
>
> I am an undergraduate student who is having syntax issues trying to get
> error bars on my graph.
>
> This is the data, which I assigned the name "Saline" to.
>  Time       Average       SEM
> 1   -20      0.000000     0.0000000
> 2
> 3    30      0.000000     0.0000000
> 4    45      3.227902     0.7462524
> 5    60      5.066664     1.1623944
> 6    80      6.107491     1.5027762
> 7   110     6.968231     1.3799637
> 8   140     7.325713     1.2282053
> 9   200     7.875194     1.1185175
> 10  260    6.513927     0.5386359
> 11  320    4.204342     0.6855906
>
> This is the command that I typed in to get my error bars.
>
> plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y, pch=21,
> pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
> xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
> yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
> font.lab=2, add=TRUE)
>
> And this is the error message I keep getting
> Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw =
> uiw,  :
>  object 'uiw' not found
> In addition: Warning message:
> In if (err == "y") z <- y else z <- x :
>  the condition has length > 1 and only the first element will be used
>
> Now, to me, the command seems correct.
> I want the error bars to show up where the points on my graph are...so the x
> coordinates should be my time (aka Saline [1]) and the y coordinates should
> be my Averages (aka Saline [2])  and my upper and lower limits to my
> confidence interval should be the SEM from Saline [3], but something is
> wrong with this and I cannot figure out what it is.  If anyone has
> suggestions I would be very grateful.  Thanks for your help!
>
> beloitstudent
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
[hidden email]
-------------------------------
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



View message @ http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244611.html
To unsubscribe from Error Bar Issues, click here.


<input onclick="jsCall();" id="jsProxy" type="hidden">
Reply | Threaded
Open this post in threaded view
|

Re: Error Bar Issues

William Revelle
Dear Beloitstudent;


Although Ben Bolker will have to give you the
definitive answer, the following will do what I
think you want to do.


library(plotrix)   #for those of us who don't know where plotCI comes from
#give us the data:

Saline <- structure(list(Time = c(-20L, NA, 30L, 45L, 60L, 80L, 110L, 140L,
200L, 260L, 320L), Average = c(0, NA, 0, 3.227902, 5.066664,
6.107491, 6.968231, 7.325713, 7.875194, 6.513927, 4.204342),
     SEM = c(0, NA, 0, 0.7462524, 1.1623944, 1.5027762, 1.3799637,
     1.2282053, 1.1185175, 0.5386359, 0.6855906)), .Names = c("Time",
"Average", "SEM"), class = "data.frame", row.names = c("1", "2",
"3", "4", "5", "6", "7", "8", "9", "10", "11"))

# First  draw the  points
plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], err="y",
  pt.bg=par("bg"),pch=21, cex=1.5 ,gap=0, sfrac=0.005,
xlim=c(-20,340),xaxp=c(-20,320,17), xlab="Time (min)", ylim=c(0,12),
  yaxp=c(0,12,12), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
font.lab=2)    #draws the points

plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], err="y",
pt.bg=par("bg"),pch=21, cex=1.5 ,gap=0, sfrac=0.005,
xlim=c(-20,340),xaxp=c(-20,320,17), ylim=c(0,12),
yaxp=c(0,12,12), las=1,
font.lab=2,add=TRUE,type="o")   #puts the lines in and gives a message

You will get a warning message the type is
obsolete, but at least you have your graph.

Bill





At 3:51 PM -0700 6/5/10, beloitstudent wrote:

>Content-Type: text/plain
>Content-Disposition: inline
>Content-length: 4586
>
>
>Thanks for the suggestion...but R still doesn't like it.  Now I have 3 error
>messages.  It seems to dislike my *err=y* command.  I'm going to continue
>trying.  Thanks for your help!  If you happen to spot anything else, please
>let me know!
>
>thanks!
>beloitstudent
>
>
>On Sat, Jun 5, 2010 at 5:16 PM, Joris FA Meys [via R] <
>[hidden email]<ml-node%[hidden email]>
>>  wrote:
>
>>  you can't refer to an argument within a function call. Try
>>
>>  uiw <- Saline[,3]
>>
>>  plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
>>  pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
>>  xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
>>  yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
>>  font.lab=2, add=TRUE)
>>
>>  Cheers
>>  Joris
>>
>>  On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent
>><[hidden
>>email]<http://user/SendEmail.jtp?type=node&node=2244611&i=0>>
>>  wrote:
>>
>>  >
>>  > Hello all,
>>  >
>>  > I am an undergraduate student who is having syntax issues trying to get
>>  > error bars on my graph.
>>  >
>>  > This is the data, which I assigned the name "Saline" to.
>>  >  Time       Average       SEM
>>  > 1   -20      0.000000     0.0000000
>>  > 2
>>  > 3    30      0.000000     0.0000000
>>  > 4    45      3.227902     0.7462524
>>  > 5    60      5.066664     1.1623944
>>  > 6    80      6.107491     1.5027762
>>  > 7   110     6.968231     1.3799637
>>  > 8   140     7.325713     1.2282053
>>  > 9   200     7.875194     1.1185175
>>  > 10  260    6.513927     0.5386359
>>  > 11  320    4.204342     0.6855906
>>  >
>>  > This is the command that I typed in to get my error bars.
>>  >
>>  > plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y,
>>  pch=21,
>>  > pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
>>  > xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
>>  > yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
>>  > font.lab=2, add=TRUE)
>>  >
>>  > And this is the error message I keep getting
>>  > Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw
>>  =
>>  > uiw,  :
>>  >  object 'uiw' not found
>>  > In addition: Warning message:
>>  > In if (err == "y") z <- y else z <- x :
>>  >  the condition has length > 1 and only the first element will be used
>>  >
>>  > Now, to me, the command seems correct.
>>  > I want the error bars to show up where the points on my graph are...so
>>  the x
>>  > coordinates should be my time (aka Saline [1]) and the y coordinates
>  > should
>>  > be my Averages (aka Saline [2])  and my upper and lower limits to my
>>  > confidence interval should be the SEM from Saline [3], but something is
>>  > wrong with this and I cannot figure out what it is.  If anyone has
>>  > suggestions I would be very grateful.  Thanks for your help!
>>  >
>>  > beloitstudent
>>  > --
>>  > View this message in context:
>>  http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.html
>>  > Sent from the R help mailing list archive at Nabble.com.
>>  >
>>  > ______________________________________________
>>  > [hidden email]
>><http://user/SendEmail.jtp?type=node&node=2244611&i=1>mailing
>>list
>>  > https://stat.ethz.ch/mailman/listinfo/r-help
>>  > PLEASE do read the posting guide
>>  http://www.R-project.org/posting-guide.html
>>  > and provide commented, minimal, self-contained, reproducible code.
>>  >
>>
>>
>>
>>  --
>>  Ghent University
>>  Faculty of Bioscience Engineering
>>  Department of Applied mathematics, biometrics and process control
>>
>>  tel : +32 9 264 59 87
>>  [hidden email] <http://user/SendEmail.jtp?type=node&node=2244611&i=2>
>>  -------------------------------
>>  Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>
>>  ______________________________________________
>>  [hidden email]
>><http://user/SendEmail.jtp?type=node&node=2244611&i=3>mailing
>>list
>>  https://stat.ethz.ch/mailman/listinfo/r-help
>>  PLEASE do read the posting guide
>>  http://www.R-project.org/posting-guide.html
>>  and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>  ------------------------------
>>   View message @
>>  http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244611.html
>>  To unsubscribe from Error Bar Issues, click here< (link removed) ==>.
>>
>>
>>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244627.html
>Sent from the R help mailing list archive at Nabble.com.
>
> [[alternative HTML version deleted]]
>
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error Bar Issues

Joris FA Meys
In reply to this post by beloitstudent
On Sun, Jun 6, 2010 at 12:51 AM, beloitstudent <[hidden email]> wrote:
>
> Thanks for the suggestion...but R still doesn't like it.  Now I have 3 error
> messages.  It seems to dislike my *err=y* command.  I'm going to continue
> trying.  Thanks for your help!  If you happen to spot anything else, please
> let me know!
Off course, same problem: You're referring to an object y in your
command. But you have no object named y in your workspace, so R can't
continue.

Look at the help files:
?plotCI

You'll see you have to put quotation marks around y, like William
showed you. Next to that, please also define from which package you
use a plot. plotCI can be found in the gplots package and in the
plotrix package.

Cheers
Joris

Either you define all input for the function before you run it, or you
use the double quotes like William showed

>
> thanks!
> beloitstudent
>
>
> On Sat, Jun 5, 2010 at 5:16 PM, Joris FA Meys [via R] <
> [hidden email]<ml-node%[hidden email]>
>> wrote:
>
>> you can't refer to an argument within a function call. Try
>>
>> uiw <- Saline[,3]
>>
>> plotCI(x=Saline [,1],y=Saline [,2], uiw=uiw, liw=uiw, err=y, pch=21,
>> pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
>> xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
>> yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
>> font.lab=2, add=TRUE)
>>
>> Cheers
>> Joris
>>
>> On Sat, Jun 5, 2010 at 6:09 PM, beloitstudent <[hidden email]<http://user/SendEmail.jtp?type=node&node=2244611&i=0>>
>> wrote:
>>
>> >
>> > Hello all,
>> >
>> > I am an undergraduate student who is having syntax issues trying to get
>> > error bars on my graph.
>> >
>> > This is the data, which I assigned the name "Saline" to.
>> >  Time       Average       SEM
>> > 1   -20      0.000000     0.0000000
>> > 2
>> > 3    30      0.000000     0.0000000
>> > 4    45      3.227902     0.7462524
>> > 5    60      5.066664     1.1623944
>> > 6    80      6.107491     1.5027762
>> > 7   110     6.968231     1.3799637
>> > 8   140     7.325713     1.2282053
>> > 9   200     7.875194     1.1185175
>> > 10  260    6.513927     0.5386359
>> > 11  320    4.204342     0.6855906
>> >
>> > This is the command that I typed in to get my error bars.
>> >
>> > plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], liw=uiw, err=y,
>> pch=21,
>> > pt.bg=par("bg"), cex=1.5, lty=1, type="o", gap=0, sfrac=0.005,
>> > xlim=c(-21,340),xaxp=c(-20,320,11), xlab="Time (min)", ylim=c(0,12),
>> > yaxp=c(0,12,11), ylab="Arterial Plasma Acetaminophen (µg/mL)", las=1,
>> > font.lab=2, add=TRUE)
>> >
>> > And this is the error message I keep getting
>> > Error in plotCI(x = Saline[, 1], y = Saline[, 2], uiw = Saline[, 3], liw
>> =
>> > uiw,  :
>> >  object 'uiw' not found
>> > In addition: Warning message:
>> > In if (err == "y") z <- y else z <- x :
>> >  the condition has length > 1 and only the first element will be used
>> >
>> > Now, to me, the command seems correct.
>> > I want the error bars to show up where the points on my graph are...so
>> the x
>> > coordinates should be my time (aka Saline [1]) and the y coordinates
>> should
>> > be my Averages (aka Saline [2])  and my upper and lower limits to my
>> > confidence interval should be the SEM from Saline [3], but something is
>> > wrong with this and I cannot figure out what it is.  If anyone has
>> > suggestions I would be very grateful.  Thanks for your help!
>> >
>> > beloitstudent
>> > --
>> > View this message in context:
>> http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244335.html
>> > Sent from the R help mailing list archive at Nabble.com.
>> >
>> > ______________________________________________
>> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2244611&i=1>mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Ghent University
>> Faculty of Bioscience Engineering
>> Department of Applied mathematics, biometrics and process control
>>
>> tel : +32 9 264 59 87
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2244611&i=2>
>> -------------------------------
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>
>> ______________________________________________
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2244611&i=3>mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>> ------------------------------
>>  View message @
>> http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244611.html
>> To unsubscribe from Error Bar Issues, click here< (link removed) ==>.
>>
>>
>>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-Bar-Issues-tp2244335p2244627.html
> Sent from the R help mailing list archive at Nabble.com.
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



--
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
[hidden email]
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.