Re: [R] ifelse

2009-10-24 Thread HBaize


What I think you are missing is that you didn't change ddd. The ifelse
statement does not assign values to the ddd object. To change ddd it would
read:

ddd - ifelse ( ddd360, ddd-360, ddd )

So when you enter print(ddd) you get the content of the original object,
which has not changed. 

What is missing from your examples below is the output of the ifelse
statement. When I run your second example (I can't run the first because you
didn't supply the data objects) 
I get the following:

 ddd - c(461, 213, 238, 249, 251)
  print(class(ddd))
[1] numeric
 
  print(ddd)
[1] 461 213 238 249 251
 
  ifelse ( ddd360, ddd-360, ddd )
[1] 101 213 238 249 251
  print(ddd)
[1] 461 213 238 249 251
 

Which is perfectly reasonable given that the ifelse does not change the ddd
object. 



pking wrote:
 
 When I run this code from an R-script:
ddd = 360 + round ( atan2(-u,-v) / d2r )
print(class(ddd))
print(ddd)
ifelse ( ddd360, ddd-360, ddd )
print(ddd)

 I get this output:   
 [1] numeric
 [1] 461 213 238 249 251
 [1] 461 213 238 249 251
 
 Why does ifelse not change the 461 to 101?
 
 I recreated the vector ddd and ran the same ifelse
 code and it did work as expected.
   
 ddd - c(461, 213, 238, 249, 251)  
 print(class(ddd))
 [1] numeric
 
 print(ddd)
 [1] 461 213 238 249 251
 
 ifelse ( ddd360, ddd-360, ddd )
 print(ddd)
 [1] 101 213 238 249 251
 
 What am I missing?
 
 Patrick King
 
 
 

-- 
View this message in context: 
http://www.nabble.com/ifelse-tp26041165p26041312.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] ifelse

2009-10-24 Thread HBaize

Also, to further clarify. When you source or batch file R scripts, objects
are only printed to the screen if you use a print function. That is why the
result of the ifelse does not appear. 

Your original example would have shown the expected result of the ifelse if
it had read: 

print(ifelse ( ddd360, ddd-360, ddd ) 

adding the print function to the ifelse in your first example, executed
using source(), will give you this output: 

[1] numeric
[1] 461 213 238 249 251
[1] 101 213 238 249 251
[1] 461 213 238 249 251
 


HBaize wrote:
 
 
 What I think you are missing is that you didn't change ddd. The ifelse
 statement does not assign values to the ddd object. To change ddd it would
 read:
 
 ddd - ifelse ( ddd360, ddd-360, ddd )
 
 So when you enter print(ddd) you get the content of the original object,
 which has not changed. 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/ifelse-tp26041165p26041840.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Social networking around R

2009-10-11 Thread HBaize



Harsh-7 wrote:
 
 Hi R users,
 
 I'd be interested in what R users think about social networking around all
 things R. For this, I've set up a social network @
 www.rstuff.socialgo.comand it would be great if you could post your
 comments on the forum created
 for this discussion.
 
 

Could you provide a complete URL. I'm getting a 404 not found. 

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Social-networking-around-R-tp25845449p25846415.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] re ad.delim skips first column (why?)

2009-10-01 Thread HBaize


I can't determine what is going on in you example, but my approach would be
to read the text file into a text editor that will display hidden characters
(tab, etc.) so you can see the pattern. It could be that there is an extra
tab in some locations. You could then use the editor's replace function to
remove the control characters that are causing the problem. 


Giovanni Dall'Olio wrote:
 
 Hi people,
 I have a text file like this one posted:
 
 
 When I use read.delim (or any read function) on it, R skips the first
 column, and I don' understand why.
 
 
 

-- 
View this message in context: 
http://www.nabble.com/read.delim-skips-first-column-%28why-%29-tp24466023p25696875.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] running R on netbooks/minis?

2009-05-03 Thread HBaize


It works great on my Acer Aspire One AOD150-1165 10.1 inch, under Windows
XP. I opted to expand to two gigs of RAM because R loads all objects into
active memory. The expansion of 2 gigs over the 1 gig that was standard only
cost $20. Unless you are using large data sets with extensive computation,
you will have no problem using R with a netbook. =)


Erin Hodgess-2 wrote:
 
 Dear R People:
 
 Is it possible to run R on a netbook/mini, please?
 
 Thanks,
 Erin
 
 
 -- 
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/running-R-on-netbooks-minis--tp23353691p23354031.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Cross-platforms solution to export R graphs

2009-04-09 Thread HBaize


Thank you Philippe. 
That is very helpful.



Philippe Grosjean wrote:
 
 Hello Rusers,
 
 I have worked on a R Wiki page for solutions in exporting R graphs, 
 especially, the often-asked questions:
 - How can I export R graphs in vectorized format (EMF) for inclusion in 
   MS Word or OpenOffice outside of Windows?
 - What is the best solution(s) for post-editing/annotating R graphs.
 
 The page is at: 
 http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export.
 
 I would be happy to receive your comments and suggestions to improve 
 this document.
 All the best,
 
 PhG
 -- 
 ..°}))
   ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
   ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
   ) ) ) ) )   Mons-Hainaut University, Belgium
 ( ( ( ( (
 ..
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/Cross-platforms-solution-to-export-R-graphs-tp22970668p22973759.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Is there any difference between - and =

2009-03-12 Thread HBaize


I think most people find it odd at first if they have always used = but
quickly you get use to it and nothing could be more clear. It is explicit.
It is active and provides a direction, a value goes into an object. The
equal sign for assignment is ambiguous. 

As an example 

 x = 3

we only know that the value 3 is assigned to the object x because by
convention a number cannot be an object, if not it could be read as the
object 3 taking the value x The expression literally states that they
are equal, yet you cannot assume that all instances of 3 are equal to x, so
it is an inaccurate expression. On the other hand,

3 - x  or 
x - 3  

is very clear. It makes no changes to 3 only to x  I've been reading
Data Manipulation with R and find the author's use of = for assignment
disturbing. You quickly get use to - and will find after a short time that
you prefer it.



Sean Zhang wrote:
 
 Dear R-helpers:
 
 I have a question related to - and =.
 
 I saw very experienced R programmers use = rather than - quite
 consistently.
 However, I heard from others that do not use = but always stick to - when
 assigning valuese.
 
 I personally like = because I was using Matabl, But, would like to receive
 expert opinion to avoid potential trouble.
 
 Many thanks in advance.
 
 -Sean
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/Is-there-any-difference-between-%3C--and-%3D-tp22456167p22489108.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Is this a documentation bug? Spss dates import

2009-03-11 Thread HBaize

Luca,
I ran your code using SPSS 17.0 and R 2.8.1.
I found that the correct date was returned in R using this code:

test.df$newdate - as.Date(as.POSIXct(test.df$mydate , origin=1582-10-14))  

Also note that SPSS 17.0 is case sensitive in storing variable names, so the
R code in your post needs to be changed from test.df$MYDATE to
test.df$mydate to match your use of lowercase in the SPSS syntax. 

Harold


Luca Braglia wrote:
 
 Hello R-user
 
 bug seekers are needed!
 In order to perform these simple tasks you have to use a copy of SPSS
 and obviously R
 

-- 
View this message in context: 
http://www.nabble.com/Is-this-a-documentation-bug--Spss-dates-import-tp22455442p22461929.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] How to generate fake population (ie. not sample) data?

2009-03-04 Thread HBaize


Could that be extended to generate a population data set with known skew and
kurtosis? 
If so, how? 

Thanks in advance for suggested solutions.

Harold



Daniel Nordlund-2 wrote:
 
 
 
 Something like this may help get you started.
 
 std.pop - function(x,mu,stdev){
   ((x-mean(x))/sd(x)*stdev)+mu
   }
 
 population - std.pop(rnorm(1000),10,5)
 
 Hope this is helpful,
 
 Dan
 
 Daniel Nordlund
 Bothell, WA USA
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/How-to-generate-fake-population-%28ie.-not-sample%29-data--tp22322488p22340256.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] boxplot with average instead of median

2008-08-06 Thread HBaize

Hadley makes a good point. Boxplots should be standardized. Thre is already
inconsistency in what value the wiskers represent. 

Violin plots with means and 95% CI are a good option if you want to show the
shape of a distribution with the mean. You could add the median as well.
That's what I did in the code I posted in this thread:

http://www.nabble.com/adding-the-mean-and-standard-deviation-to-boxplots-td15271398.html


hadley wrote:
 
 On Mon, Aug 4, 2008 at 10:36 PM, Chad Junkermeier [EMAIL PROTECTED]
 wrote:
 I really like the ease of use with the boxplot command in R.  I would
 rather
 have a boxplot that shows the average value and the standard deviation
 then
 the median value and the quartiles.
 
 I would suggest that you don't do this.  Most people looking at the
 boxplots will expect to see the tradition Tukey boxplot with medians
 and quartiles, and are likely to misinterpret the graph.
 
 Why do you want to display means and standard deviations?
 
 Hadley
 
 
 -- 
 http://had.co.nz/
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/boxplot-with-average-instead-of-median-tp18826179p18853580.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Opening R from Tinn without setting directory each time

2008-08-05 Thread HBaize

That doesn't make sense. Which version of Tinn-R are you using?

From Options-Main-Application 
do you get a dialog box with a tab R, and within that a tab General?

At the bottom of the General tab there is a button under Rgui. That 
should bring up a file selection box. Proceed to the location of your 
Rgui.exe which should be in the bin directory.

C:\Program Files\R\R-2.7.1\bin\Rgui.exe

Click OK. 
Works for me. I'm using Tinn-R version 1.19.0.2

HB



Paul Chatfield wrote:
 
 Hi - I can access R from Tinn-R by going to Options-Main-Application/R
 and setting the search path, but each time I exit Tinn-R I have to
 redefine the search path.  Is there no way of fixing that directory as
 default?  I have installed R under its default directory C:/Program
 Files/R/R-2.7.1 and Tinn under a variety of different places to try to
 rectify the problem though currently under C:/Program Files/Tinn-R.  Any
 ideas what I'm missing?
 
 Thanks
 
 Paul
 

-- 
View this message in context: 
http://www.nabble.com/Opening-R-from-Tinn-without-setting-directory-each-time-tp18830678p18842136.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] boxplot with average instead of median

2008-08-05 Thread HBaize


Look at this disscussion from two weeks ago:

http://www.nabble.com/adding-the-mean-and-standard-deviation-to-boxplots-td15271398.html



Chad Junkermeier wrote:
 
 I really like the ease of use with the boxplot command in R.  I would  
 rather have a boxplot that shows the average value and the standard  
 deviation then the median value and the quartiles.
 
 Is there a way to do this?
 
 
 Chad Junkermeier, Graduate Student
 Dept. of Physics
 West Virginia University
 PO Box 6315
 210 Hodges Hall
 Morgantown WV 26506-6315
 phone: (304) 293-3442 ext. 1430
 fax: (304) 293-5732
 email: chad.junkermeier{at}mail.wvu.edu
 -
 Concurrently at:
 Dept. of Physics and Astronomy
 Brigham Young University
 Provo UT 84602
 email: junkermeier{at}byu.edu
 
 cell: (801) 380-8895
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/boxplot-with-average-instead-of-median-tp18826179p18842374.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] adding the mean and standard deviation to boxplots

2008-07-23 Thread HBaize

Fernando,
I don't have time to do all that you asked, but here is some code that makes
violin plots with mean, median, and 95% CI. I like this plot very much, even
if boxplot purists think it is horrible :-) 

I think the boxplot was developed before we had computing power. Now we can
show the detail of the distribution easily. This code uses the library
UsingR written by John Verzani. 

Real R wizards will find my code to be crude. It could be done with more
elegance, but it works :-) 
Note that I varied the sample size to show difference in 95% CI.

HTH

---

## Create three random data vectors
a - rnorm(25,2500,300)
b - rnorm(50,3500,250)
c - rnorm(100,4000,200)


## Convert data vectors to dataframes
adf - data.frame(Group =  A , Measure = a)
bdf - data.frame(Group =  B , Measure = b)
cdf - data.frame(Group =  C , Measure = c)

## Combine into a dataframe using rbind
abcData - rbind(adf, bdf, cdf)
attach(abcData)

## load the UsingR library for violin plots

library(UsingR)

## Run boxplot to find statistics, but don't draw the boxplots
S - boxplot(Measure ~ Group, plot=FALSE)

## Draw violin plots
simple.violinplot(Measure ~ Group,
col = lightblue)

## Add title 
title(main=Just Random Test Data,
  sub=A, B,  C,
  cex.main = 1.5,
  cex.sub = 1.3)


## Define locations for additional chart elements
at - c(1:length(S$names))

## Draw thick green lines for median values

points(at,S$stats[3, ], pch = 22, cex = 1.2, bg = darkgreen)

## Get Group means and plot them using a diamond plot symbol
##IMPORTANT -- must add the missing values removal: na.rm=TRUE
## if there is any missing data.

means - by(Measure, Group, mean, na.rm=TRUE)
points(at,means, pch = 23, cex = 1.2, bg = red)

##-  Get CIs -##
## create standard error function--
se - function(x) {
 y - x[!is.na(x)]
 sqrt(var(as.vector(y))/length(y))
}

## create length function for non-missing values
lngth - function(x){
y - x[!is.na(x)]
length(y)
}

## Compute vectors of standard error and n
Hse - by(Measure,Group,se)
Hn  - by(Measure,Group,lngth)

## compute 95% CIs and store in vectors
civ.u - means + qt(.975, df=Hn-1) * Hse # Upper bound CI
civ.l - means + qt(.025, df=Hn-1) * Hse # Lower bound CI


## Draw CI, first vertical line, then upper and lower horizontal
segments(at, civ.u, at, civ.l, lty = solid, lwd = 2, col = red)
segments(at - 0.1, civ.u, at + 0.1, civ.u, lty = solid, lwd =2,col =
red)
segments(at - 0.1, civ.l, at + 0.1, civ.l, lty = solid, lwd =2,col =
red)


## Draw Mean values to the left edge of each violinplot
text(at - 0.1, means, labels = formatC(means, format = f, digits = 1),
pos = 2, cex = 1, col = red)

## Draw Median values to the right edge of each violinplot
text(at + 0.1, S$stats[3, ], labels = formatC(S$stats[3, ],
 format = f, digits = 1), pos = 4, cex = 1, col = darkgreen)

## Print n under the name of measure
mtext(S$n, side = 1, at = at, cex=.75, line = 2.5)

## End






Fernando Marmolejo-Ramos wrote:
 
 Dear users
 
 This is a message I was directing to Harold Baize but because I pressed
 the wrong button the message got lost g!!!
 
 So I’m doing it all over again:
 
 Lets suppose I have three batches of data:
 
 a - rnorm(50,2500,300) 
 b - rnorm(50,3500,250)
 c - rnorm(50,4000,200)
 
 # Now I want to plot them as boxplots and violin plots
 require(vioplot)
 vioplot (a,b,c, horizontal=T, col=“white”)
 boxplot (a,b,c, horizontal=T, col=“white”)
 
 As we know boxplot show the least-greates values, lower-upper quartiles,
 the mean, and outliers (when present).
 
 However, for some data is not important the MEDIAN but the MEAN. Also, it
 is more relevant to show ERROR BARS instead of quartiles. 
 
 So, how could I see (for the batches of data I introduced above)…
 
 1.a boxplot showing the MEAN and the SD instead of the lower/upper
 quartile?
 2.a boxplot showing the MEAN and the STANDARD ERROR OF THE MEAN instead
 of the lower/upper quartile?
 3.a boxplot showing the MEAN and the 95% CI instead of the lower/upper
 quartile?
 
 (I think in all these cases is preferable to have visual access, or to
 have the line that shows, the LEAST and the GREATEST VALUES.)
 
 In other words, that the ERROR BARS (95% CI, SD, SE) proposed here take
 the place of the boxes usually used to represent the lower/upper quartile.
 
 Now, the big question, is all this jazz possible to be implemented in
 violin plots as well?
 
 How could that be done?
 
 Cheers,
 
 Fernando
 

-- 
View this message in context: 
http://www.nabble.com/adding-the-mean-and-standard-deviation-to-boxplots-tp15271398p18619876.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Summary Stats (not summary(x))

2008-07-09 Thread HBaize


I think the function describe() in the package psych will give you 
want you want. There are other similar functions in the library Simple 
as well.

Harold



nmarti wrote:
 
 I'm looking for a function that lists a few summary stats for a column (or
 row) of data.  I'm aware of summary(x), but that does not give me what I'm
 looking for.
 I'm actually looking for something that is very similar to the descriptive
 statistics tool in excel; i.e. Mean, Std. Error, Std. Deviation, Kurtosis.
 I'm positive that I came across a function that did this (possibly in
 Rmetrics), but now I can't find it.  I lost it in the endless mass of R
 functions.
 
 Any help would be appreciated.
 

-- 
View this message in context: 
http://www.nabble.com/Summary-Stats-%28not-summary%28x%29%29-tp18363275p18363387.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


[R] RODBC Access limit?

2008-07-03 Thread HBaize


I have been using RODBC to connect to an Access database to capture data to
create plots. Recently I found incomplete charts. Upon investigation I
discovered that the data retrieved stopped at 3276 rows (records) out of a
table with over 5600 records. 

I've tried changing max,buffsize, and rows_at_time but it still
returns only 3276 rows.  

Is this a limitation in R or Access? Is there an easy work around? 

Thanks for any helpful suggestions.







-- 
View this message in context: 
http://www.nabble.com/RODBC-Access-limit--tp18253443p18253443.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] boxplot colors

2008-06-22 Thread HBaize


You are drawing four box plots, not two. Two of them are just the number 5.
The two box plots that are only 5 don't have a box, so you can't see that
they're red. Try this:

boxplot(1:19,20:39,col=c(red,blue))


Paul Adams-8 wrote:
 
 Hello everyone,
 
 
 I am trying to color two boxplots on the same graph two 
 different colors.
 I have tried the following
 
 boxplot(5,1:19,5,20:39,col=c(red,blue))
 but all I get are two blue boxes.
 Any help would be appreciated
 Paul
 
 
 
   
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/boxplot-colors-tp18051541p18052038.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Combine colors and shading lines

2008-06-20 Thread HBaize


Josh, 
Check into add=TRUE :-)

All you need to do is insert add=TRUE to the second 
chart to superimpose it on the first chart. You might also 
consider making the second bar a different shade of color 
rather than using shadding lines, then it would only be one 
plot. 

data(HairEyeColor)
a - as.table( apply(HairEyeColor, c(1,2), sum) )
a1-a[1:2,]

barplot(a1,
type=n,
col=c(red,red,blue,blue,purple,purple,green,green),
beside = TRUE )

barplot(a1,
col=1,
density=c(0,7,0,7,0,7,0,7),
beside = TRUE, add=TRUE )



Josh Roofchop wrote:
 
 Hi, basically I am trying to create a grouped bar graph with each group a
 different color and a bar in each group to have shading lines.  Basically
 combine the 2 graphs created below.
 Thanks,
 Josh
 
 data(HairEyeColor)
 a - as.table( apply(HairEyeColor, c(1,2), sum) )
 a1-a[1:2,]
 
 par(mfcol=c(1,2), bg=white)
 
 barplot(a1, 
   type=n,
   col=c(2,2,4,4,6,6,3,3),
 beside = TRUE, )
 
 barplot(a1, 
 col=1,
 density=c(0,7,0,7,0,7,0,7),
 beside = TRUE, )
 
  http://www.nabble.com/file/p18033630/graph.JPG graph.JPG 
 

-- 
View this message in context: 
http://www.nabble.com/Combine-colors-and-shading-lines-tp18033630p18035111.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Combine colors and shading lines

2008-06-20 Thread HBaize


Well perhaps we can take the mystery of why it work for me, but not you, off
line :-)
I'm using R 2.6.1 on a WinXP platform. 

You could try just using shades of color like this:

data(HairEyeColor)
a - as.table( apply(HairEyeColor, c(1,2), sum) )
a1-a[1:2,]

barplot(a1,
type=n,
col=c(red,pink,blue,lightblue,purple,
  lavender,green,lightgreen),
beside = TRUE )




-- 
View this message in context: 
http://www.nabble.com/Combine-colors-and-shading-lines-tp18033630p18036907.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] adding the mean and standard deviation to boxplots

2008-02-04 Thread HBaize

There are many ways to do it. The following will place a blue point on the
boxplot at the mean, then print the mean at the bottom of the plot. In some
plots I've gone too far and included median points and values as well. You
could also put 95% CI on the same plot, but it would get perhaps too busy.


# Plot boxplot of vitamin C subset
bx - boxplot(len ~ dose, data = ToothGrowth,
boxwex = 0.25, at = 1:3 - 0.2,
subset = supp == VC, col = yellow,
main = Guinea Pigs' Tooth Growth,
xlab = Vitamin C dose mg,
ylab = tooth length, ylim = c(0, 35), yaxs = i)

# keep location
at - c(1:length(bx$names))

# find means, plot as points
SubTc -subset(ToothGrowth, supp == VC)
means - by(SubTc$len, SubTc$dose, mean,na.rm=TRUE)
points(at - 0.2, means, pch = 19, col = blue)

# write mean values 
text(at - 0.1, 1, labels = formatC(means, format = f, digits = 1),
pos = 2, cex = 1, col = red)

# Orange juice subset
boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
boxwex = 0.25, at = 1:3 + 0.2,
subset = supp == OJ, col = orange)

# find means, plot as points
SubTo -subset(ToothGrowth, supp == OJ)
meano - by(SubTo$len, SubTo$dose, mean,na.rm=TRUE)
points(at + 0.2,meano, pch = 19, col = blue)

# write mean values 
text(at + 0.3, 1, labels = formatC(meano, format = f, digits = 1),
pos = 2, cex = 1, col = orange)

legend(2, 9, c(Ascorbic acid, Orange juice),
   fill = c(yellow, orange))
--   
THT, I'm sure my R code is not as efficient as it could be. 

Harold Baize
Butte County Department of Behavioral Health




Tom Cohen-2 wrote:
 
 Dear list, 

   How can I add the mean and standard deviation to each of the boxplots
 using the example provided  in the boxplot function?
   
 boxplot(len ~ dose, data = ToothGrowth,
 boxwex = 0.25, at = 1:3 - 0.2,
 subset = supp == VC, col = yellow,
 main = Guinea Pigs' Tooth Growth,
 xlab = Vitamin C dose mg,
 ylab = tooth length, ylim = c(0, 35), yaxs = i)
 boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
 boxwex = 0.25, at = 1:3 + 0.2,
 subset = supp == OJ, col = orange)
 legend(2, 9, c(Ascorbic acid, Orange juice),
fill = c(yellow, orange))
 
 Thanks for any help,
   Tom
 

 -
 
 Jämför pris på flygbiljetter och hotellrum:
 http://shopping.yahoo.se/c-169901-resor-biljetter.html
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org 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 this message in context: 
http://www.nabble.com/adding-the-mean-and-standard-deviation-to-boxplots-tp15271398p15278974.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.