Re: [R] Controlling size of boxplot when it is added in a plot

2007-01-14 Thread Chuck Cleland
Charilaos Skiadas wrote:
 Greetings,
 
   I am trying to add a boxplot to the bottom of a histogram, right  
 between the histogram bars and the x axis. Here is the code I am  
 using at the moment (the par line is probably not relevant for our  
 discussion):
 
 hs - hist(x, breaks = 20, plot = F)
 par(mar = c(3,3,2,1))
 hist(x, breaks = 20, main = NULL, ylim = c(-2, max(hs$counts)))
 boxplot(x, horizontal = T, axes = T, add = T, at = -1)
 
 The problem is the following. As it is, the boxplot restricts itself  
 to the -1 line. I would like it to occupy both the -1 and the -2  
 lines ( I guess more generally I would like to control how much  
 vertical space the embedded boxplot occupies). I tried to set the  
 width parameter in the boxplot, but that seemed to have no effect at  
 all.

  Try setting the boxwex argument instead:

par(mfrow=c(1,2))

set.seed(54321)
x - rnorm(100)
hs - hist(x, breaks = 20, plot = F)
hist(x, breaks = 20, main = NULL, ylim = c(-2, max(hs$counts)))
boxplot(x, horizontal = T, axes = T, add = T, at = -1, boxwex = 1)

hist(x, breaks = 20, main = NULL, ylim = c(-2, max(hs$counts)))
boxplot(x, horizontal = T, axes = T, add = T, at = -1, boxwex = 3)

 On an OT note, I haven't seen this way of combining a histogram with  
 a boxplot (perhaps I haven't looked really hard). I thought it would  
 be useful for my students to see them next to each other, to develop  
 a feeling for what histograms might correspond to what boxplots. Is  
 there perhaps some reason why I should avoid showing those graphs to  
 them like that, that I am not aware of? Or just a reason why I  
 haven't seen them combined like this much?
 
 TIA
 
 Charilaos Skiadas
 Department of Mathematics
 Hanover College
 P.O.Box 108
 Hanover, IN 47243
 
 __
 R-help@stat.math.ethz.ch 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. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch 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] ks.test not working?

2007-01-14 Thread Benjamin Dickgiesser
Hi,

I am trying the following:

library(ismev)
library(evd)

fit - gev.fit(x,show=FALSE)
ks.test(x,pgev,fit$mle[1],fit$mle[2],fit$mle[3])


but I am getting:
Warning message:
cannot compute correct p-values with ties in: ks.test(x, pgev,
fit$mle[1], fit$mle[2], fit$mle[3])

where x is:
 [1]  239   381   43   22159   15619  156
 253  1006
 [18]5  100   10  103   25512   118   68   13  154
  67   125   15
 [35]5  130   47  143  176  573  592  213   54   10   179  198
 293   77   11   44
 [52]6   222   10812   164   70   1247
 134   41  5158
 [69]  200  1692   13   49  218   48   34   74   19   44  1286
  96  238   17  167
 [86]  308  204   416   32   77   14   62   103642
   1114
[103]   22   15   13   12   34   14   1331122   52
  3469   31
[120]  342  34827   52   39   795   88  238   40  294   69
 878   7516
[137]5  381   58   84  588  345  161 12936  403  516   161
1112   54  3812
[154]  526   38   17   20   17  800  1891   57   90   92   16   17
  31   114   17
[171]   129   10   46   14   23111  313


Can anyone tell me why that could be?

Thank you very much,
Benjamin

__
R-help@stat.math.ethz.ch 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] ks.test not working?

2007-01-14 Thread Uwe Ligges


Benjamin Dickgiesser wrote:
 Hi,
 
 I am trying the following:
 
 library(ismev)
 library(evd)
 
 fit - gev.fit(x,show=FALSE)
 ks.test(x,pgev,fit$mle[1],fit$mle[2],fit$mle[3])

1. The test *is* working. It simply warns (and does not report an error) 
that you have ties in your data and the assumption for calculating 
p-values do not hold.
2. The KS tests tends to be very conservative given you specify 
estimated parameters of the distribution.

Uwe Ligges

 
 but I am getting:
 Warning message:
 cannot compute correct p-values with ties in: ks.test(x, pgev,
 fit$mle[1], fit$mle[2], fit$mle[3])
 
 where x is:
  [1]  239   381   43   22159   15619  156
  253  1006
  [18]5  100   10  103   25512   118   68   13  154
   67   125   15
  [35]5  130   47  143  176  573  592  213   54   10   179  198
  293   77   11   44
  [52]6   222   10812   164   70   1247
  134   41  5158
  [69]  200  1692   13   49  218   48   34   74   19   44  1286
   96  238   17  167
  [86]  308  204   416   32   77   14   62   103642
1114
 [103]   22   15   13   12   34   14   1331122   52
   3469   31
 [120]  342  34827   52   39   795   88  238   40  294   69
  878   7516
 [137]5  381   58   84  588  345  161 12936  403  516   161
 1112   54  3812
 [154]  526   38   17   20   17  800  1891   57   90   92   16   17
   31   114   17
 [171]   129   10   46   14   23111  313
 
 
 Can anyone tell me why that could be?
 
 Thank you very much,
 Benjamin
 
 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] PCA (prcomp) details info.

2007-01-14 Thread Bjørn-Helge Mevik
Francesco Savorani wrote:

 I'm handling a matrix dataset composed by a number of variables much
 higher than the objects (900 vs 100) and performing a prcomp
 (centered and scaled) PCA on it. What I get is a Loadings (rotation)
 matrix limited by my lower number of objects and thus 900x100
 instead of 900x900. If I try to manually calculate the matrix scores
 multiplying the original variables (centered and scaled) for such a
 loadings matrix I cannot obtain the same values calculated by R and
 stored on the prcomp$x matrix (100x100).

This works for me:

M - matrix(rnorm(900*100), ncol = 900)
pca - prcomp(M, scale = TRUE)
S - scale(M) %*% pca$rotation
all.equal(S, pca$x) ## = TRUE

-- 
Bjørn-Helge Mevik

__
R-help@stat.math.ethz.ch 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] merging two lists but get indexes

2007-01-14 Thread Teng Sun
Suppose I have two columns of entries, how can I get the union of the
two columns? Please note: I input my columns through excel. These
entries have text format in excel. Also, out of curiosity, how can I
find out the data type of a data frame ?


 a - read.csv(book1.csv)
 a
  n1 n2
1  apple   soda
2 orange  apple
3   soda  green
4red yellow
5  white   blue
6 white

 union(a$n1,a$n2)
[1] 2 3 5 4 6 1

I want the actual names instead of the indexes.

__
R-help@stat.math.ethz.ch 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] merging two lists but get indexes

2007-01-14 Thread Chuck Cleland
Teng Sun wrote:
 Suppose I have two columns of entries, how can I get the union of the
 two columns? Please note: I input my columns through excel. These
 entries have text format in excel. Also, out of curiosity, how can I
 find out the data type of a data frame ?

df - data.frame(n1 = c(apple,orange,soda,red,white,),
 n2 = c(soda,apple,green,yellow,blue,white),
 x = rnorm(6))

 str(df)
'data.frame':   6 obs. of  3 variables:
 $ n1: Factor w/ 6 levels ,apple,orange,..: 2 3 5 4 6 1
 $ n2: Factor w/ 6 levels apple,blue,..: 4 1 3 6 2 5
 $ x : num  -0.0932 -2.0714 -0.9539  0.7249 -0.7039 ...

 lapply(df, class)
$n1
[1] factor

$n2
[1] factor

$x
[1] numeric

 a - read.csv(book1.csv)
 a
   n1 n2
 1  apple   soda
 2 orange  apple
 3   soda  green
 4red yellow
 5  white   blue
 6 white
 
 union(a$n1,a$n2)
 [1] 2 3 5 4 6 1
 
 I want the actual names instead of the indexes.

  You are getting the union of factor levels rather than the union of
the strings.  Try this:

 union(as.character(df$n1), as.character(df$n2))

[1] apple  orange soda
[4] redwhite  
[7] green  yellow blue

 __
 R-help@stat.math.ethz.ch 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch 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] merging two lists but get indexes

2007-01-14 Thread Gabor Grothendieck
Try:

a - read.csv(book1.csv, as.is = TRUE)

to read the columns in as character class rather than the default of
factor .
See ?read.csv

On 1/14/07, Teng Sun [EMAIL PROTECTED] wrote:
 Suppose I have two columns of entries, how can I get the union of the
 two columns? Please note: I input my columns through excel. These
 entries have text format in excel. Also, out of curiosity, how can I
 find out the data type of a data frame ?


  a - read.csv(book1.csv)
  a
  n1 n2
 1  apple   soda
 2 orange  apple
 3   soda  green
 4red yellow
 5  white   blue
 6 white

  union(a$n1,a$n2)
 [1] 2 3 5 4 6 1

 I want the actual names instead of the indexes.

 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] changes in the structure of mer objects?

2007-01-14 Thread joris . dewolf

Dear all,

I try to run the example of lmer and get the following error message.

 library(lme4)
 example(lmer)
lmer (fm1 - lmer(Reaction ~ Days + (Days | Subject), sleepstudy))
[[1]]
Error in get(x, envir, mode, inherits) : variable as.dpoMatrix was not
found

This error message is similar to what I get with other models. It looks
like the mer class has a slightly different structure. Anybody an idea how
to solve this?


I am using R 2.4.1 under linux and the latest releases of lme4 and Matrix

lme4_0.9975-10
Matrix_0.9975-8

 version
   _
platform   x86_64-unknown-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)

Thanks

Joris De Wolf
Phone: +32 9 2429155, E-Mail: [EMAIL PROTECTED]
Postal Address: CropDesign N.V. Technologiepark 3, 9052 Gent Belgium

__
R-help@stat.math.ethz.ch 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] extracting data into different subsets

2007-01-14 Thread Jenny persson
 y Slide Block ID
  441068 -0.020464103 1 15 GFASKTPANQA
  448844 0.061400545 1 41 GFASKTPANQA
  456620 -0.031026896 10 15 GFASKTPANQA
  464396 -0.033166864 10 41 GFASKTPANQA
  472172 -0.108148804 11 15 GFASKTPANQA
  479948 -0.397759508 11 41 GFASKTPANQA
  4167 -0.67283526 1 13 ALPAFSPPAQA
  11943 -0.23982701 1 37 ALPAFSPPAQA
  19719 -0.10169540 10 13 ALPAFSPPAQA
  27495 0.70043972 10 37 ALPAFSPPAQA
  35271 -0.18807235 11 13 ALPAFSPPAQA
  43047 -0.17982104 11 37 ALPAFSPPAQA
  5264 -0.011681805 1 17 ATQAAGAGAVA
  13040 -0.073063462 1 41 ATQAAGAGAVA
  20816 -0.017996429 10 17 ATQAAGAGAVA
  28592 0.010159866 10 41 ATQAAGAGAVA
  36368 -0.056034035 11 17 ATQAAGAGAVA
  44144 -0.346175641 11 41 ATQAAGAGAVA
  5612 -0.7121977 1 18 GFASKTPANQA
  13388 -0.4076580 1 42 GFASKTPANQA
  21164 -0.1864131 10 18 GFASKTPANQA
  28940 -0.1140163 10 42 GFASKTPANQA
  36716 -0.3246222 11 18 GFASKTPANQA
  44492 -0.4355016 11 42 GFASKTPANQA
   
  where there are 4 different IDs and each ID appears twice in two blocks for 
each of 3 slides. I want to extract the data
  in such a way that every ID that appears the first time will be grouped to 
group 1, and the second time to group 2.
  For the data above, it means that the IDs with response y that are in blocks 
15,13,17,18 for each slide will be in group 1 and the rest are in group 2. How 
can I do this in R ?
  Thanks for your help,
  Jenny


-


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] extracting data into different subsets

2007-01-14 Thread jim holtman
try this:

 input -y Slide Block ID
+  441068 -0.020464103 1 15 GFASKTPANQA
+  448844 0.061400545 1 41 GFASKTPANQA
+  456620 -0.031026896 10 15 GFASKTPANQA
+  464396 -0.033166864 10 41 GFASKTPANQA
+  472172 -0.108148804 11 15 GFASKTPANQA
+  479948 -0.397759508 11 41 GFASKTPANQA
+  4167 -0.67283526 1 13 ALPAFSPPAQA
+  11943 -0.23982701 1 37 ALPAFSPPAQA
+  19719 -0.10169540 10 13 ALPAFSPPAQA
+  27495 0.70043972 10 37 ALPAFSPPAQA
+  35271 -0.18807235 11 13 ALPAFSPPAQA
+  43047 -0.17982104 11 37 ALPAFSPPAQA
+  5264 -0.011681805 1 17 ATQAAGAGAVA
+  13040 -0.073063462 1 41 ATQAAGAGAVA
+  20816 -0.017996429 10 17 ATQAAGAGAVA
+  28592 0.010159866 10 41 ATQAAGAGAVA
+  36368 -0.056034035 11 17 ATQAAGAGAVA
+  44144 -0.346175641 11 41 ATQAAGAGAVA
+  5612 -0.7121977 1 18 GFASKTPANQA
+  13388 -0.4076580 1 42 GFASKTPANQA
+  21164 -0.1864131 10 18 GFASKTPANQA
+  28940 -0.1140163 10 42 GFASKTPANQA
+  36716 -0.3246222 11 18 GFASKTPANQA
+  44492 -0.4355016 11 42 GFASKTPANQA
+ 
 x - read.table(textConnection(input), header=TRUE)

 # find the breaks in the ID
 ID.breaks - c(TRUE, diff(as.numeric(x$ID)) != 0)
 group.1 - x[ID.breaks,]
 group.2 - x[!ID.breaks,]

 group.1
 y Slide Block  ID
441068 -0.02046410 115 GFASKTPANQA
4167   -0.67283526 113 ALPAFSPPAQA
5264   -0.01168180 117 ATQAAGAGAVA
5612   -0.71219770 118 GFASKTPANQA
 group.2
 y Slide Block  ID
448844  0.06140055 141 GFASKTPANQA
456620 -0.031026901015 GFASKTPANQA
464396 -0.033166861041 GFASKTPANQA
472172 -0.108148801115 GFASKTPANQA
479948 -0.397759511141 GFASKTPANQA
11943  -0.23982701 137 ALPAFSPPAQA
19719  -0.101695401013 ALPAFSPPAQA
27495   0.700439721037 ALPAFSPPAQA
35271  -0.188072351113 ALPAFSPPAQA
43047  -0.179821041137 ALPAFSPPAQA
13040  -0.07306346 141 ATQAAGAGAVA
20816  -0.017996431017 ATQAAGAGAVA
28592   0.010159871041 ATQAAGAGAVA
36368  -0.056034041117 ATQAAGAGAVA
44144  -0.346175641141 ATQAAGAGAVA
13388  -0.40765800 142 GFASKTPANQA
21164  -0.186413101018 GFASKTPANQA
28940  -0.114016301042 GFASKTPANQA
36716  -0.324622201118 GFASKTPANQA
44492  -0.435501601142 GFASKTPANQA




On 1/14/07, Jenny persson [EMAIL PROTECTED] wrote:

 y Slide Block ID
 441068 -0.020464103 1 15 GFASKTPANQA
 448844 0.061400545 1 41 GFASKTPANQA
 456620 -0.031026896 10 15 GFASKTPANQA
 464396 -0.033166864 10 41 GFASKTPANQA
 472172 -0.108148804 11 15 GFASKTPANQA
 479948 -0.397759508 11 41 GFASKTPANQA
 4167 -0.67283526 1 13 ALPAFSPPAQA
 11943 -0.23982701 1 37 ALPAFSPPAQA
 19719 -0.10169540 10 13 ALPAFSPPAQA
 27495 0.70043972 10 37 ALPAFSPPAQA
 35271 -0.18807235 11 13 ALPAFSPPAQA
 43047 -0.17982104 11 37 ALPAFSPPAQA
 5264 -0.011681805 1 17 ATQAAGAGAVA
 13040 -0.073063462 1 41 ATQAAGAGAVA
 20816 -0.017996429 10 17 ATQAAGAGAVA
 28592 0.010159866 10 41 ATQAAGAGAVA
 36368 -0.056034035 11 17 ATQAAGAGAVA
 44144 -0.346175641 11 41 ATQAAGAGAVA
 5612 -0.7121977 1 18 GFASKTPANQA
 13388 -0.4076580 1 42 GFASKTPANQA
 21164 -0.1864131 10 18 GFASKTPANQA
 28940 -0.1140163 10 42 GFASKTPANQA
 36716 -0.3246222 11 18 GFASKTPANQA
 44492 -0.4355016 11 42 GFASKTPANQA

 where there are 4 different IDs and each ID appears twice in two blocks
 for each of 3 slides. I want to extract the data
 in such a way that every ID that appears the first time will be grouped to
 group 1, and the second time to group 2.
 For the data above, it means that the IDs with response y that are in
 blocks 15,13,17,18 for each slide will be in group 1 and the rest are in
 group 2. How can I do this in R ?
 Thanks for your help,
 Jenny


 -


[[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Controlling size of boxplot when it is added in a plot

2007-01-14 Thread Charilaos Skiadas
Sorry, meant to send this to the list.

On Jan 14, 2007, at 4:28 PM, Charilaos Skiadas wrote:

 On Jan 14, 2007, at 5:50 AM, Chuck Cleland wrote:

   Try setting the boxwex argument instead:

 Thanks Chuck, that does indeed seem to work pretty well. I'm not  
 quite sure what the best way to determine an appropriate size for  
 the boxplot would be, but the following kind of works, at least for  
 the cases I tried. Though I'm not entirely happy with it. And I'm  
 sure I've made a bunch of errors along the way, that someone more  
 experienced in R could spot easily. Feel free to criticize the  
 code. the boxwex default I guess is probably terribly named. One  
 over it is supposed to be the size of the boxplot over the size of  
 the histogram.

 force.odd - function(x) {
   x + 1 - x %% 2;
 }
 boxhist - function(x, boxwex = 8, ...) {
   hs - hist(x, breaks = 20, plot = F)
   space - force.odd(max(floor(hs$counts / boxwex), 1))
   plot(hs, main = NULL, ylim = c(-space, max(hs$counts)), ...)
   boxplot(x, horizontal = T, axes = T, add = T, at = -space/2,  
 boxwex = space)
 }
 x - rweibull(300,1,1); boxhist(x)

 Haris

Haris

__
R-help@stat.math.ethz.ch 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] [R-pkgs] spatstat 1.11-0

2007-01-14 Thread Adrian Baddeley

spatstat 1.11-0

Version 1.11-0 of package 'spatstat' is now available.

Spatstat is a package for the analysis of spatial data, 
mostly point pattern data. See www.spatstat.org

Important changes in version 1.11-0:

New format for ppm objects (objects in old format are still handled).
More stringent checking of function arguments.
Improved handling of pixellation effects.
Extensions to variance-covariance calculations for fitted models.

Adrian Baddeley and Rolf Turner

___
R-packages mailing list
R-packages@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch 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] How to detect if R is running on Mac OS X?

2007-01-14 Thread Philippe Grosjean
This question is probably trivial, but I don't find the answer. I have 
code that is different for Windows, Unix/Linux and Mac OSX. The man page 
of .Platform tells that .Platform$OS.type is the right way to test for 
it... but it also tels that it returns either windows or unix. Is 
Mac OS X reported as unix? If yes, how do I make the difference?
Thanks,

Philippe Grosjean

__
R-help@stat.math.ethz.ch 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.