Re: [R] Fisher test problem

2009-03-22 Thread Viju Moses

As you say, I guess that's not possible. Meanwhile I've got R's results 
verified in Stata

. tabi 17 6 \ 2 1, chi2 exact

  |  col
  row | 1  2 | Total
---+--+--
1 |17  6 |23 
2 | 2  1 | 3 
---+--+--
Total |19  7 |26 


 Pearson chi2(1) =   0.0708   Pr = 0.790
  Fisher's exact = 1.000
  1-sided Fisher's exact = 0.627

The OpenEpi.com output was: (note the 2 tailed P value (fisher test))

Chi Square and Exact Measures of Association
TestValue   p-value(1-tail) p-value(2-tail)
Uncorrected chi square  0.07083 0.3951  0.7901
Yates corrected chi square  0.1813  0.3351  0.6702
Mantel-Haenszel chi square  0.06811 0.3971  0.7941
Fisher exact0.6273  1.25
Mid-P exact 0.3971  0.7942

Thanks for pointing it out.. Had been under the notion that OpenEpi was very... 
strong (being associated with EpiInfo and WHO).

Viju


Tal Galili wrote:

Viju Moses,
Are you sure you got a P-value of 1.25  ?
Since P-value could only be between 0 to 1...

Tal





On Sat, Mar 21, 2009 at 9:17 PM, Viju Moses vijumo...@gmail.com 
mailto:vijumo...@gmail.com wrote:


Hi, I noted a discrepancy between R and openepi when I ran a fisher
test with the same matrix. In R:

  a=matrix(c(1,2,6,17), nrow=2)
  a
   [,1] [,2]
[1,]16
[2,]2   17
  fisher.test(a, conf.int http://conf.int=T)

  Fisher's Exact Test for Count Data

data:  a
p-value = 1
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.02061498 31.73691924
sample estimates:
odds ratio
 1.396646

But in openepi the P value is 1.25. (In another instance too for
other sets of data, I had got a p value of 1 in 3 instances for a
prop.test when I got 3 other answers on a friend's stata software
with the same data. )

I'm using R on Ubuntu Intrepid. Is there anything I'm doing wrong?
Any other packages I have to install?

Thanks in advance

Viju Moses

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




--
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il




__
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] Fisher test problem

2009-03-22 Thread Thomas Lumley
On Sat, 21 Mar 2009 markle...@verizon.net wrote:

 by definition, the one tailed p-value has to be = 0.5 so there is still
 something wrong with your OpenEpi calc.

I think that's a little strong.

Firstly, a one-tailed test in a pre-determined direction can have any p-value.

Secondly, even the smaller one-sided tail probability can be 0.5. The problem 
is discreteness.  It may be that 0.62 is the smaller of p(T=t) and p(T=t), 
and this turns out to be the case.  The other tail probability is 0.83.

OpenEpi should still be thresholding the p-value at 1, but that's just 
cosmetic. 

-thomas


Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
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] Forestplot () box size question

2009-03-22 Thread Thomas Lumley

On Sat, 21 Mar 2009, Gerard Smits wrote:


I have tried several sites (2 in Ca and also Australia) and find only
version 2.14.

Which site did you pull 2.15 from?


I have checked half a dozen sites in various countries, and they all have 2.15 
(even in the Southern Hemisphere -- it's not that updates flow the wrong way 
south of the equator). The CRAN mirror status page says that no mirrors are 
more than a couple of days out of date.

Mostly likely you have an old version of R. CRAN binaries are built only for 
the current version of R.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
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] Estimating LC50 from a Weibull distribution

2009-03-22 Thread Greg
I am attempting to estimate LC50 (analogous to LD50, but uses exposure
concentration rather than dose) by fitting a Weibull model; but I
can't seem to get it to work.  From what I can gather, I should be
using survreg() from the survival package.  The survreg() function
relies on time-to-event data; my data result from 96 h exposures
(i.e., dead or alive after a fixed period; 96 h).  I've tried the
following (doesn't work):

 conc - c(10.3, 10.8, 11.6, 13.2, 15.8, 20.1) # Exposure concentrations
 orign - c(76, 79, 77, 76, 78, 77) # Original number of subjects
 ndead - c(16, 22, 40, 69, 78, 77) # Number dead after 96 h
 d - data.frame(conc=conc, orign=orign, ndead=ndead)
 d$prop - d$ndead/d$orign  # Calculate proportion dead after 96 h
# Adjust for 100% mortalities
 d$prop[d$prop==1.00] - 1-(1/(2*d$orign[d$prop==1.00]))
  fit - survreg(Surv(d$prop) ~ d$conc, dist=weibull)
 summary(fit)

Call:
survreg(formula = Surv(d$prop) ~ d$conc, dist = weibull)
 Value Std. Error zp
(Intercept) -2.254 0.9506 -2.37 0.017737
d$conc   0.135 0.0686  1.97 0.048532
Log(scale)  -1.061 0.3203 -3.31 0.000927

Scale= 0.346

Weibull distribution
Loglik(model)= 0.6   Loglik(intercept only)= -1.6
Chisq= 4.56 on 1 degrees of freedom, p= 0.033
Number of Newton-Raphson Iterations: 5
n= 6

Estimating the LC50 from these coefficients yields an unreasonable
answer:

LC50 = (0.5 + 2.254)/0.135 = 20.4; i.e., higher than the highest
exposure concentration.

I'm sure I'm doing something silly--I just don't know what.

Essentially, I'm trying to do this, but with a Weibull model:

 library(MASS)
 resp - cbind(d$ndead, nalive = d$orign - d$ndead)
 mod - glm(resp ~ d$conc, family = binomial(link = probit))
 result - dose.p(mod, p = 0.5)
 result
 DoseSE
p = 0.5: 11.49053 0.1069564

Any help would be greatly appreciated.

Sincerely,

Greg.

__
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] data analysis. R

2009-03-22 Thread UBC

thx for ur fast responds.
but sorry for asking stupid, i am a turn beginner of R (just trying it out
3 months, and i am taking my first course about it)
so, to tackle this questions,
i was told to use nested design method,
could you actually show me how would u attempt this problem?
(a) Determine if insulation in the house effects the average gas
consumption.
(b) How much extra gas is used when there is no insulation? Provide an
interval estimate as well as a point estimate.

i just got confused by the backgroud information.
We are interested in looking at the effect of insulation on gas
consumption. The average outside temperature (degrees celcius) was also
measured.

so how should my model looks like?
i dont even know what should be my explanatory/response variables...

thx in advance



Gabor Grothendieck wrote:
 
 This works with the example.  If the real data is different it may not
 work.  To run the example below just copy and paste it into R.
 To run with the real data replace textConnection(Lines) with
 insulation.txt everywhere.
 
 Lines - Before insulAfter insul.
 tempgas tempgas
 -0.87.2-0.74.8
 -0.76.90.84.6
 0.46.41.04.7
 2.56.01.44.0
 2.95.81.54.2
 3.25.81.64.2
 3.65.62.34.1
 3.94.72.54.0
 4.25.82.53.5
 4.35.23.13.2
 5.44.93.93.9
 6.04.94.03.5
 6.04.34.03.7
 6.04.44.23.5
 6.24.54.33.5
 6.34.64.63.7
 6.93.74.73.5
 7.03.94.93.4
 7.44.24.93.7
 7.54.04.94.0
 7.53.95.03.6
 7.63.55.33.7
 8.04.06.22.8
 8.53.67.13.0
 9.13.17.22.8
 10.2  2.67.52.6
8.02.7
8.72.8
8.81.3
9.71.5
 
 nfld - count.fields(textConnection(Lines))
 data.lines - readLines(textConnection(Lines))
 data.lines - ifelse(nfld == 2, paste(NA NA, data.lines), data.lines)
 my.data - read.table(textConnection(data.lines), header = TRUE, skip = 1)
 
 
 
 
 On Sat, Mar 21, 2009 at 8:13 PM, UBC cheong0...@hotmail.com wrote:

 so i am having this question
 what should i do if the give data file (.txt) has 4 columns, but
 different
 lengths?
 how can i read them in R?
 any idea for the following problem?


 Gas consumption (1000 cubic feet) was measured before and after
 insulation
 was put into
 a house. We are interested in looking at the effect of insulation on gas
 consumption. The
 average outside temperature (degrees celcius) was also measured. The data
 are included in
 the file insulation.txt.

 (a) Determine if insulation in the house effects the average gas
 consumption.
 (b) How much extra gas is used when there is no insulation? Provide an
 interval estimate
 as well as a point estimate.

 heres the content in insulation.txt  (u can just copy and paste it to
 the
 notepad so can be read in R)

 Before insul    After insul.
 temp    gas     temp    gas
 -0.8    7.2    -0.7    4.8
 -0.7    6.9    0.8    4.6
 0.4    6.4    1.0    4.7
 2.5    6.0    1.4    4.0
 2.9    5.8    1.5    4.2
 3.2    5.8    1.6    4.2
 3.6    5.6    2.3    4.1
 3.9    4.7    2.5    4.0
 4.2    5.8    2.5    3.5
 4.3    5.2    3.1    3.2
 5.4    4.9    3.9    3.9
 6.0    4.9    4.0    3.5
 6.0    4.3    4.0    3.7
 6.0    4.4    4.2    3.5
 6.2    4.5    4.3    3.5
 6.3    4.6    4.6    3.7
 6.9    3.7    4.7    3.5
 7.0    3.9    4.9    3.4
 7.4    4.2    4.9    3.7
 7.5    4.0    4.9    4.0
 7.5    3.9    5.0    3.6
 7.6    3.5    5.3    3.7
 8.0    4.0    6.2    2.8
 8.5    3.6    7.1    3.0
 9.1    3.1    7.2    2.8
 10.2  2.6    7.5    2.6
                8.0    2.7
                8.7    2.8
                8.8    1.3
                9.7    1.5



 thx and any ideas would help.
 --
 View this message in context:
 http://www.nabble.com/data-analysis.-R-tp22641912p22641912.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-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/data-analysis.-R-tp22641912p22643290.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 

[R] Peña, Rodríguez test

2009-03-22 Thread J C

Hi, 

 Anyone have done anything about this Peña, Rodríguez test b4. I have 
never seen it b4 in my life. Now i simply need to write some R code for this. 
any help would be appreciated.

_
Chat with the whole group, and bring everyone together.

[[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.


[R] variance/mean

2009-03-22 Thread rkevinburton
At the risk of appearing ignorant why is the folowing true?

o - cbind(rep(1,3),rep(2,3),rep(3,3))
var(o)
 [,1] [,2] [,3]
[1,]000
[2,]000
[3,]000

and

mean(o)
[1] 2

How do I get mean to return an array similar to var? I would expect in the 
above example a vector of length 3 {1,2,3}.

Thank you for your help.

Kevin

__
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] variance/mean

2009-03-22 Thread Ted Harding
On 22-Mar-09 08:17:29, rkevinbur...@charter.net wrote:
 At the risk of appearing ignorant why is the folowing true?
 
 o - cbind(rep(1,3),rep(2,3),rep(3,3))
 var(o)
  [,1] [,2] [,3]
 [1,]000
 [2,]000
 [3,]000
 
 and
 
 mean(o)
 [1] 2
 
 How do I get mean to return an array similar to var? I would expect in
 the above example a vector of length 3 {1,2,3}.
 
 Thank you for your help.
 Kevin

This is a consequence of (understandable) confusion about how var()
and mean() operate! It is not explicit, in ?var, that if you apply
var() to a matrix, as in your var(o) you get the covariance matrix
between the columns of 'o' -- except where it says (almost as an
aside) that 'var' is just another interface to 'cov'. Hence in
your example var(o) is equivalent to cov(o). Looked at in this
way, it is now straightforward to expect what you got.

This is, of course, different from what you would expect if you apply
var() to a vector, namely the variance of that series of numbers
(a single value).

On the other hand, mean() works differently. According to ?mean:
  Arguments:
 x: An R object.  Currently there are methods for numeric
data frames, numeric vectors and dates.
  [...]
  Value:
 For a data frame, a named vector with the appropriate method
 being applied column by column.

which may have been what you expected. But a matrix is not a data
frame. Instead, it is an array, which (in effect) is a vector with
an attached dimensions attribute which tells R how to chop it up
into columns etc. -- whereas a data frame has its by-column
structure built in to it.

Now: ?mean says nothing about matrices. Nothing whatever.
So you have to find out the hard way that mean(o) treats the array
'o' as a vector, ignoring its dimensions attribute. Hence you
get a single number, which is the mean of all the values in the
matrix.

In order to get what you are apparently looking for (the means of
the columns of 'o'), you could:

a) (the smooth way) use the apply() function, causing mean() to be
   applied to the second dimension (columns) of 'o':

   apply(o,2,mean)
   # [1] 1 2 3

b) (the heavy way) take a hint from ?mean and feed it a data frame:

   mean(as.data.frame(o))
   # V1 V2 V3
   #  1  2  3 

Hoping this helps to clarify things!
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 22-Mar-09   Time: 09:01:40
-- XFMail --

__
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] variance/mean

2009-03-22 Thread Wacek Kusnierczyk
rkevinbur...@charter.net wrote:
 At the risk of appearing ignorant why is the folowing true?

 o - cbind(rep(1,3),rep(2,3),rep(3,3))
 var(o)
  [,1] [,2] [,3]
 [1,]000
 [2,]000
 [3,]000

 and

 mean(o)
 [1] 2

 How do I get mean to return an array similar to var? I would expect in the 
 above example a vector of length 3 {1,2,3}.
   

you may well be ignorant about how var works with matrices, but this
does not mean it's your fault.  the documentation is typically cryptical.

when you apply var to a single matrix, it will compute covariances
between its columns rather than the overall variance:

set.seed(0)
x = matrix(rnorm(4), 2, 2)
   
var(x)
#[,1] [,2]
# [1,]  1.2629543 1.329799
# [2,] -0.3262334 1.272429

matrix(nrow=2, ncol=2, byrow=TRUE, c(
   cov(x[,1], x[,1]), cov(x[,1], x[,2]),
   cov(x[,2], x[,1]), cov(x[,2], x[,2])))
  
vQ

__
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] package sowas

2009-03-22 Thread ronggui
There is a binary version for Windows in the homepage of it.
http://www.cru.uea.ac.uk/~douglas/software/sowas_0.94.zip

You can find more on http://tocsy.agnld.uni-potsdam.de/wavelets/

Best

2009/3/22 stephen sefick ssef...@gmail.com:
 You must go to his website because it is not on CRAN.  I have built it
 on mac osx by installing it with R CMD install.  This should work on
 other unix platforms.

 Stephen Sefick

 On Sat, Mar 21, 2009 at 9:26 PM,  mau...@alice.it wrote:
 I cannot find sowas package by Douglas Mauran in CRAN packages list-
 On which platforms does sowas run ?
 Has anybody used such a package at all ?

 hHank you very much,
 Maura



 tutti i telefonini TIM!


        [[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.




 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

                                                                -K. Mullis

 __
 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.




-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

A sociologist is someone who, when a beautiful women enters the room
and everybody look at her, looks at everybody.

__
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] limiting simulated animal movement

2009-03-22 Thread Jim Lemon

Umesh Srinivasan wrote:

Hi,

I am trying to simulate animal movement in a gridded landscape made up of
cells. At each time step (iteration), the animal moves from one cell to
another in a random fashion.
...
The problem is
1. I want to limit animals to a pre-defined circular home range
2. I want to limit animals to the borders of the landscape itself


I tried to limit animals to their home range using:

if (sqrt((x - a)^2 + (y - b)^2)  radius.range) {
a - a[i-1]
b - b[i-1]
}

Where x and y are co-ordinates for the centre of the home range

But this is not working - giving NA values for x and y co-ordinates. Does
anyone know what to do?
  

Hi Umesh,
The reason the above is generating NAs may be that you have defined x 
and y outside the function you are using to simulate movement. In 
general, an animal would slow down near the edges of a range, so 
something like this might give you a more realistic simulated exploration:


explore.circle-function(x,y,radius,nsteps) {
plot(0,xlim=c(x-radius-1,x+radius+1),ylim=c(y-radius-1,y+radius+1),type=n)
newx-newy-rep(NA,nsteps+1)
xyprob-matrix(NA,ncol=6,nrow=nsteps+1)
newx[1]-x
newy[1]-y
for(astep in 1:nsteps) {
 xprob-c((newx[astep]-(x-radius))/radius,1,(x+radius-newx[astep])/radius)
 newx[astep+1]-newx[astep]+sample(-1:1,1,prob=xprob)
 yprob-c((newy[astep]-(y-radius))/radius,1,(y+radius-newy[astep])/radius)
 newy[astep+1]-newy[astep]+sample(-1:1,1,prob=yprob)
 text(newx[astep],newy[astep],astep)
 xyprob[astep,]-c(xprob,yprob)
}
text(newx[nsteps+1],newy[nsteps+1],nsteps+1)
return(cbind(newx,newy,xyprob))
}

This is not guaranteed to stay inside the circle, so you might have to 
add more constraints.


Jim

__
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] limiting simulated animal movement

2009-03-22 Thread Umesh Srinivasan
Wow, that was really quick, thanks a lot. Will try this and get back to you.

Cheers,
Umesh

On Sun, Mar 22, 2009 at 3:52 PM, Jim Lemon j...@bitwrit.com.au wrote:

 Umesh Srinivasan wrote:

 Hi,

 I am trying to simulate animal movement in a gridded landscape made up of
 cells. At each time step (iteration), the animal moves from one cell to
 another in a random fashion.
 ...
 The problem is
 1. I want to limit animals to a pre-defined circular home range
 2. I want to limit animals to the borders of the landscape itself


 I tried to limit animals to their home range using:

 if (sqrt((x - a)^2 + (y - b)^2)  radius.range) {
 a - a[i-1]
 b - b[i-1]
 }

 Where x and y are co-ordinates for the centre of the home range

 But this is not working - giving NA values for x and y co-ordinates. Does
 anyone know what to do?


 Hi Umesh,
 The reason the above is generating NAs may be that you have defined x and y
 outside the function you are using to simulate movement. In general, an
 animal would slow down near the edges of a range, so something like this
 might give you a more realistic simulated exploration:

 explore.circle-function(x,y,radius,nsteps) {

 plot(0,xlim=c(x-radius-1,x+radius+1),ylim=c(y-radius-1,y+radius+1),type=n)
 newx-newy-rep(NA,nsteps+1)
 xyprob-matrix(NA,ncol=6,nrow=nsteps+1)
 newx[1]-x
 newy[1]-y
 for(astep in 1:nsteps) {
  xprob-c((newx[astep]-(x-radius))/radius,1,(x+radius-newx[astep])/radius)
  newx[astep+1]-newx[astep]+sample(-1:1,1,prob=xprob)
  yprob-c((newy[astep]-(y-radius))/radius,1,(y+radius-newy[astep])/radius)
  newy[astep+1]-newy[astep]+sample(-1:1,1,prob=yprob)
  text(newx[astep],newy[astep],astep)
  xyprob[astep,]-c(xprob,yprob)
 }
 text(newx[nsteps+1],newy[nsteps+1],nsteps+1)
 return(cbind(newx,newy,xyprob))
 }

 This is not guaranteed to stay inside the circle, so you might have to add
 more constraints.

 Jim



[[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.


Re: [R] bargraph.CI change se for sd

2009-03-22 Thread herwig


Thanks for the solution.
And sorry about the not workable example (I actually edited the post a
minute after posting it -too late I am afraid).

 


  library(sciplot)
  bargraph.CI(peptide, surface, group=adjunct,data = y)
Error in eval(substitute(subset), envir = data) : object y not found
#groan, ... why can't people offer a workable example?
  data(ToothGrowth)
# se as default
  bargraph.CI(x.factor = dose, response = len, data = ToothGrowth)
# create desired function
  bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
   ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )



-- 
View this message in context: 
http://www.nabble.com/bargraph.CI-change-se-for-sd-tp22633770p22644429.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] Help plotting a histogram of X~Exp(1)

2009-03-22 Thread BowlesMcCann

I want to plot a histogram of X~Exp(1) where X is the sum of Y + Z. To do
this, should I simulate values of Y and Z using Y-runif(100) and
Z-runif(100)? And where do I go from there?

Many thanks.
-- 
View this message in context: 
http://www.nabble.com/Help-plotting-a-histogram-of-X%7EExp%281%29-tp22645091p22645091.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] Plot and Boxplot in the same graph

2009-03-22 Thread johnhj

I tried to do it with:

 y - rnorm(100)
 x - gl(2,50)
 boxplot(x,y)
 points(x,y)

But the problem is, that the the y coordinates are shown for the boxplot and
not for points(x,y)
Is it possible to show the graph with the (x,y) coordinates with the
points() function and the boxplots only for the x coordinates. A better
solution could be to have a seperated y axis on the left side for the
boxplots().

Is it possible to do it in this was ?

 


Paul Johnson-11 wrote:
 
 On Fri, Mar 20, 2009 at 10:02 PM, johnhj jhar...@web.de wrote:

 Hii,

 Is it possible, to use the plot() funktion and the boxplot() funktion
 together ?
 I will plot a simple graph and additionally to the graph on certain
 places
 boxplots. I have imagined to plot the graph a little bit transparency and
 show in the same graph on certain places boxplots

 Is it possible to do it in this way ?

 greetings,
 johnh
 --

 Run the boxplot first, then use points() or other subsidiary plot
 functions to add the points in the figure.
 
 y - rnorm(100)
 x - gl(2,50)
 boxplot(x,y)
 points(x,y)
 
 
 -- 
 Paul E. Johnson
 Professor, Political Science
 1541 Lilac Lane, Room 504
 University of Kansas
 
 __
 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/Plot-and-Boxplot-in-the-same-graph-tp22632355p22645076.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] Estimating LC50 from a Weibull distribution

2009-03-22 Thread Christian Ritz
Hi Greg,

you can use the extension package 'drc' from CRAN:


conc - c(10.3, 10.8, 11.6, 13.2, 15.8, 20.1) # Exposure concentrations
orign - c(76, 79, 77, 76, 78, 77) # Original number of subjects

ndead - c(16, 22, 40, 69, 78, 77) # Number dead after 96 h
d - data.frame(conc=conc, orign=orign, ndead=ndead)

## Loading 'drc'
library(drc)

## Fitting model assuming 100% mortality for high concentrations
## and 0% for concentration 0
d.m1-drm(ndead/orign~conc, weight=orign, data=d, fct=W1.2(), type=binomial)
plot(d.m1)

## Fitting model where mortality at conc=0 is estimated
## (ad hoc adjustments should be avoided)
d.m2-update(d.m1, fct=W1.3u())
plot(d.m2, add=TRUE, type=none, lty=2)

## Calculating LC50
ED(d.m2, 50)


Note that you don't really have time-to-event data as you only have observations
reflecting the effect of exposure at one particular time point (96h). 
Time-to-event data
occur if exposure is monitored repeatedly over time, in several intervals or at 
several
time points, e.g. at 24h, 48h, and 96h, possibly subject to censoring. 
Therefore the above
analysis is based on binomial distributions that are often appropriate for 
quantal data.

Note also, that in ecotoxicology Weibull model may refer to one several 
related models
depending on which guidelines, papers, or software you refer to.


Christian

__
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] Help plotting a histogram of X~Exp(1)

2009-03-22 Thread David Winsemius
If you run this you get sensible output, but whether it meets you  
needs depends on what you meant by Exp(1):


 Y - rnorm(100)
 Z - rnorm(100)
 X - exp(Y+Z)
 hist(X)

If you are looking for methods to handle random variables in R, you  
may want to look at the series of packages all beginning with distr:

   distr, distrDoc, distrEx, distrMod, distrSim, distrTeach, distrTEst.

--
David Winsemius
On Mar 22, 2009, at 7:19 AM, BowlesMcCann wrote:



I want to plot a histogram of X~Exp(1) where X is the sum of Y + Z.  
To do

this, should I simulate values of Y and Z using Y-runif(100) and
Z-runif(100)? And where do I go from there?

Many thanks.
--
View this message in context: 
http://www.nabble.com/Help-plotting-a-histogram-of-X%7EExp%281%29-tp22645091p22645091.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] libRlapack.so not found

2009-03-22 Thread Johannes Huesing
Johannes Huesing johan...@huesing.name [Sat, Mar 21, 2009 at 08:12:05AM CET]:
 Whenever I try to load the Matrix package, I get the following error
 message:
 libRlapack.so: cannot open shared object file: No such file or directory
 A file with that name is indeed not on the hard disk.

http://lmgtfy.com/?q=libRlapack

Thanks to Dirk who provided the answer about a year ago.

sudo apt-get remove r-cran-matrix did it for me.

-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

__
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] R: package sowas

2009-03-22 Thread mauede
I downloaded it. But I could not find the installation executable file. 
How can I install it on Windows XP ?
Thank you.
Maura



-Messaggio originale-
Da: ronggui [mailto:ronggui.hu...@gmail.com]
Inviato: dom 22/03/2009 10.47
A: mau...@alice.it; r-help@r-project.org
Oggetto: Re: [R] package sowas
 
There is a binary version for Windows in the homepage of it.
http://www.cru.uea.ac.uk/~douglas/software/sowas_0.94.zip

You can find more on http://tocsy.agnld.uni-potsdam.de/wavelets/

Best

2009/3/22 stephen sefick ssef...@gmail.com:
 You must go to his website because it is not on CRAN.  I have built it
 on mac osx by installing it with R CMD install.  This should work on
 other unix platforms.

 Stephen Sefick

 On Sat, Mar 21, 2009 at 9:26 PM,  mau...@alice.it wrote:
 I cannot find sowas package by Douglas Mauran in CRAN packages list-
 On which platforms does sowas run ?
 Has anybody used such a package at all ?

 hHank you very much,
 Maura



 tutti i telefonini TIM!


        [[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.




 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

                                                                -K. Mullis

 __
 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.




-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

A sociologist is someone who, when a beautiful women enters the room
and everybody look at her, looks at everybody.




tutti i telefonini TIM!


[[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.


Re: [R] R: package sowas

2009-03-22 Thread ronggui
Executable file is not required.  You must install R first, then you
click packages--install package(s) from local zip file ... to
install the sowas package.

Best

2009/3/22  mau...@alice.it:
 I downloaded it. But I could not find the installation executable file.
 How can I install it on Windows XP ?
 Thank you.
 Maura



 -Messaggio originale-
 Da: ronggui [mailto:ronggui.hu...@gmail.com]
 Inviato: dom 22/03/2009 10.47
 A: mau...@alice.it; r-help@r-project.org
 Oggetto: Re: [R] package sowas

 There is a binary version for Windows in the homepage of it.
 http://www.cru.uea.ac.uk/~douglas/software/sowas_0.94.zip

 You can find more on http://tocsy.agnld.uni-potsdam.de/wavelets/

 Best

 2009/3/22 stephen sefick ssef...@gmail.com:
 You must go to his website because it is not on CRAN.  I have built it
 on mac osx by installing it with R CMD install.  This should work on
 other unix platforms.

 Stephen Sefick

 On Sat, Mar 21, 2009 at 9:26 PM,  mau...@alice.it wrote:
 I cannot find sowas package by Douglas Mauran in CRAN packages list-
 On which platforms does sowas run ?
 Has anybody used such a package at all ?

 hHank you very much,
 Maura



 tutti i telefonini TIM!


        [[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.




 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

                                                                -K. Mullis

 __
 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.




 --
 HUANG Ronggui, Wincent
 Tel: (00852) 3442 3832
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html

 A sociologist is someone who, when a beautiful women enters the room
 and everybody look at her, looks at everybody.



 Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e
 tutti i telefonini TIM!
 Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer



-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

__
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] R: R: package sowas

2009-03-22 Thread mauede
OK.Done. Tank you very much.
Maura

-Messaggio originale-
Da: ronggui [mailto:ronggui.hu...@gmail.com]
Inviato: dom 22/03/2009 15.40
A: mau...@alice.it
Cc: r-help@r-project.org
Oggetto: Re: R: [R] package sowas
 
Executable file is not required.  You must install R first, then you
click packages--install package(s) from local zip file ... to
install the sowas package.

Best

2009/3/22  mau...@alice.it:
 I downloaded it. But I could not find the installation executable file.
 How can I install it on Windows XP ?
 Thank you.
 Maura



 -Messaggio originale-
 Da: ronggui [mailto:ronggui.hu...@gmail.com]
 Inviato: dom 22/03/2009 10.47
 A: mau...@alice.it; r-help@r-project.org
 Oggetto: Re: [R] package sowas

 There is a binary version for Windows in the homepage of it.
 http://www.cru.uea.ac.uk/~douglas/software/sowas_0.94.zip

 You can find more on http://tocsy.agnld.uni-potsdam.de/wavelets/

 Best

 2009/3/22 stephen sefick ssef...@gmail.com:
 You must go to his website because it is not on CRAN.  I have built it
 on mac osx by installing it with R CMD install.  This should work on
 other unix platforms.

 Stephen Sefick

 On Sat, Mar 21, 2009 at 9:26 PM,  mau...@alice.it wrote:
 I cannot find sowas package by Douglas Mauran in CRAN packages list-
 On which platforms does sowas run ?
 Has anybody used such a package at all ?

 hHank you very much,
 Maura



 tutti i telefonini TIM!


        [[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.




 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

                                                                -K. Mullis

 __
 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.




 --
 HUANG Ronggui, Wincent
 Tel: (00852) 3442 3832
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html

 A sociologist is someone who, when a beautiful women enters the room
 and everybody look at her, looks at everybody.



 Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e
 tutti i telefonini TIM!

er



-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html




tutti i telefonini TIM!


[[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.


[R] Multiple Comparisons for (multicomp - glht) for glm negative binomial (glm.nb)

2009-03-22 Thread lara harrup (IAH-P)
Hi
 
I have some experimental data where I have counts of the number of
insects collected to different trap types rotated through 5 different
location (variable -location), 4 different chemical attractants [A, B,
C, D]  were applied to the traps (variable - semio) and all were
trialled at two different CO2 release rates [1, 2] (variable CO2) I also
have a selection of continuous variables measuring meteorological
conditions to account for any bias cause by changing weather conditions,
the data is over dispersed so I have fitted a negative binomial glm
(glm.nb) and simplified using stepAIC from the MASS package etc.
 
There are significant differences in the number of insects attracted to
the different chemical (semio) and to the two different CO2 (release
rates) I have then used the glht function from the multcomp package to
do multiple comparisons to see what the specific differences between the
levels are for semio and CO2 using the code below which works great but
what I would like to do is to do comparisons combining the factors e.g a
comparison for semioA at CO at level 1 vs Semio A at CO2 level 2  etc to
see which is the best combination, is this possible or should I have
started of with my counts already split up into this e.g. a treatment
variable(semioA at CO2 level 1 = A1, semioA at CO2 level 2 = A2 etc), I
started with them this way as we have no prior knowledge that increasing
co2 will have any effect.
 
I have had a quick try with the data split into a treatment factor
(instead of semio and CO2 level) but I can not get convergence with
glm.nb I think this may be to do with to many zeros in the data set, do
you know if glht or another multiple comparison will work or
zeroinflated negative binomial regression(zeroinfl() from the pscl
library)?
 
Any help or ideas will be gratefully appreciated. Many thanks in
advance.
 
Lara
 
 
semiochemical -read.csv(G:/semiochemical_data.csv, header=T)

semiochemical$location2-factor(semiochemical$location)
levels(semiochemical$location2)-c(1,2,3,4,5)
 
semiochemical$semio2-factor(semiochemical$semio)
levels(semiochemical$semio2)-c(A,B,C,D)
 
semiochemical$CO22-factor(semiochemical$CO2)
levels(semiochemical$CO22)-c(1,2)
 
model1-glm.nb(total ~ semio + CO2 + location + temp + mean.wind.speed)
 
model.glht.Semio - glht(model1, linfct=mcp(semio=Tukey))
model.glht.CO2 - glht(model1, linfct=mcp(CO2=Tukey))
 

[[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.


[R] Problems with combining plots

2009-03-22 Thread johnhj

Hii,

I will combine some plots. Like this example here
http://www.statmethods.net/advgraphs/layout.html I tired to do it for 2
plots but without success.

Here is my code:

test-read.table(file=D:/file.txt)
space-read.table(file=D:/space.txt)

space$gruppe - 502*rep(1:6, each=7)
x- c(test$V1)
y- c(test$V2)

par(mfrow=c(1,1)) 

png(filename = D:/example.png, width = 640, height = 480, pointsize = 12,
bg = white,  res = NA)

boxplot(V2 ~ gruppe , data = space , col = lightgray,boxwex=0.2)
plot(panel.first=grid(ny=NULL,nx=NULL),x,y, xlab = Zeit(sec), ylab
=Datenrate(MBit(sec)),ylim=c(0,40), col =purple, type =l, main
=combined plots,lwd=2)

dev.off()


What is the mistake in my code ? 


-- 
View this message in context: 
http://www.nabble.com/Problems-with-combining-plots-tp22646692p22646692.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] Help plotting a histogram of X~Exp(1)

2009-03-22 Thread BowlesMcCann

Thank you very much!
 
:)



David Winsemius wrote:
 
 If you run this you get sensible output, but whether it meets you  
 needs depends on what you meant by Exp(1):
 
   Y - rnorm(100)
   Z - rnorm(100)
   X - exp(Y+Z)
   hist(X)
 
 If you are looking for methods to handle random variables in R, you  
 may want to look at the series of packages all beginning with distr:
 distr, distrDoc, distrEx, distrMod, distrSim, distrTeach, distrTEst.
 
 -- 
 David Winsemius
 On Mar 22, 2009, at 7:19 AM, BowlesMcCann wrote:
 

 I want to plot a histogram of X~Exp(1) where X is the sum of Y + Z.  
 To do
 this, should I simulate values of Y and Z using Y-runif(100) and
 Z-runif(100)? And where do I go from there?

 Many thanks.
 -- 
 View this message in context:
 http://www.nabble.com/Help-plotting-a-histogram-of-X%7EExp%281%29-tp22645091p22645091.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.
 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 
 __
 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.
 
 
:clap::clap::clap:
-- 
View this message in context: 
http://www.nabble.com/Help-plotting-a-histogram-of-X%7EExp%281%29-tp22645091p22645942.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] Converting Matrix into List - problem (urgent)

2009-03-22 Thread Nidhi Kohli
Hi,
 
I'm trying to convert Matrix into a list format and have written the following 
code:
 
path = (C:/2PL_Alpha_C_2PL_Loading)
setwd(path)
getwd()
 
congeneric = matrix(rep(NA,36),nrow=6,ncol=6)
conFirst = matrix(rep(NA,36),nrow=6,ncol=6)
conFirstTwenty = rep(NA, 20)
k = 1
 
#Reading all the Alpha and Congeneric 2PL values into variables
alpha - read.table(2PLAlphaGenPars_1.dat, header=FALSE)
congeneric - read.table(C_parameter_estimates_1.dat, header=FALSE)
 
for (i in 1:6)
{
 for (j in 1:6)
  {
   conFirst[i,j] = as.matrix(congeneric[i,j])
   if (k = 20)
   {
conFirstTwenty[k] = as.list(conFirst[i,j])
k = k + 1
   }
  
  }
}
 
In the above program i'm picking up the first 20 values from the Matrix and 
putting it in a list format. This is what i see now in conFirstTwenty:
 
[[1]]
[1] 0.520404D+00
[[2]]
[1] 0.601942D+00
[[3]]
[1] 0.603340D+00
[[4]]
[1] 0.655582D+00
[[5]]
[1] 0.490995D+00
.
..
..
...
[[20]]
[1] 0.627368D+00
 
I want to remove the Column name and Row name from the above output. Any help 
on this will be greatly appreciated (I'm open to any other alternative way to 
convert Matrix into List also)
 
P.S. I have tried using row.names and col.names in the read.table function 
however getting error col.names object not found. I don't know what does this 
mean
 
Regards,

Nidhi Kohli
***
Nidhi Kohli, M.Ed.
Doctoral Student
Department of Measurement, Statistics 
 and Evaluation 
University of Maryland
1230 Benjamin Building
College Park, MD 20742-1115

e-mail: nid...@umd.edu

__
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] Accuracy of R and other platforms

2009-03-22 Thread Karl Ove Hufthammer
Alejandro C. Frery:

 @ARTICLE{AlmironSilvaMM:2009,
 author = {Almiron, M. and Almeida, E. S. and Miranda, M.},
 title = {The Reliability of Statistical Functions in Four Software
 Packages Freely used in Numerical Computation},
 journal = {Brazilian Journal of Probability and Statistics},
 year = {in press},
 volume = {Special Issue on Statistical Image and Signal Processing},
 url = {http://www.imstat.org/bjps/}}
 
 is freely available under the Future Papers link. It makes a nice
 comparison of the numerical properties of R, Ox, Octave and Python.

Thanks for posting this. I’m happy to see that the results for R were 
generally excellent, and almost always better than for the three other 
software packages.

But there were a few cases where R did not turn out to be the winner.
Rather surprising that Ox was better than R for computing the 
autocorrelation coefficient for two of the datasets, given its terrible 
results for the standard deviation. Anybody have any ideas why?

-- 
Karl Ove Hufthammer

__
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] Converting Matrix into List - problem (urgent)

2009-03-22 Thread Nidhi Kohli
Hi,

I'm trying to convert Matrix into a list format and have written the following 
code:

path = (C:/2PL_Alpha_C_2PL_Loading)
setwd(path)
getwd()

congeneric = matrix(rep(NA,36),nrow=6,ncol=6)
conFirst = matrix(rep(NA,36),nrow=6,ncol=6)
conFirstTwenty = rep(NA, 20)
k = 1

#Reading all the Alpha and Congeneric 2PL values into variables
alpha - read.table(2PLAlphaGenPars_1.dat, header=FALSE)
congeneric - read.table(C_parameter_estimates_1.dat, header=FALSE)

for (i in 1:6)
{
for (j in 1:6)
 {
  conFirst[i,j] = as.matrix(congeneric[i,j])
  if (k = 20)
  {
   conFirstTwenty[k] = as.list(conFirst[i,j])
   k = k + 1
  }
 
 }
}

In the above program i'm picking up the first 20 values from the Matrix and 
putting it in a list format. This is what i see now in conFirstTwenty:

[[1]]
[1] 0.520404D+00
[[2]]
[1] 0.601942D+00
[[3]]
[1] 0.603340D+00
[[4]]
[1] 0.655582D+00
[[5]]
[1] 0.490995D+00
.
..
..
...
[[20]]
[1] 0.627368D+00

I want to remove the Column name and Row name from the above output. Any help 
on this will be greatly appreciated (I'm open to any other alternative way to 
convert Matrix into List also)

P.S. I have tried using row.names and col.names in the read.table function 
however getting error col.names object not found. I don't know what does this 
mean

Regards,

Nidhi Kohli
***
Nidhi Kohli, M.Ed.
Doctoral Student
Department of Measurement, Statistics
and Evaluation
University of Maryland
1230 Benjamin Building
College Park, MD 20742-1115

e-mail: nid...@umd.edu

__
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] Forestplot () box size question

2009-03-22 Thread Gerard Smits
Yes, my R is a few versions old.  I did not realize that the package 
version was dependent on the R version.  Thanks.  Gerard

PS was able to apply the code suggested by David W. to the 2.14 
version and got it to work.

At 12:32 AM 3/22/2009, Thomas Lumley wrote:
On Sat, 21 Mar 2009, Gerard Smits wrote:

I have tried several sites (2 in Ca and also Australia) and find only
version 2.14.

Which site did you pull 2.15 from?

I have checked half a dozen sites in various countries, and they all 
have 2.15 (even in the Southern Hemisphere -- it's not that updates 
flow the wrong way south of the equator). The CRAN mirror status 
page says that no mirrors are more than a couple of days out of date.

Mostly likely you have an old version of R. CRAN binaries are built 
only for the current version of R.

  -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle



[[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.


Re: [R] Converting Matrix into List - problem (urgent)

2009-03-22 Thread Nidhi Kohli
Hi JiHo,

Thank you so much for the quick reply. Let me explain you what I want. I have a 
data file in the following format:

0.610251D+00 0.615278D+00 0.583581D+00 0.560295D+00
0.501325D+00 0.639512D+00 0.701607D+00 0.544963D+00
0.589746D+00 0.648588D+00 0.608216D+00 0.582599D+00
0.625204D+00 0.523065D+00 0.627593D+00 0.621433D+00
0.733730D+00 0.498495D+00 0.748673D+00 0.591025D+00
0.578333D+00 0.564807D+00 0.652199D+00 0.579333D+00

I'm reading this file into a variable named congeneric (see my code) and now 
trying to pick up first 20 values and need these 20 values in a list format like

0.610251D+00 (row 1, col 1)
0.615278D+00 (row 1, col 2)
0.583581D+00 (row 1, col 3)
...


Can you tell me how can i achieve this? I think i'm pretty close but don't know 
how to remove the Row Name and Col. name from the conFirstTwenty list (see my 
code)

I really appreciate your help

Regards
Nidhi





 Original message 
Date: Sun, 22 Mar 2009 12:54:34 -0400
From: JiHO jo.li...@gmail.com  
Subject: Re: [R] Converting Matrix into List - problem (urgent)  
To: Nidhi Kohli nid...@umd.edu, R Help r-h...@stat.math.ethz.ch

On 2009-March-22  , at 12:26 , Nidhi Kohli wrote:

 I want to remove the Column name and Row name from the above output.  
 Any help on this will be greatly appreciated (I'm open to any other  
 alternative way to convert Matrix into List also)

What are you trying to achieve exactly? Do you just want to print a  
clean output on the screen? If yes, look at `cat`, or `print`.

JiHO
---
http://jo.irisson.free.fr/


__
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] Hollander's test of bivariate symmetry

2009-03-22 Thread joseph . g . boyer
Couldn't find it anywhere, so for future users who stumble on this thread, 
here is some code.
Note: If your data has missing values, delete those observations from the 
data first before running this code.

Place these functions in the global environment (ie run the code below).

Then, to obtain the test statistic: H_bisym_stat(x,y)  (x and y are the 
two vectors you are comparing).

To obtain a p-value: H_bisym_stat(x,y). The p-value is calculated via a 
Monte Carlo algorithm.

You can use the permutations argument to H_bisym_stat to increase the 
number of Monte Carlo samples.


#Hollander's test of bivariate symmetry

#Calculating test statistic for Hollander's test of bivariate 
symmetry

H_bisym_stat - function(x,y){

minXY - pmin(x,y);
sortX - x[order(minXY)];
sortY - y[order(minXY)];
minXY - pmin(sortX, sortY);
R - as.numeric(sortX = sortY);
maxXY - pmax(sortX,sortY);
 
D1 - matrix(0, length(x), length(x));
D2 - matrix(0, length(x), length(x));

for (i in 1:length(x)){

for (j in 1:length(x)){

D1[i,j] = as.numeric(minXY[j]  
maxXY[i]  maxXY[i] = maxXY[j]);
D2[i,j] = as.numeric(minXY[i] = 
minXY[j]);

}

}

D = D1*D2;

S = 2*R - 1;

T = t( t(S) %*% D);

H_squared = (1/length(x)^2)*( t(T) %*% T );

H_squared};

#Create a permutation sample for paired data;

permsamp_paired - function(x,y){

new - rbinom(length(x),1,0.5);
x_new - x*new + y*(1 - new);
y_new - y*new + x*(1 - new);

list(x_new = x_new, y_new = y_new)};


#Calculate pvalue for Hollander statistic;

H_bisym_pv - function(x, y, permutations = 1000){

H_squared = H_bisym_stat(x=x, y=y);

numb_greater = 0;

for (i in 1:permutations) {

newvars - permsamp_paired(x=x, y=y);
x_new - newvars$x_new;
y_new - newvars$y_new;

newstat - H_bisym_stat(x=x_new, y=y_new);

numb_greater = numb_greater + 
as.numeric(newstat = H_squared);
 
}

pv - numb_greater/permutations;

pv };


Joe Boyer
Statistical Sciences 
GlaxoSmithKline
[[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.


Re: [R] Converting Matrix into List - problem (urgent)

2009-03-22 Thread JiHO

On 2009-March-22  , at 13:06 , Nidhi Kohli wrote:

I'm reading this file into a variable named congeneric (see my code)  
and now trying to pick up first 20 values and need these 20 values  
in a list format like


0.610251D+00 (row 1, col 1)
0.615278D+00 (row 1, col 2)
0.583581D+00 (row 1, col 3)
...




Basically you want a list in which each element as only one value in  
it. And those elements are the first twenty of the previous matrix,  
reading by line, then column.


I am not sure about:

I want to remove the Column name and Row name from the above output.  
Any help on this will be greatly appreciated (I'm open to any other  
alternative way to convert Matrix into List also)


I don't see any column or row name in


[[1]]
[1] 0.520404D+00
[[2]]
[1] 0.601942D+00
[[3]]
[1] 0.603340D+00
[[4]]
[1] 0.655582D+00
[[5]]
[1] 0.490995D+00
.
..
..
...
[[20]]
[1] 0.627368D+00


That's just a the way a list is printed. If you just want a clean  
visual output, then use cat in a for loop.


So I guess my question is what are you trying to achieve with that?  
What do you need the list for? It would help to know (a bit) of the  
general context to help you.


JiHO
---
http://jo.irisson.free.fr/

__
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] Converting Matrix into List - problem (urgent)

2009-03-22 Thread JiHO

On 2009-March-22  , at 13:06 , Nidhi Kohli wrote:

Thank you so much for the quick reply. Let me explain you what I  
want. I have a data file in the following format:


0.610251D+00 0.615278D+00 0.583581D+00 0.560295D+00
0.501325D+00 0.639512D+00 0.701607D+00 0.544963D+00
0.589746D+00 0.648588D+00 0.608216D+00 0.582599D+00
0.625204D+00 0.523065D+00 0.627593D+00 0.621433D+00
0.733730D+00 0.498495D+00 0.748673D+00 0.591025D+00
0.578333D+00 0.564807D+00 0.652199D+00 0.579333D+00

I'm reading this file into a variable named congeneric (see my code)  
and now trying to pick up first 20 values and need these 20 values  
in a list format like


0.610251D+00 (row 1, col 1)
0.615278D+00 (row 1, col 2)
0.583581D+00 (row 1, col 3)
...


Can you tell me how can i achieve this? I think i'm pretty close but  
don't know how to remove the Row Name and Col. name from the  
conFirstTwenty list (see my code)


Alternatives:

congeneric - scan(textConnection(0.610251 0.615278 0.583581 0.560295
0.501325 0.639512 0.701607 0.544963
0.589746 0.648588 0.608216 0.582599
0.625204 0.523065 0.627593 0.621433
0.733730 0.498495 0.748673 0.591025
0.578333 0.564807 0.652199 0.579333), sep= )
# you would use scan with the filename in which the data is, rather  
than the textConnection. That's just for the purpose of the  
demonstration here.


# possible outputs
congeneric[1:20]

as.list(congeneric[1:20])

for (i in 1:20) {
cat(congeneric[i],\n)
}

JiHO
---
http://jo.irisson.free.fr/

__
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] Converting Matrix into List - problem (urgent)

2009-03-22 Thread Nidhi Kohli
JiHo,

Thanks for the reply, however i dont think it will help. Okay here is what i 
will achieve once i get this into a list format. I have another file in the 
following format:
0.63275433157105
0.686061949818395
0.786426681675948
0.954103894997388
0.600840965518728
0.949194842483848
0.972337634302676
0.830398896243423
0.81455702194944
0.530893135233782
0.602987287449650
0.588278376264498
0.843511423328891
0.692051859106869
0.88492070278
0.748849621042609
0.858809254132211
0.995953047415242
0.690017589717172
0.888722610659897

I need to compute correlation between these two sets. So i'm trying to convert 
my other file also in the above format so that i can use the function to 
compute correlation

Nidhi

 Original message 
Date: Sun, 22 Mar 2009 13:27:32 -0400
From: JiHO jo.li...@gmail.com  
Subject: Re: [R] Converting Matrix into List - problem (urgent)  
To: Nidhi Kohli nid...@umd.edu
Cc: R Help r-h...@stat.math.ethz.ch

On 2009-March-22  , at 13:06 , Nidhi Kohli wrote:

 Thank you so much for the quick reply. Let me explain you what I  
 want. I have a data file in the following format:

 0.610251D+00 0.615278D+00 0.583581D+00 0.560295D+00
 0.501325D+00 0.639512D+00 0.701607D+00 0.544963D+00
 0.589746D+00 0.648588D+00 0.608216D+00 0.582599D+00
 0.625204D+00 0.523065D+00 0.627593D+00 0.621433D+00
 0.733730D+00 0.498495D+00 0.748673D+00 0.591025D+00
 0.578333D+00 0.564807D+00 0.652199D+00 0.579333D+00

 I'm reading this file into a variable named congeneric (see my code)  
 and now trying to pick up first 20 values and need these 20 values  
 in a list format like

 0.610251D+00 (row 1, col 1)
 0.615278D+00 (row 1, col 2)
 0.583581D+00 (row 1, col 3)
 ...
 

 Can you tell me how can i achieve this? I think i'm pretty close but  
 don't know how to remove the Row Name and Col. name from the  
 conFirstTwenty list (see my code)

Alternatives:

congeneric - scan(textConnection(0.610251 0.615278 0.583581 0.560295
0.501325 0.639512 0.701607 0.544963
0.589746 0.648588 0.608216 0.582599
0.625204 0.523065 0.627593 0.621433
0.733730 0.498495 0.748673 0.591025
0.578333 0.564807 0.652199 0.579333), sep= )
# you would use scan with the filename in which the data is, rather  
than the textConnection. That's just for the purpose of the  
demonstration here.

# possible outputs
congeneric[1:20]

as.list(congeneric[1:20])

for (i in 1:20) {
   cat(congeneric[i],\n)
}

JiHO
---
http://jo.irisson.free.fr/


__
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] Selecting closest values

2009-03-22 Thread P_M

Hi
I have a table with ID (1 to 183) and Location (144 to -22).
My problem is that I want to select the 10 ID's that are closest in Location
to ID 1, ID 2 and so on.
Also, some ID have the same Location. Say, if 11 ID's are closest to ID 100
I want to randomly choose one of the ID's to select 10 ID's total.

Thank you

 

-- 
View this message in context: 
http://www.nabble.com/Selecting-closest-values-tp22647126p22647126.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] Problems with combining plots

2009-03-22 Thread Wills, Kellie
par(mfrow=c(1,1)) will give you just one panel.  Try par(mfrow=c(2,1)) or 
par(mfrow=c(1,2)).


-Original Message-
From: r-help-boun...@r-project.org on behalf of johnhj
Sent: Sun 3/22/2009 10:50 AM
To: r-help@r-project.org
Subject: [R]  Problems with combining plots
 

Hii,

I will combine some plots. Like this example here
http://www.statmethods.net/advgraphs/layout.html I tired to do it for 2
plots but without success.

Here is my code:

test-read.table(file=D:/file.txt)
space-read.table(file=D:/space.txt)

space$gruppe - 502*rep(1:6, each=7)
x- c(test$V1)
y- c(test$V2)

par(mfrow=c(1,1)) 

png(filename = D:/example.png, width = 640, height = 480, pointsize = 12,
bg = white,  res = NA)

boxplot(V2 ~ gruppe , data = space , col = lightgray,boxwex=0.2)
plot(panel.first=grid(ny=NULL,nx=NULL),x,y, xlab = Zeit(sec), ylab
=Datenrate(MBit(sec)),ylim=c(0,40), col =purple, type =l, main
=combined plots,lwd=2)

dev.off()


What is the mistake in my code ? 


-- 
View this message in context: 
http://www.nabble.com/Problems-with-combining-plots-tp22646692p22646692.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-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] Selecting closest values

2009-03-22 Thread jim holtman
It would be helpful is you supplied a subset of the data so that we
could see what you expect.  The 'outer'

On Sun, Mar 22, 2009 at 1:48 PM, P_M pmart...@broadpark.no wrote:

 Hi
 I have a table with ID (1 to 183) and Location (144 to -22).
 My problem is that I want to select the 10 ID's that are closest in Location
 to ID 1, ID 2 and so on.
 Also, some ID have the same Location. Say, if 11 ID's are closest to ID 100
 I want to randomly choose one of the ID's to select 10 ID's total.

 Thank you



 --
 View this message in context: 
 http://www.nabble.com/Selecting-closest-values-tp22647126p22647126.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.




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

What is the problem that you are trying to solve?

__
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] Selecting closest values

2009-03-22 Thread P_M

Yes, of course.

ID  loc 
1   144 
2   144 
3   140 
4   126 
5   120 
6   112 
7   100 
8   99  
9   91  
11  90  
12  90  
13  89  
15  86  
16  85  
17  85  
18  80  
19  79  
20  79  
21  78  
22  78  
23  76  
24  74  
25  73  
26  72  
27  71  
28  68  
29  68  
30  68
.   .   
.   .
185 -22 


P_M wrote:
 
 Hi
 I have a table with ID (1 to 183) and Location (144 to -22).
 My problem is that I want to select the 10 ID's that are closest in
 Location to ID 1, ID 2 and so on.
 Also, some ID have the same Location. Say, if 11 ID's are closest to ID
 100 I want to randomly choose one of the ID's to select 10 ID's total.
 
 Thank you
 
  
 
 

-- 
View this message in context: 
http://www.nabble.com/Selecting-closest-values-tp22647126p22648754.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] using wavelet transform to calculate mean frequency of a signal

2009-03-22 Thread stvienna wiener
Dear list,

in short: I would like to calculate the mean frequency
of a signal (e.g. time series) using the wavelet transform.



with details: I did not find a R function to calculate a
mean frequency using one of the cran packages.

My searches using  R Site Search returned:
**(1)waveclock {waveclock}R Documentation
Reconstruction of the modal frequencies in a time series using continuous
wavelet transformation and the crazy climbers algorithm
(this look like what I wanted to do, but I can't figure it out)

**(2) tfmean {Rwave}R Documentation
Average frequency by frequency
(this seems not to help either)


I am a bit desperate at the moment
and would very, very much appreciate any help.

Regards,
Stephan

[[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.


Re: [R] Pruning trees in a Random Forest

2009-03-22 Thread Liaw, Andy
Jerry Friedman advocated a few mods to RF in his ISLE algorithm:
 
- draw smaller samples
- grow smaller trees
- post process the forest using something like PathSeeker (or LASSO)
 
Andy



From: Wensui Liu [mailto:liuwen...@gmail.com]
Sent: Fri 3/20/2009 4:46 PM
To: Liaw, Andy
Cc: Anirudh Kondaveeti; r-help@r-project.org
Subject: Re: [R] Pruning trees in a Random Forest



I don't think it necessary to prune trees in RF, per brieman's paper.

On 3/20/09, Liaw, Andy andy_l...@merck.com wrote:
 The way the trees are structured in randomForest, there's no way to stop
 tree growth by depth (what you called level).

 (If anyone has ideas, I'm all ears.)

 Andy

 From: Anirudh Kondaveeti

 Hi all!

 The randomForest in R enables us to prune the trees using the nodesize
 feature where we can stop splitting a node if it contains
 less than the
 specified no.of of records/entities at that node.

 However is there a way to stop the tree growing after a
 specified number of
 levels. To be more clear on what I mean by a level. Level 0
 is the parent
 node, Level 1 has 2 daughter nodes, Level 2 has 4 daughter
 nodes, Level 3
 has 8 daughter nodes etc.

 Thanks in advance!

 Anirudh Kondaveeti
 

  [[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.

 Notice:  This e-mail message, together with any attachme...{{dropped:12}}

 __
 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.



--
==
WenSui Liu
Acquisition Risk, Chase
Blog   : statcompute.spaces.live.com

Tough Times Never Last. But Tough People Do.  - Robert Schuller
==


Notice:  This e-mail message, together with any attachme...{{dropped:15}}

__
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] Selecting closest values

2009-03-22 Thread jim holtman
If we assume the distance is linear, this might work:

 x
   ID loc
1   1 144
2   2 144
3   3 140
4   4 126
5   5 120
6   6 112
7   7 100
8   8  99
9   9  91
10 11  90
11 12  90
12 13  89
13 15  86
14 16  85
15 17  85
16 18  80
17 19  79
18 20  79
19 21  78
20 22  78
21 23  76
22 24  74
23 25  73
24 26  72
25 27  71
26 28  68
27 29  68
28 30  68
 x.outer - outer(x$loc, x$loc, function(a,b) abs(a - b))
 # set diag to Inf so a point is not closest to itself
 diag(x.outer) - Inf
 # assume that you choose the 8th element, here are the closest IDs
 x$ID[order(x.outer[,8])]
 [1]  7  9 11 12 13  6 15 16 17 18 19 20  5 21 22 23 24 25  4 26 27 28
29 30  3  1  2  8





On Sun, Mar 22, 2009 at 2:04 PM, P_M pmart...@broadpark.no wrote:

 Yes, of course.

 ID      loc
 1       144
 2       144
 3       140
 4       126
 5       120
 6       112
 7       100
 8       99
 9       91
 11      90
 12      90
 13      89
 15      86
 16      85
 17      85
 18      80
 19      79
 20      79
 21      78
 22      78
 23      76
 24      74
 25      73
 26      72
 27      71
 28      68
 29      68
 30      68
 .       .
 .       .
 185     -22


 P_M wrote:

 Hi
 I have a table with ID (1 to 183) and Location (144 to -22).
 My problem is that I want to select the 10 ID's that are closest in
 Location to ID 1, ID 2 and so on.
 Also, some ID have the same Location. Say, if 11 ID's are closest to ID
 100 I want to randomly choose one of the ID's to select 10 ID's total.

 Thank you





 --
 View this message in context: 
 http://www.nabble.com/Selecting-closest-values-tp22647126p22648754.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.




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

What is the problem that you are trying to solve?

__
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] Converting Matrix into List - problem (urgent)

2009-03-22 Thread Daniel Nordlund
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Nidhi Kohli
 Sent: Sunday, March 22, 2009 10:41 AM
 To: JiHO
 Cc: R Help
 Subject: Re: [R] Converting Matrix into List - problem (urgent)
 
 JiHo,
 
 Thanks for the reply, however i dont think it will help. Okay 
 here is what i will achieve once i get this into a list 
 format. I have another file in the following format:
 0.63275433157105
 0.686061949818395
 0.786426681675948
 0.954103894997388
 0.600840965518728
 0.949194842483848
 0.972337634302676
 0.830398896243423
 0.81455702194944
 0.530893135233782
 0.602987287449650
 0.588278376264498
 0.843511423328891
 0.692051859106869
 0.88492070278
 0.748849621042609
 0.858809254132211
 0.995953047415242
 0.690017589717172
 0.888722610659897
 
 I need to compute correlation between these two sets. So i'm 
 trying to convert my other file also in the above format so 
 that i can use the function to compute correlation
 
 Nidhi
 
  Original message 
 Date: Sun, 22 Mar 2009 13:27:32 -0400
 From: JiHO jo.li...@gmail.com  
 Subject: Re: [R] Converting Matrix into List - problem (urgent)  
 To: Nidhi Kohli nid...@umd.edu
 Cc: R Help r-h...@stat.math.ethz.ch
 
 On 2009-March-22  , at 13:06 , Nidhi Kohli wrote:
 
  Thank you so much for the quick reply. Let me explain you what I  
  want. I have a data file in the following format:
 
  0.610251D+00 0.615278D+00 0.583581D+00 0.560295D+00
  0.501325D+00 0.639512D+00 0.701607D+00 0.544963D+00
  0.589746D+00 0.648588D+00 0.608216D+00 0.582599D+00
  0.625204D+00 0.523065D+00 0.627593D+00 0.621433D+00
  0.733730D+00 0.498495D+00 0.748673D+00 0.591025D+00
  0.578333D+00 0.564807D+00 0.652199D+00 0.579333D+00
 
  I'm reading this file into a variable named congeneric 
 (see my code)  
  and now trying to pick up first 20 values and need these 
 20 values  
  in a list format like
 
  0.610251D+00 (row 1, col 1)
  0.615278D+00 (row 1, col 2)
  0.583581D+00 (row 1, col 3)
  ...
  
 
  Can you tell me how can i achieve this? I think i'm pretty 
 close but  
  don't know how to remove the Row Name and Col. name from the  
  conFirstTwenty list (see my code)
 
 Alternatives:
 
 congeneric - scan(textConnection(0.610251 0.615278 
 0.583581 0.560295
 0.501325 0.639512 0.701607 0.544963
 0.589746 0.648588 0.608216 0.582599
 0.625204 0.523065 0.627593 0.621433
 0.733730 0.498495 0.748673 0.591025
 0.578333 0.564807 0.652199 0.579333), sep= )
 # you would use scan with the filename in which the data is, rather  
 than the textConnection. That's just for the purpose of the  
 demonstration here.
 
 # possible outputs
 congeneric[1:20]
 
 as.list(congeneric[1:20])
 
 for (i in 1:20) {
  cat(congeneric[i],\n)
 }
 
 JiHO
 ---

You really haven't given us enough information.  What stements did you
execute that produced the data and row/column labels shown above?  What does
running str(congeneric) tell you about congeneric?  I don't think you want
your data for the correlation in an R list structure.  You want your data in
vectors, or the columns of a matrix or dataframe.  Given the data in your
file, you could do something like this

#read data into a matrix
m - as.matrix(read.table(your_data_file,sep=' ', header=FALSE))

#get the 20 values you want
vector1 - as.vector(t(m))[1:20]

But without knowing the actual structure of your variable congeneric, it is
not possible to tell you how to manipulate it.  Maybe someone else will be
better at guessing.

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.


Re: [R] Multiple Comparisons for (multicomp - glht) for glm negative binomial (glm.nb)

2009-03-22 Thread Achim Zeileis

On Sun, 22 Mar 2009, lara harrup (IAH-P) wrote:


Hi

I have some experimental data where I have counts of the number of
insects collected to different trap types rotated through 5 different
location (variable -location), 4 different chemical attractants [A, B,
C, D]  were applied to the traps (variable - semio) and all were
trialled at two different CO2 release rates [1, 2] (variable CO2) I also
have a selection of continuous variables measuring meteorological
conditions to account for any bias cause by changing weather conditions,
the data is over dispersed so I have fitted a negative binomial glm
(glm.nb) and simplified using stepAIC from the MASS package etc.

There are significant differences in the number of insects attracted to
the different chemical (semio) and to the two different CO2 (release
rates) I have then used the glht function from the multcomp package to
do multiple comparisons to see what the specific differences between the
levels are for semio and CO2 using the code below which works great but
what I would like to do is to do comparisons combining the factors e.g a
comparison for semioA at CO at level 1 vs Semio A at CO2 level 2  etc to
see which is the best combination, is this possible or should I have
started of with my counts already split up into this e.g. a treatment
variable(semioA at CO2 level 1 = A1, semioA at CO2 level 2 = A2 etc), I
started with them this way as we have no prior knowledge that increasing
co2 will have any effect.

I have had a quick try with the data split into a treatment factor
(instead of semio and CO2 level) but I can not get convergence with
glm.nb I think this may be to do with to many zeros in the data set, do
you know if glht or another multiple comparison will work or
zeroinflated negative binomial regression(zeroinfl() from the pscl
library)?


Yes, it does, because zeroinfl() (and hurdle()) both return models with 
the usual extractor methods (coef, vcov, et al). The only nuisance is that 
you can't use the mcp() interface because it will be confused about the 
two parts of the model (count vs. zero-inflation part) which might both 
contain the same variables. What you have to do is set up your contrast 
matrix by hand. An example using the NMES1988 data from the AER package 
is included below.


hth,
Z

## packages
library(pscl)
library(multcomp)

## data
data(NMES1988, package = AER)
nmes - NMES1988[, c(1, 6:8)]

## models
fm_pois - glm(visits ~ ., data = nmes, family = poisson)
fm_nbin - glm.nb(visits ~ ., data = nmes)
fm_zinb - zeroinfl(visits ~ . | ., data = nmes, dist = negbin)

## generalized linear hypotheses
glht_pois - glht(fm_pois, linfct = mcp(health = Tukey))
glht_nbin - glht(fm_nbin, linfct = mcp(health = Tukey))

## compute contrasts by hand for ZINB
nr - length(levels(nmes$health))
contr - matrix(0, nrow = nr, ncol = length(coef(fm_zinb)))
colnames(contr) - names(coef(fm_nbin))
rownames(contr) - paste(levels(nmes$health)[c(2, 3, 3)], 
levels(nmes$health)[c(1, 1, 2)], sep =  - )

contr[,3:4] - contrMat(numeric(nrow(contr)), type = Tukey)[,-2]
glht_zinb - glht(fm_zinb, linfct = contr)

## multiple comparisons
summary(glht_pois)
summary(glht_nbin)
summary(glht_zinb)



Any help or ideas will be gratefully appreciated. Many thanks in
advance.

Lara


semiochemical -read.csv(G:/semiochemical_data.csv, header=T)

semiochemical$location2-factor(semiochemical$location)
levels(semiochemical$location2)-c(1,2,3,4,5)

semiochemical$semio2-factor(semiochemical$semio)
levels(semiochemical$semio2)-c(A,B,C,D)

semiochemical$CO22-factor(semiochemical$CO2)
levels(semiochemical$CO22)-c(1,2)

model1-glm.nb(total ~ semio + CO2 + location + temp + mean.wind.speed)

model.glht.Semio - glht(model1, linfct=mcp(semio=Tukey))
model.glht.CO2 - glht(model1, linfct=mcp(CO2=Tukey))


[[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.




__
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] barplot2 x-axis

2009-03-22 Thread Mafalda Viana
Dear R users,

I am trying to build a barplot2 graph however I can't find a way of defining
the scale for the x-axis.

I would like to show in my x-axis only the numbers 0, 25, 50, 75 etc. (so
far R is giving me a random scale hard to interpret and it doens't look
nice...). Could anyone advise me on how to do this please, it would be a
great help! Thank you.

Below I show the code I have been using for my plots.

my.plot- barplot2(mydata.y, names.arg=mydata.x, width=1,
xlab=km, ylab=kg, main=plot.name,
plot.ci=TRUE, ci.l=data.lci,ci.u=data.uci, ci.col = red, font=40,
font.lab=60, xlim=c(0,250), xpd=FALSE)

Thanking you in advance
Mafalda
-- 
Mafalda Viana

[[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.


Re: [R] Converting Matrix into List - problem (urgent)

2009-03-22 Thread JiHO

On 2009-March-22  , at 12:26 , Nidhi Kohli wrote:

I want to remove the Column name and Row name from the above output.  
Any help on this will be greatly appreciated (I'm open to any other  
alternative way to convert Matrix into List also)


What are you trying to achieve exactly? Do you just want to print a  
clean output on the screen? If yes, look at `cat`, or `print`.


JiHO
---
http://jo.irisson.free.fr/

__
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] Selecting closest values

2009-03-22 Thread Johannes Huesing
P_M pmart...@broadpark.no [Sun, Mar 22, 2009 at 06:48:36PM CET]:
 
 Hi
 I have a table with ID (1 to 183) and Location (144 to -22).
 My problem is that I want to select the 10 ID's that are closest in Location
 to ID 1, ID 2 and so on.
 Also, some ID have the same Location. Say, if 11 ID's are closest to ID 100
 I want to randomly choose one of the ID's to select 10 ID's total.

In the general case, the nn function from the RANN package (not part of CRAN
but found by rseek) does what you want, but for the one-dimensional case this
might be overkill.

-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

__
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] 'require' equivalent for local functions

2009-03-22 Thread JiHO

Hello everyone,

I often create some local libraries of functions (.R files with only  
functions in them) that I latter call. In scripts that call a function  
from such library, I would like to be able to test whether the  
function is already known in the namespace and, only if it is not,  
source the library file. I.e. what `require` does for packages, I want  
to do with my local functions.


Example:
lib.R
foo - function(x) { x*2 }

script.R
require.local(foo,lib.R)
	# that searches for function foo and, if not found, executes  
source(lib.R)

foo(2)

Obviously, I want the test to be quite efficient otherwise I might as  
well source the local library every time. I am aware that it would  
probably not be able to check for changes in lib.R (i.e. do  
complicated things such as re-source lib.R if foo in the namespace and  
foo in lib.R are different), but that I can handle manually.


This seems like a common enough workflow but I cannot find a pre- 
existing solution. Does anyone have pointers?


Otherwise I tried to put that together:

require.local - function(fun, lib)
#
#   Searches for function fun and sources lib in
#   case it is not found
#
{
	if (! (deparse(substitute(fun)) %in% ls(.GlobalEnv)  class(fun)  
== function) ) {

cat(Sourcing, lib,...\n)
source(lib)
}
}

but I am really not confident with all those deparse/substitute things  
and the environment manipulation, so I guess there should be a better  
way.


JiHO
---
http://jo.irisson.free.fr/

__
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] 'require' equivalent for local functions

2009-03-22 Thread Gabor Grothendieck
Try this:

if (!exists(myfun, mode = function)) source(myfile.R)

Also check the other arguments of exists in case you want to
restrict the search.

On Sun, Mar 22, 2009 at 5:05 PM, JiHO jo.li...@gmail.com wrote:
 Hello everyone,

 I often create some local libraries of functions (.R files with only
 functions in them) that I latter call. In scripts that call a function from
 such library, I would like to be able to test whether the function is
 already known in the namespace and, only if it is not, source the library
 file. I.e. what `require` does for packages, I want to do with my local
 functions.

 Example:
 lib.R
        foo - function(x) { x*2 }

 script.R
        require.local(foo,lib.R)
        # that searches for function foo and, if not found, executes
 source(lib.R)
        foo(2)

 Obviously, I want the test to be quite efficient otherwise I might as well
 source the local library every time. I am aware that it would probably not
 be able to check for changes in lib.R (i.e. do complicated things such as
 re-source lib.R if foo in the namespace and foo in lib.R are different), but
 that I can handle manually.

 This seems like a common enough workflow but I cannot find a pre-existing
 solution. Does anyone have pointers?

 Otherwise I tried to put that together:

 require.local - function(fun, lib)
 #
 #       Searches for function fun and sources lib in
 #       case it is not found
 #
 {
        if (! (deparse(substitute(fun)) %in% ls(.GlobalEnv)  class(fun)
 == function) ) {
                cat(Sourcing, lib,...\n)
                source(lib)
        }
 }

 but I am really not confident with all those deparse/substitute things and
 the environment manipulation, so I guess there should be a better way.

 JiHO
 ---
 http://jo.irisson.free.fr/

 __
 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-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] 'require' equivalent for local functions

2009-03-22 Thread Wacek Kusnierczyk
JiHO wrote:
 Hello everyone,

 I often create some local libraries of functions (.R files with only
 functions in them) that I latter call. In scripts that call a function
 from such library, I would like to be able to test whether the
 function is already known in the namespace and, only if it is not,
 source the library file. I.e. what `require` does for packages, I want
 to do with my local functions.

 Example:
 lib.R
 foo - function(x) { x*2 }

 script.R
 require.local(foo,lib.R)
 # that searches for function foo and, if not found, executes
 source(lib.R)
 foo(2)

 Obviously, I want the test to be quite efficient otherwise I might as
 well source the local library every time. I am aware that it would
 probably not be able to check for changes in lib.R (i.e. do
 complicated things such as re-source lib.R if foo in the namespace and
 foo in lib.R are different), but that I can handle manually.

 This seems like a common enough workflow but I cannot find a
 pre-existing solution. Does anyone have pointers?

 Otherwise I tried to put that together:

 require.local - function(fun, lib)
 #
 #Searches for function fun and sources lib in
 #case it is not found
 #
 {
 if (! (deparse(substitute(fun)) %in% ls(.GlobalEnv) 
 class(fun) == function) ) {
perhaps

find(deparse(substitute(fun)), mode='function')

but note that this will *not* tell you whether *the* function you want
to import is already known, but rather whether *some* function with the
specified name is already known.

vQ

__
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] barplot2 x-axis

2009-03-22 Thread Marc Schwartz

On Mar 22, 2009, at 2:31 PM, Mafalda Viana wrote:


Dear R users,

I am trying to build a barplot2 graph however I can't find a way of  
defining

the scale for the x-axis.

I would like to show in my x-axis only the numbers 0, 25, 50, 75  
etc. (so
far R is giving me a random scale hard to interpret and it doens't  
look
nice...). Could anyone advise me on how to do this please, it would  
be a

great help! Thank you.

Below I show the code I have been using for my plots.

my.plot- barplot2(mydata.y, names.arg=mydata.x, width=1,
xlab=km, ylab=kg, main=plot.name,
plot.ci=TRUE, ci.l=data.lci,ci.u=data.uci, ci.col = red, font=40,
font.lab=60, xlim=c(0,250), xpd=FALSE)



It is not entirely clear what you are doing here an we cannot  
reproduce it lacking your data.


Your x (horizontal) axis will have one tick mark below each bar, using  
the labels that you have indicated with mydata.x. Based upon your  
code, the x axis values would appear to be measures of distance.


Your y (vertical) axis would appear to be a measure of weight, perhaps  
being some descriptive statistic (eg. mean) for weight at each distance.


It is unclear what you want to do with the x axis in lieu of the  
default values. Modifying the tick marks on the y axis would seem to  
make more sense here.


In general, with any R graphic, you would use the arguments 'xaxt =  
n' and/or 'yaxt = n' to disable the default drawing of the x and y  
axes, respectively. You would then call the axis() function passing  
the specific locations and values of the tick marks that you wish to  
draw. See ?par and ?axis for more information on these.


BTW if you are not plotting counts or proportions/percentages, then a  
barplot is not the best approach for the display of summarized  
continuous data. I would use a point plot with error bars/confidence  
intervals. See the errbar() function in the Hmisc package or the  
plotCI() or plotmeans() functions in gplots. You could also create  
something manually by using plot() and then either segments() or  
arrows() for the CIs.


HTH,

Marc Schwartz

__
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] If statement generates two outputs

2009-03-22 Thread jimdare

Hi,

How do I tell an if statement to generate two seperate outputs.

E.g  If X5 I want to create df1 and df2:

if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)}

Thanks,
James
-- 
View this message in context: 
http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22650844.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] If statement generates two outputs

2009-03-22 Thread Wacek Kusnierczyk
jimdare wrote:
 Hi,

 How do I tell an if statement to generate two seperate outputs.

 E.g  If X5 I want to create df1 and df2:

 if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)}
   
almost there:

if (X5) {df1-c(4,5,6,7,8); df2-c(9,10,11,12,13)}

vQ

__
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] If statement generates two outputs

2009-03-22 Thread Daniel Moreira
if (X5) {
  df1-c(4,5,6,7,8)
  df2-c(9,10,11,12,13)
}

hth,

Daniel Moreira, MD




jimdare jamesdar...@gmail.com 
Sent by: r-help-boun...@r-project.org
03/22/2009 05:27 PM

To
r-help@r-project.org
cc

Subject
[R]  If statement generates two outputs







Hi,

How do I tell an if statement to generate two seperate outputs.

E.g  If X5 I want to create df1 and df2:

if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)}

Thanks,
James
-- 
View this message in context: 
http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22650844.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.


[[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.


Re: [R] If statement generates two outputs

2009-03-22 Thread jimdare

Thanks very much 



Wacek Kusnierczyk wrote:
 
 jimdare wrote:
 Hi,

 How do I tell an if statement to generate two seperate outputs.

 E.g  If X5 I want to create df1 and df2:

 if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)}
   
 almost there:
 
 if (X5) {df1-c(4,5,6,7,8); df2-c(9,10,11,12,13)}
 
 vQ
 
 __
 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/If-statement-generates-two-outputs-tp22650844p22650960.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] Following progress in a lapply() function

2009-03-22 Thread Blanchette, Marco
Dear all,

I am processing a very long and complicated list using lapply through a custom 
function and I would like to generate some sort of progress report. For 
instance, print a dot on the screen every time 1000 item have been process. Or 
even better, reporting the percent of the list that have been process every 
10%. However, I can't seem to figure out a way to achieve that.

For instance, I have a list of 50,000 slots:

aList - replicate(5,list(rnorm(50)))

That need to be process through the following custom function:

myFnc - function(x){
 tTest - t.test(x)
return(list(p.value=tTest$p.value,t.stat=tTest$stat))
}

Using an lapply statement, as in:

myResults - lapply(aList, myFnc)

The goal would be to report on the progress of the lapply() function during 
processing.

Any suggestion would be greatly appreciated.

Thanks

Marco


--
Marco Blanchette, Ph.D.
Assistant Investigator
Stowers Institute for Medical Research
1000 East 50th St.

Kansas City, MO 64110

Tel: 816-926-4071
Cell: 816-726-8419
Fax: 816-926-2018

__
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] barplot2 x-axis

2009-03-22 Thread Mafalda Viana
Dear Mark,

Thanks for your reply.

I attach one of my plots as an example (e.g.Mafalda) to show what I want. If
you notice in the plot the x-axis has a funny scale (0, 13, 28...) and what
I would like to do is to make that scale from 0 and then increasing by 25 km
for a better interpretation (0, 25, 50...).

Hopefully my problem is more clear now, meanwhile I will have a look to your
suggestions.

Thank you very much
Mafalda



2009/3/22 Marc Schwartz marc_schwa...@comcast.net

  On Mar 22, 2009, at 2:31 PM, Mafalda Viana wrote:

 Dear R users,

 I am trying to build a barplot2 graph however I can't find a way of
 defining
 the scale for the x-axis.

 I would like to show in my x-axis only the numbers 0, 25, 50, 75 etc. (so
 far R is giving me a random scale hard to interpret and it doens't look
 nice...). Could anyone advise me on how to do this please, it would be a
 great help! Thank you.

 Below I show the code I have been using for my plots.

 my.plot- barplot2(mydata.y, names.arg=mydata.x, width=1,
 xlab=km, ylab=kg, main=plot.name,
 plot.ci=TRUE, ci.l=data.lci,ci.u=data.uci, ci.col = red, font=40,
 font.lab=60, xlim=c(0,250), xpd=FALSE)



 It is not entirely clear what you are doing here an we cannot reproduce it
 lacking your data.

 Your x (horizontal) axis will have one tick mark below each bar, using the
 labels that you have indicated with mydata.x. Based upon your code, the x
 axis values would appear to be measures of distance.

 Your y (vertical) axis would appear to be a measure of weight, perhaps
 being some descriptive statistic (eg. mean) for weight at each distance.

 It is unclear what you want to do with the x axis in lieu of the default
 values. Modifying the tick marks on the y axis would seem to make more sense
 here.

 In general, with any R graphic, you would use the arguments 'xaxt = n'
 and/or 'yaxt = n' to disable the default drawing of the x and y axes,
 respectively. You would then call the axis() function passing the specific
 locations and values of the tick marks that you wish to draw. See ?par and
 ?axis for more information on these.

 BTW if you are not plotting counts or proportions/percentages, then a
 barplot is not the best approach for the display of summarized continuous
 data. I would use a point plot with error bars/confidence intervals. See the
 errbar() function in the Hmisc package or the plotCI() or plotmeans()
 functions in gplots. You could also create something manually by using
 plot() and then either segments() or arrows() for the CIs.

 HTH,

 Marc Schwartz





-- 
Mafalda Viana
__
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] data frame to array

2009-03-22 Thread Thomas S. Dye
Aloha all,

I have a data frame with 4 columns.  The first three are factors (f1,  
f2, f3) and the fourth is numeric.  I'd like to explore these data  
using median polish.  To do that I plan to use medpolish() on the  
matrix[f1,f2xf3], then medpolish on the resulting matrix[f2,f3].  This  
approach is described by Cook on page 141 of Exploring Data Tables,  
Trends, and Shapes.

split() gets me close to where I want to be, but results in a list,  
rather than a matrix.  How do I construct the matrix[f1,f2xf3] from my  
data frame?

Also, any pointers to existing code that performs multi-way median  
polish will be appreciated.

Sorry for the newbie-type query, but manipulating data prior to  
analysis is really hard for me in R.

All the best,
Tom

Thomas S. Dye, Ph.D.
T. S. Dye  Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com



[[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.


Re: [R] Following progress in a lapply() function

2009-03-22 Thread Gabor Grothendieck
There are several packages with progress bars:

RSiteSearch(progress)

On Sun, Mar 22, 2009 at 6:06 PM, Blanchette, Marco m...@stowers.org wrote:
 Dear all,

 I am processing a very long and complicated list using lapply through a 
 custom function and I would like to generate some sort of progress report. 
 For instance, print a dot on the screen every time 1000 item have been 
 process. Or even better, reporting the percent of the list that have been 
 process every 10%. However, I can't seem to figure out a way to achieve that.

 For instance, I have a list of 50,000 slots:

 aList - replicate(5,list(rnorm(50)))

 That need to be process through the following custom function:

 myFnc - function(x){
     tTest - t.test(x)
    return(list(p.value=tTest$p.value,t.stat=tTest$stat))
 }

 Using an lapply statement, as in:

 myResults - lapply(aList, myFnc)

 The goal would be to report on the progress of the lapply() function during 
 processing.

 Any suggestion would be greatly appreciated.

 Thanks

 Marco


 --
 Marco Blanchette, Ph.D.
 Assistant Investigator
 Stowers Institute for Medical Research
 1000 East 50th St.

 Kansas City, MO 64110

 Tel: 816-926-4071
 Cell: 816-726-8419
 Fax: 816-926-2018

 __
 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-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] Following progress in a lapply() function

2009-03-22 Thread hadley wickham
On Sun, Mar 22, 2009 at 5:06 PM, Blanchette, Marco m...@stowers.org wrote:
 Dear all,

 I am processing a very long and complicated list using lapply through a 
 custom function and I would like to generate some sort of progress report. 
 For instance, print a dot on the screen every time 1000 item have been 
 process. Or even better, reporting the percent of the list that have been 
 process every 10%. However, I can't seem to figure out a way to achieve that.

 For instance, I have a list of 50,000 slots:

 aList - replicate(5,list(rnorm(50)))

 That need to be process through the following custom function:

 myFnc - function(x){
     tTest - t.test(x)
    return(list(p.value=tTest$p.value,t.stat=tTest$stat))
 }

 Using an lapply statement, as in:

 myResults - lapply(aList, myFnc)

 The goal would be to report on the progress of the lapply() function during 
 processing.

install.packages(plyr)
library(plyr)

myResults - llply(aList, myFnc, .progress = text)

see http://had.co.nz/plyr for more info.

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.


Re: [R] Selecting closest values

2009-03-22 Thread Bill.Venables
Here is one way you might find useful

 id - 1:183
 lo - sample((-22):144, 183, rep = TRUE)
 ds - outer(lo, lo, function(x,y) abs(x-y))
 rs - t(apply(ds, 2, function(x) id[order(x)][2:11]))
 rownames(rs) - id

Here's what I got

 head(rs)
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
1  118   23  125  182  1838   86  119  141   175
2   27  167  1764  126   45  113   81  144   153
3   437   18   60  148   11   12  150   85   163
4  126   27  167  1762   45  144  153   4855
5   15   46   86  141  175   23  125  1831   118
6   58   78  139   13   66  131  156  181  117   157

If you want anything more random in the case of ties than this, you will have 
to work a bit harder on the code.  

W.

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of P_M
Sent: Monday, 23 March 2009 1:32 AM
To: r-help@r-project.org
Subject: [R] Selecting closest values


Hi
I have a table with ID (1 to 183) and Location (144 to -22).
My problem is that I want to select the 10 ID's that are closest in Location
to ID 1, ID 2 and so on.
Also, some ID have the same Location. Say, if 11 ID's are closest to ID 100
I want to randomly choose one of the ID's to select 10 ID's total.

Thank you

 

-- 
View this message in context: 
http://www.nabble.com/Selecting-closest-values-tp22647126p22647126.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-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] I have a question about a programa in R

2009-03-22 Thread Carlos J. Gil Bellosta
Hello,

And what is exactly your problem? 

Best regards,

Carlos J. Gil Bellosta
http://www.datanalytics.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] data frame to array

2009-03-22 Thread Bill.Venables
Here is a possibility

Dat - cbind(expand.grid(f1 = letters[1:5], f2 = LETTERS[1:5], 
f3 = as.character(1:5)), x = rnorm(125))
M - with(Dat, {
  f23 - f2:f3
  m - matrix(0, length(levels(f1)), length(levels(f23)))
  i - match(f1, levels(f1))
  j - match(f23, levels(f23))
  m[cbind(i,j)] - x
  dimnames(m) - list(levels(f1), levels(f23))
  m
 })

 M[1:5, 1:5]
  A:1A:2A:3A:4A:5
a  1.72686085 -2.0605242  1.0989119  0.8096139  1.0146972
b -0.34512446 -0.1709805  0.3401842  0.5815685 -1.4862872
c  1.14489491 -0.3959085  0.3222197 -1.1108793  0.3676764
d  0.02520386 -1.0018102 -0.7232067 -0.6142914  0.6694813
e -1.23366653  0.3826862 -0.6797035  0.6536055  0.8865669

This should work provided you have one entry per f1 x f2 x f3 cell.  The rows 
of the data frame may be in arbitrary order.  

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Thomas S. Dye
Sent: Monday, 23 March 2009 7:36 AM
To: r-help@r-project.org
Subject: [R] data frame to array

Aloha all,

I have a data frame with 4 columns.  The first three are factors (f1,  
f2, f3) and the fourth is numeric.  I'd like to explore these data  
using median polish.  To do that I plan to use medpolish() on the  
matrix[f1,f2xf3], then medpolish on the resulting matrix[f2,f3].  This  
approach is described by Cook on page 141 of Exploring Data Tables,  
Trends, and Shapes.

split() gets me close to where I want to be, but results in a list,  
rather than a matrix.  How do I construct the matrix[f1,f2xf3] from my  
data frame?

Also, any pointers to existing code that performs multi-way median  
polish will be appreciated.

Sorry for the newbie-type query, but manipulating data prior to  
analysis is really hard for me in R.

All the best,
Tom

Thomas S. Dye, Ph.D.
T. S. Dye  Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com



[[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.

__
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] barplot2 x-axis

2009-03-22 Thread Marc Schwartz
Looking at the graphic (I got it here, but it was stripped for those  
getting it via the server), the CI's don't really add much to the  
interpretation of the data. They are small enough as to be a non-issue  
at least in this example and there is too much data to make them  
useful for visually comparing the means across the bars anyway.


The values along the x axis that you are getting are the result of  
there being too many small vertical bars in the space and that the  
size of the font for the bars is too large to display all of the  
labels. The other consideration, is that the horizontal spacing of the  
bars will not be based upon their numeric value on a linear scale, but  
their physical sequence in your data. Thus, if there are sequence gaps  
in the distance measures along the x axis, those gaps will not be  
maintained when displayed, resulting in a compromised linear scale  
along the axis.


For example, consider:

x - c(1:5, 8, 15:18)

names(x) = c(1:5, 8, 15:18)

barplot(x)


Note that there are gaps (6:7 and 9:14) where data is not present, but  
the bars (5/8 and 8/15) are nevertheless next to each other. You would  
need to insert NA's at the missing data points to maintain the proper  
bar locations along the x axis.


Here is what it should look like:

x - c(1:5, NA, NA, 8, rep(NA, 6), 15:18)

names(x) - c(1:5, NA, NA, 8, rep(NA, 6), 15:18)

barplot(x, cex.names = 0.75)



Contrast how barplot() handles such data by default versus plot():

x - c(1:5, 8, 15:18)

plot(x, x, type = h, lwd = 10)



Recognizing that there may be community standards for you in how such  
data (presumably animal or vegetative abundance data) should be  
presented, my recommendation otherwise in a vacuum would be to plot  
the data using points and leave out the CIs:


 plot(mydata.x, mydata.y, xlab = km, ylab = kg, main = plot.name,
  xlim = c(0, 250), xaxt = n, pch = 19)

 axis(1, at = seq(0, 250, 25))


or if you need bars (use type = h as above), if that is the  
preferred presentation format:


 plot(mydata.x, mydata.y, xlab = km, ylab = kg, main = plot.name,
  xlim = c(0, 250), xaxt = n, type = h, lwd = 5)

 axis(1, at = seq(0, 250, 25))



The bottom line is the key take away message that you are trying to  
convey, without that message being lost in too much ink.


HTH,

Marc


On Mar 22, 2009, at 4:45 PM, Mafalda Viana wrote:


Dear Mark,

Thanks for your reply.

I attach one of my plots as an example (e.g.Mafalda) to show what I  
want. If
you notice in the plot the x-axis has a funny scale (0, 13, 28...)  
and what
I would like to do is to make that scale from 0 and then increasing  
by 25 km

for a better interpretation (0, 25, 50...).

Hopefully my problem is more clear now, meanwhile I will have a look  
to your

suggestions.

Thank you very much
Mafalda



2009/3/22 Marc Schwartz marc_schwa...@comcast.net


On Mar 22, 2009, at 2:31 PM, Mafalda Viana wrote:

Dear R users,


I am trying to build a barplot2 graph however I can't find a way of
defining
the scale for the x-axis.

I would like to show in my x-axis only the numbers 0, 25, 50, 75  
etc. (so
far R is giving me a random scale hard to interpret and it doens't  
look
nice...). Could anyone advise me on how to do this please, it  
would be a

great help! Thank you.

Below I show the code I have been using for my plots.

my.plot- barplot2(mydata.y, names.arg=mydata.x, width=1,
xlab=km, ylab=kg, main=plot.name,
plot.ci=TRUE, ci.l=data.lci,ci.u=data.uci, ci.col = red, font=40,
font.lab=60, xlim=c(0,250), xpd=FALSE)




It is not entirely clear what you are doing here an we cannot  
reproduce it

lacking your data.

Your x (horizontal) axis will have one tick mark below each bar,  
using the
labels that you have indicated with mydata.x. Based upon your code,  
the x

axis values would appear to be measures of distance.

Your y (vertical) axis would appear to be a measure of weight,  
perhaps
being some descriptive statistic (eg. mean) for weight at each  
distance.


It is unclear what you want to do with the x axis in lieu of the  
default
values. Modifying the tick marks on the y axis would seem to make  
more sense

here.

In general, with any R graphic, you would use the arguments 'xaxt =  
n'
and/or 'yaxt = n' to disable the default drawing of the x and y  
axes,
respectively. You would then call the axis() function passing the  
specific
locations and values of the tick marks that you wish to draw. See ? 
par and

?axis for more information on these.

BTW if you are not plotting counts or proportions/percentages, then a
barplot is not the best approach for the display of summarized  
continuous
data. I would use a point plot with error bars/confidence  
intervals. See the

errbar() function in the Hmisc package or the plotCI() or plotmeans()
functions in gplots. You could also create something manually by  
using

plot() and then either segments() or arrows() for the CIs.

HTH,

Marc Schwartz






--
Mafalda Viana

Re: [R] If statement generates two outputs

2009-03-22 Thread jimdare

Hi, 

I tried to create the following if / else statement but I keep getting the
error Error: unexpected '}' in size=large,center=none)
} (I have highlighted the } in bold where the error is occuring).  I can't
seem to find a reason for this, does anyone know how I can fix it?

Thanks,
James  

if (nostocks=3)

{data1-test[,data1stocks];
tex1-latex(data1, file=paste(i$Species[1], 1.tex, sep=), 
 rowname = NULL, 
 cgroup = c(Fishstock, stocknames,Total), 
 n.cgroup = c(1, rep(2,(nostocks+1)), 
 colheads = c(Year, rep(c(Catch, TACC),
nostocks+1)),
size=large,center=none)

}else)  
{data1-test[,1:9];data2-test[,data2stocks];
tex1-latex(data1, file=paste(i$Species[1], 1.tex, sep=), 
 rowname = NULL, 
 cgroup = c(Fishstock, stocknames,Total), 
 n.cgroup = c(1, rep(2,4)), 
 colheads = c(Year, rep(c(Catch, TACC),
nostocks+1)),
size=large,center=none);

tex2-latex(data2, file=paste(i$Species[1], 2.tex, sep=), 
rowname = NULL, 
 cgroup = c(Fishstock, stocknames,Total), 
 n.cgroup = c(1, rep(2,((nostocks-4)+1)), 
colheads = c(Year, rep(c(Catch, TACC),
nostocks+1)),size=large,center=none)
}







jimdare wrote:
 
 Hi,
 
 How do I tell an if statement to generate two seperate outputs.
 
 E.g  If X5 I want to create df1 and df2:
 
 if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)}
 
 Thanks,
 James
 

-- 
View this message in context: 
http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22652363.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] using xyplot

2009-03-22 Thread Santosh
Dear R-sians!
I am trying generate a bunch of xyplots

library(lattice)
myPanel - function(x,y,xl=range(x),yl=range(y),...) {
  panel.xyplot(x,y,pch=20,col='blue',cex=0.7,xlim=xl,ylim=yl,...)
  panel.abline(v=0, col='gray30',lty=2,lwd=1.5,...)
  panel.loess(x,y,
span=2/3,family='gaussian',normalize=T,col='red',lwd=1.5,...)
#  panel.lmline(x,y, col='red',lwd=1.5,...)
  }

nms - names(tmp7)[c(3:7,9)]
for (i in nms) {
 tmp1  - xyplot(i~pk, data=tmp7, # different y's in the loop; x is same for
all
  as.table=T,panel=myPanel,main=paste('PK vs',i,'- overall'))
  pdf(paste(pkvs,i,a.pdf,sep=),w=10,h=8)
   print(tmp1)
  dev.off()
}

The above code does not seem to work. I was not able to use sapply with a
FUN=xyplot, either.
I was, however, able to generate the plots (with xyplot) when I hard-code
the index value!

Could you please help me troubleshooting the above code? If you can also
help with an alternate code using sapply, it would be helpful!


Thanks much in advance!

Regards,
Santosh

[[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.


Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Duncan Murdoch

On 22/03/2009 5:05 PM, JiHO wrote:

Hello everyone,

I often create some local libraries of functions (.R files with only  
functions in them) that I latter call. In scripts that call a function  
from such library, I would like to be able to test whether the  
function is already known in the namespace and, only if it is not,  
source the library file. I.e. what `require` does for packages, I want  
to do with my local functions.


That's pretty hard to make bulletproof.  Why not just put those 
functions in a package, and use that package?  If the functions are all 
written in R, creating the package is very easy:  see package.skeleton. 
 (And if you have a perfect memory and don't plan to distribute the 
package to anyone, you can skip documenting the functions:  then it's 
almost no work at all.)


Duncan Murdoch



Example:
lib.R
foo - function(x) { x*2 }

script.R
require.local(foo,lib.R)
	# that searches for function foo and, if not found, executes  
source(lib.R)

foo(2)

Obviously, I want the test to be quite efficient otherwise I might as  
well source the local library every time. I am aware that it would  
probably not be able to check for changes in lib.R (i.e. do  
complicated things such as re-source lib.R if foo in the namespace and  
foo in lib.R are different), but that I can handle manually.


This seems like a common enough workflow but I cannot find a pre- 
existing solution. Does anyone have pointers?


Otherwise I tried to put that together:

require.local - function(fun, lib)
#
#   Searches for function fun and sources lib in
#   case it is not found
#
{
	if (! (deparse(substitute(fun)) %in% ls(.GlobalEnv)  class(fun)  
== function) ) {

cat(Sourcing, lib,...\n)
source(lib)
}
}

but I am really not confident with all those deparse/substitute things  
and the environment manipulation, so I guess there should be a better  
way.


JiHO
---
http://jo.irisson.free.fr/

__
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-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] Axes in 3D plots

2009-03-22 Thread Leah Gerber
I am wondering if anyone knows how to change or rotate the default axes on a 3D 
scatterplot. I would like to change which sides of the cube the 3 axes are 
displayed on. 

Many thanks,

Leah Gerber 



  
[[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.


Re: [R] Axes in 3D plots

2009-03-22 Thread Daniel Moreira
To rotate the graph you can change the viewpoint. Try: ?rgl.viewpoint

library(rgl)
x - sort(rnorm(1000))
y - rnorm(1000)
z - rnorm(1000) + atan2(x,y)
plot3d(x, y, z, col=rainbow(1000), size=2)
start - proc.time()[3]
while ((i - 36*(proc.time()[3]-start))  360) {
  rgl.viewpoint(i,i/4); 
}


To define the side which the axes will be displayed, try: ?axes3d

library(rgl)
x - sort(rnorm(1000))
y - rnorm(1000)
z - rnorm(1000) + atan2(x,y)
plot3d(x, y, z, col=rainbow(1000), size=2,axes=F)
axes3d(c('x--','x+-','x++','x-+','z--','y++'))

hth,


Daniel Moreira, MD




Leah Gerber leahger...@yahoo.com 
Sent by: r-help-boun...@r-project.org
03/22/2009 09:07 PM

To
r-help@r-project.org
cc

Subject
[R] Axes in 3D plots






I am wondering if anyone knows how to change or rotate the default axes on 
a 3D scatterplot. I would like to change which sides of the cube the 3 
axes are displayed on. 

Many thanks,

Leah Gerber 



 
 [[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.


[[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.


Re: [R] If statement generates two outputs

2009-03-22 Thread jim holtman
You appear to have a number of unbalanced parentheses in your
statements.  Here is one that seems to work:

if (nostocks=3)

   {data1-test[,data1stocks];
   tex1-latex(data1, file=paste(i$Species[1], 1.tex, sep=),
rowname = NULL,
cgroup = c(Fishstock, stocknames,Total),
n.cgroup = c(1, rep(2,(nostocks+1)),
colheads = c(Year, rep(c(Catch, TACC),
nostocks+1)),
   size=large,center=none))

}else
   {data1-test[,1:9];data2-test[,data2stocks];
   tex1-latex(data1, file=paste(i$Species[1], 1.tex, sep=),
rowname = NULL,
cgroup = c(Fishstock, stocknames,Total),
n.cgroup = c(1, rep(2,4)),
colheads = c(Year, rep(c(Catch, TACC),
nostocks+1)),
   size=large,center=none);

   tex2-latex(data2, file=paste(i$Species[1], 2.tex, sep=),
   rowname = NULL,
cgroup = c(Fishstock, stocknames,Total),
n.cgroup = c(1, rep(2,((nostocks-4)+1)),
   colheads = c(Year, rep(c(Catch, TACC),
nostocks+1)),size=large,center=none))
}



On Sun, Mar 22, 2009 at 7:59 PM, jimdare jamesdar...@gmail.com wrote:

 Hi,

 I tried to create the following if / else statement but I keep getting the
 error Error: unexpected '}' in size=large,center=none)
 } (I have highlighted the } in bold where the error is occuring).  I can't
 seem to find a reason for this, does anyone know how I can fix it?

 Thanks,
 James

 if (nostocks=3)

                {data1-test[,data1stocks];
                tex1-latex(data1, file=paste(i$Species[1], 1.tex, sep=),
                     rowname = NULL,
                     cgroup = c(Fishstock, stocknames,Total),
                     n.cgroup = c(1, rep(2,(nostocks+1)),
                     colheads = c(Year, rep(c(Catch, TACC),
 nostocks+1)),
                size=large,center=none)

 }else)
                {data1-test[,1:9];data2-test[,data2stocks];
                tex1-latex(data1, file=paste(i$Species[1], 1.tex, sep=),
                     rowname = NULL,
                     cgroup = c(Fishstock, stocknames,Total),
                     n.cgroup = c(1, rep(2,4)),
                     colheads = c(Year, rep(c(Catch, TACC),
 nostocks+1)),
                size=large,center=none);

                tex2-latex(data2, file=paste(i$Species[1], 2.tex, sep=),
                rowname = NULL,
                     cgroup = c(Fishstock, stocknames,Total),
                     n.cgroup = c(1, rep(2,((nostocks-4)+1)),
                colheads = c(Year, rep(c(Catch, TACC),
 nostocks+1)),size=large,center=none)
 }







 jimdare wrote:

 Hi,

 How do I tell an if statement to generate two seperate outputs.

 E.g  If X5 I want to create df1 and df2:

 if (X5) {df1-c(4,5,6,7,8) AND df2-c(9,10,11,12,13)}

 Thanks,
 James


 --
 View this message in context: 
 http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22652363.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.




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

What is the problem that you are trying to solve?

__
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] mvpart error

2009-03-22 Thread Josh Stumpf
Hello all,

When attempting a classification tree using mvpart, I get the following
error:

 thesis2.mvp=mvpart(bat_sp~., data=alltrees.df)
Error in all(keep) :
  unused argument(s) (c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE))

bat_sp is an unordered categorical variable, and the predictors are a
mixture of categorical and continuous variables. I had run the algorithm
successfully in the past (about 1.5 years ago) on a preliminary subset of
the same dataset using a previous version of R  The current system is R
2.8.1 running under Ubuntu Jaunty. Any ideas as to the cause?

Josh Stumpf

Eastern Michigan University

[[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.


[R] Help with 'boot'

2009-03-22 Thread pgseye

Hi,

I'm wanting to test for a difference in medians between 2 groups using
resampling methods. I found the boot package, but don't really understand
how to write the 'statistic' function required as the 2nd argument for the
bootstrap test.

Thanks if you can help,

Paul
-- 
View this message in context: 
http://www.nabble.com/Help-with-%27boot%27-tp22653487p22653487.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] newton method

2009-03-22 Thread Roslina Zakaria

Hi R-users,

Does R has a topic on newton's method?

Thank you for the info.

__
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] Selecting closest values

2009-03-22 Thread Frank E Harrell Jr

bill.venab...@csiro.au wrote:

Here is one way you might find useful


id - 1:183
lo - sample((-22):144, 183, rep = TRUE)
ds - outer(lo, lo, function(x,y) abs(x-y))
rs - t(apply(ds, 2, function(x) id[order(x)][2:11]))
rownames(rs) - id


Here's what I got


head(rs)

  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
1  118   23  125  182  1838   86  119  141   175
2   27  167  1764  126   45  113   81  144   153
3   437   18   60  148   11   12  150   85   163
4  126   27  167  1762   45  144  153   4855
5   15   46   86  141  175   23  125  1831   118
6   58   78  139   13   66  131  156  181  117   157

If you want anything more random in the case of ties than this, you will have to work a bit harder on the code.  


W.

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of P_M
Sent: Monday, 23 March 2009 1:32 AM
To: r-help@r-project.org
Subject: [R] Selecting closest values


Hi
I have a table with ID (1 to 183) and Location (144 to -22).
My problem is that I want to select the 10 ID's that are closest in Location
to ID 1, ID 2 and so on.
Also, some ID have the same Location. Say, if 11 ID's are closest to ID 100
I want to randomly choose one of the ID's to select 10 ID's total.

Thank you

 



Also take a look at the whichClosest function in the Hmisc package.  But 
whichClosest cheats by calling Fortran.


Cheers
Frank

--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
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] newton method

2009-03-22 Thread Michael Kubovy
Take a look at the functionsnlm(), optim() in the stats package and  
maxNR() in the maxLik package.

On Mar 22, 2009, at 11:15 PM, Roslina Zakaria wrote:

 Does R has a topic on newton's method?


_
Professor Michael Kubovy
University of Virginia
Department of Psychology
Postal Address:
P.O.Box 400400, Charlottesville, VA 22904-4400
Express Parcels Address:
Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903
Office:B011;Phone: +1-434-982-4729
Lab:B019;   Phone: +1-434-982-4751
WWW:http://www.people.virginia.edu/~mk9y/
Skype name: polyurinsane





[[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.


Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Ken-JP

I agree with Duncan.  I used to do exactly what you did - source()ing data
files inside a wrapper not unlike C #define wrappers, but it became a
headache with more files and the files began looking more cluttered.

It has taken me several days to learn about how create a package properly,
along with package RUnit for unit-testing, and with documentation.  The R
Extensions file is often a good source of information.  Be sure you find
information about Rcmd install and Rcmd check, which are also very useful. 
prompt() can help you build your .Rd (help files).  Alternatively, you may
use Rdoc$compile() (from package R.oo) if you intend to embed your
Rdoc-style comments inside your R code, as I do.  I also use R.oo as a more
traditional object-oriented alternative to S3/S4.  Once set-up, you can
automagically generate .pdf files and .chm (windows-based help) for your
package.  Help for my own package has helped me keep my code consistent,
clean, and re-factorable.  Best of all, you can use put require( my.package
) or data( my.data) and voila.

It has been a bit of a learning curve, but the packaging facilities in R are
actually very well developed.  Once set-up, maintenance becomes less of a
chore.  Good luck.


Duncan Murdoch-2 wrote:
 
 On 22/03/2009 5:05 PM, JiHO wrote:
 Hello everyone,
 
 I often create some local libraries of functions (.R files with only  
 functions in them) that I latter call. In scripts that call a function  
 from such library, I would like to be able to test whether the  
 function is already known in the namespace and, only if it is not,  
 source the library file. I.e. what `require` does for packages, I want  
 to do with my local functions.
 
 That's pretty hard to make bulletproof.  Why not just put those 
 functions in a package, and use that package?  If the functions are all 
 written in R, creating the package is very easy:  see package.skeleton. 
   (And if you have a perfect memory and don't plan to distribute the 
 package to anyone, you can skip documenting the functions:  then it's 
 almost no work at all.)
 
-- 
View this message in context: 
http://www.nabble.com/%27require%27-equivalent-for-local-functions-tp22650626p22653884.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.