Re: [R] help with the maxBHHH routine

2011-05-03 Thread Arne Henningsen
Dear Rohit

On 3 May 2011 22:53, Rohit Pandey  wrote:
> Hello R community,
>
> I have been using R's inbuilt maximum likelihood functions, for the
> different methods (NR, BFGS, etc).
>
> I have figured out how to use all of them except the maxBHHH function. This
> one is different from the others as it requires an observation level
> gradient.
>
> I am using the following syntax:
>
> maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)
>
> where logLik is the likelihood function and returns a vector of observation
> level likelihoods and nuGradient is a function that returns a matrix with
> each row corresponding to a single observation and the columns corresponding
> to the gradient values for each parameter (as is mentioned in the online
> help).
>
> however, this gives me the following error:
>
> *Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
> :
>  the matrix returned by the gradient function (argument 'grad') must have
> at least as many rows as the number of parameters (10), where each row must
> correspond to the gradients of the log-likelihood function of an individual
> (independent) observation:
>  currently, there are (is) 10 parameter(s) but the gradient matrix has only
> 2 row(s)
> *
> It seems it is expecting as many rows as there are parameters. So, I changed
> my likelihood function so that it would return the transpose of the earlier
> matrix (hence returning a matrix with rows equaling parameters and columns,
> observations).
>
> However, when I run the function again, I still get an error:
> *Error in gr[, fixed] <- NA : (subscript) logical subscript too long*
>
> I have verified that my gradient function, when summed across observations
> gives the same results as the in built numerical gradient (to the 11th
> decimal place - after that, they differ since R's function is numerical).
>
> I am trying to run a very large estimation (1000's of observations and 821
> parameters) and all of the other methods are taking way too much time
> (days). This method is our last hope and so, any help will be greatly
> appreciated.

Please make yourself familiar with the BHHH algorithm and read the
documentation of maxBHHH: it says about argument "grad":

"[...] If the BHHH method is used, ‘grad’ must return a matrix, where
rows correspond to the gradient vectors of individual observations and
the columns to the individual parameters.[...]"

More information of the maxLik package is available at:
http://dx.doi.org/10.1007/s00180-010-0217-1

Best regards,
Arne

-- 
Arne Henningsen
http://www.arne-henningsen.name

__
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

2011-05-03 Thread Nekeisha Spencer
 Accelerated Failure Time Model to Proportional Hazard Form

Greetings R users:

I have been working on a problem for  a while and can't seem to get any result. 
I am trying to convert  accelerated failure time estimates to proportional 
form. 
I keep getting an error that I can't understand and don't know if it can be 
debugged or not. My code is as follows:


data<-read.csv("repdata.csv")
da<-na.omit(data)
attach(da)
library(survival)
library(rms)
weib1<-psm(Surv(time,ratified)~island+pop+gdppc+fh+nngo+industryemplimp+icrgfromper+ngoicrgfromper+industryemplimpicrgfromper,
 data=da, dist="weibull",init=NULL, scale=0, 
control=survreg.control(maxiter=1000))
print(weib1)
f.ph<-pphsm(weib1)

However, after running the last line of code, I get  the following:

Warning message:
In pphsm(weib1) :
  at present, pphsm does not return the correct covariance matrix


 Any suggestions will be greatly appreciated!! My data is attached. 

Thanks in Advance


 NSPENCER
__
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] RStudio -manipulate command

2011-05-03 Thread veepsirtt
Why the mean value  " h" is not changing as the slider moves from 0 to 25 ?.
It remains always constant.

library(manipulate)

example <- function(x.max){
plot(cars, xlim=c(0,x.max)) 
abline(h=mean(cars$dist),col="blue",lty=2) }

manipulate(
example(x.max), x.max=slider(0,25, step=5) )

veepsirtt

--
View this message in context: 
http://r.789695.n4.nabble.com/RStudio-manipulate-command-tp3474947p3494489.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] nls problem with R

2011-05-03 Thread sterlesser
the original data are
V2 =c(371000,285000 ,156000, 20600, 4420, 3870, 5500 )
T2=c( 0.3403 ,0.4181 ,0.4986 ,0.7451 ,1.0069 ,1.553)
nls2=nls(V2~v0*(1-epi+epi*exp(-cl*(T2-t0))),start=list(v0=10^7,epi=0.9,cl=6.2,t0=8.7))
after execution error occurs as below

Error in nlsModel(formula, mf, start, wts) : 
  singular gradient matrix at initial parameter estimates
Error in nlsModel(formula, mf, start, wts) : 
  singular gradient matrix at initial parameter estimates
In addition: Warning messages:
1: In lhs - rhs :
  longer object length is not a multiple of shorter object length
2: In .swts * attr(rhs, "gradient") :
  longer object length is not a multiple of shorter object length

could anyone help me ?thansks

--
View this message in context: 
http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3494454.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to fit a random data into Beta distribution?

2011-05-03 Thread Shekhar
Hi Steven,
Thanks for the quick reply. i have tried but
its giving me error--->Error in optim(x = c(38.1815173696765,
-12.7988197976440, -3.88212459045077,  :
  initial value in 'vmmin' is not finite


i have tried something like this:

library(MASS)
x<-rnorm(n=100,mean=10,sd=20);
fitdistr(x,dbeta,start=list(shape1=1,shape2=1)

Please correct me if my understanding is wrong:
In the fitdistr fucntion we are providing the initial values of the
Beta distribution parameters as shape1=1 and shape2=1. This function
will try to fit the data and give us the new parameters of Beta
distribution that approximately fits this data.


I have tried the function with other distribution like Normal, Gamma,
Weibull...its working fine..

Regards,
Som Shekhar




On May 4, 1:25 am, Steven Kennedy  wrote:
> library(MASS)
> fitdistr(x,"beta",list(shape1=1,shape2=1))
>
>
>
> On Tue, May 3, 2011 at 9:44 PM, Shekhar  wrote:
>
> > Hi,
> > I have some random data and i want to find out the parameters of Beta
> > distribution ( a and b) such that this data approximately fits into
> > this distribution. I have tried by plot the histograms and graph, but
> > it requires lot of tuning and i am unable to do that. can anyone tell
> > me how to do it programmitically in R?
>
> > Regards,
> > Som Shekhar
>
> > __
> > r-h...@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] problem with package "adapt" for R in Mac

2011-05-03 Thread Matías Ramírez Salgado
Hi,

How i can install the package "adapt" in some version of R for mac?

i try in 2.13, 2.9,2.7 and other previous versions... and nothing happens.

and another question: There are some packages that do the same but that it
is implemented for mac? (calculate integrals in 2 or more dimmensions).

help me please, it's for an important work.

greetings.


-- 
Matías Hernán Ramírez Salgado.
Estudiante de Estadística.
Pontificia Universidad Católica de Chile.

[[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] na.omit - Is it working properly?

2011-05-03 Thread peter dalgaard

On May 3, 2011, at 21:18 , Kalicin, Sarah wrote:

> 
> I have a work around for this, but can someone explain why the first example 
> does not work properly? I believed it worked in the previous version of R, by 
> selecting just the rows=200525 and omitting the na's. I just upgraded to 
> 2.13. I am also concern with the row numbers being different in the 
> selections, should I be worried? FYI, I just selected the first few rows for 
> demonstration, please do not worry that the number of rows shown are not 
> equal. - Sarah
> 
> With na.omit around the column, but it is showing other values in the F.WW 
> column other than 200525, along with NA.  I was hoping that this would omit 
> all the NA's, and show all the rows that P$F.WW=200525. I believe it did with 
> the previous version of R.

That's highly unlikely. na.omit(P$WW) has fewer elements than there are rows in 
P so you get vector recycling in the style of 

> thuesen[c(F,F,F,F,T),]
   blood.glucose short.velocity
57.2   1.27
10  12.2   1.22
15   6.7   1.52
20  16.1   1.05

(now why don't we get the usual warning about "not a multiple of" in this case?)

Worse, if you omit observations prior to comparison, the result won't line up. 
E.g. in the thuesen data, obs.

> thuesen[na.omit(thuesen$short.velocity)==1.12,]
   blood.glucose short.velocity
16   8.6 NA
22   4.9   1.03

whereas in fact 

> subset(thuesen, short.velocity==1.12)
   blood.glucose short.velocity
17   4.2   1.12
23   8.8   1.12



> P[na.omit(P$F.WW)==200525, c(51, 52)]
>  F.WWR.WW
> 45  200525  NA
> 53  NA  NA
> 61  200534  200534
> 63  200608  200608
> 66  200522  200541
> 80  NA  NA
> 150 200521  200516
> 231 200530  200530
> 
> No na.omit, the F.WW=200525 seems to work, but lots of NA included. This is 
> what is expected!! The row numbers are not the same as the above example, 
> except the first row.
>> P[P$F.WW==200525, c(51, 52)]
>F.WW R.WW
> 45200525  NA
> NANA  NA
> NA.1  NA  NA
> NA.2  NA  NA
> NA.3  NA  NA
> 57200525  200526
> 65200525  NA
> 67200525  NA
> 70200525  200525
> NA.4  NA  NA
> NA.5  NA  NA
> 86200525  NA

Presumably, a number of rows got omitted here? The NA's are a bit of a pain, 
but that's the way things work: If there is an observation that you don't know 
whether to include, you get an NA filled row.

> thuesen[thuesen$short.velocity==1.12,]
   blood.glucose short.velocity
NANA NA
17   4.2   1.12
23   8.8   1.12

To avoid this, you explicitly test for NA using is.na() or use subset() which 
does it internally. 

> 
> Na.omit excludes the na's. This is what I want. The concern I have is why the 
> row numbers do not match any of those shown in the examples above.
>> na.omit(P[P$F.WW==200525, c(51, 52)])
>F.WWR.WW
> 57200525  200526
> 70200525  200525
> 161   200525  200525
> 245   200525  200525
> 246   200525  200525
> 247   200525  200526
> 256   200525  200525
> 266   200525  200525
> 269   200525  200525
> 271   200525  200526
> 276   200525  200526
> 278   200525  200526
> 

Well, now you remove rows with NA _anywhere_, so e.g. row #65 is out because 
R.WW is missing. I expect #161 and higher was just chopped from the earlier 
list. 

In short, nothing out of the ordinary seems to be going on here.


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] fitting distributions using fitdistr (MASS)

2011-05-03 Thread David Winsemius


On May 3, 2011, at 10:03 PM, Usha wrote:


Thanks for the help.
I would like to explain my problem.
I have sample of scores from tests which varies form 0 to 35.
Now, i want to find out the best fit distribution for this data. I  
need to

order the distributions based on their best fit.
For this i am using the function fitdistr(). [One of the Ref.used :  
FITTING

DISTRIBUTIONS WITH R by Vito Ricci. ]

Example:

scores<-sample(0:35,500,replace=T)
normalfit<-fitdistr(scores,"normal")
normalfit

   mean  sd
16.846   10.1361869
( 0.4533041) ( 0.3205344)

normalfit$loglik

[1] -1867.525
kstestnormal<-ks.test(scores,"pnorm",16.846, 10.1361869) # for  
the

measure of goodness


1) Am i doing the right thing?


No. The most important right thing you are not doing is describing  
your goals. Clearly you do _not_ want the best fitting distribution,  
since the best fit distribution would be a multinomial distribution  
with whatever probabilities would exactly fit the sample.



2) If yes, can't i follow the same procedure for all the distributions
supported by fitdistr? With the start values wherever necessary?


You can do anything you want. But have you considered the power of  
this method and the error rates? Is there no science behind this to  
guide what is so far an aimless search strategy?



3) Do I have to consider/worry about the warnings that I get?


We cannot force you to heed the warnings.


--
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] fitting distributions using fitdistr (MASS)

2011-05-03 Thread Usha
Thanks for the help. 
I would like to explain my problem.
I have sample of scores from tests which varies form 0 to 35.
Now, i want to find out the best fit distribution for this data. I need to
order the distributions based on their best fit.
For this i am using the function fitdistr(). [One of the Ref.used : FITTING
DISTRIBUTIONS WITH R by Vito Ricci. ]

 Example:
> scores<-sample(0:35,500,replace=T)
> normalfit<-fitdistr(scores,"normal")
> normalfit
mean  sd
16.846   10.1361869
( 0.4533041) ( 0.3205344)
> normalfit$loglik
[1] -1867.525
 > kstestnormal<-ks.test(scores,"pnorm",16.846, 10.1361869) # for the
measure of goodness


1) Am i doing the right thing?
2) If yes, can't i follow the same procedure for all the distributions
supported by fitdistr? With the start values wherever necessary?
3) Do I have to consider/worry about the warnings that I get? 

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/fitting-distributions-using-fitdistr-MASS-tp3492526p3494532.html
Sent from the R help mailing list archive at Nabble.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] Specification of the model

2011-05-03 Thread jouba

Hi all ,
1. In Laavan the package when you have two variables a and b which have a 
direct effect on one another for example like this: (a ↔ b), To write this in 
the model we must write how:a ~~b Or we must write two equations:a ~ bb ~ a
in this case there is some information to add for the residues
 
 
 
 
 
Thank you in advance

Antra EL MOUSSELLY 

  

--
View this message in context: 
http://r.789695.n4.nabble.com/Structural-equation-modeling-in-R-lavaan-sem-tp3409642p3494391.html
Sent from the R help mailing list archive at Nabble.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] na.omit - Is it working properly?

2011-05-03 Thread P Ehlers

Kalicin, Sarah wrote:
\begin{quote}
I have a work around for this, but can someone explain
why the first example does not work properly?
I believed it worked in the previous version of R,
by selecting just the rows=200525 and omitting the na's.
\end{quote}

You can prove this statement by providing reproducible
code that we can test.

Peter Ehlers

I just upgraded to 2.13. I am also concern with the row numbers being 
different in the selections, should I be worried? FYI, I just selected 
the first few rows for demonstration, please do not worry that the 
number of rows shown are not equal. - Sarah


With na.omit around the column, but it is showing other values in the F.WW 
column other than 200525, along with NA.  I was hoping that this would omit all 
the NA's, and show all the rows that P$F.WW=200525. I believe it did with the 
previous version of R.
P[na.omit(P$F.WW)==200525, c(51, 52)]
  F.WWR.WW
45  200525  NA
53  NA  NA
61  200534  200534
63  200608  200608
66  200522  200541
80  NA  NA
150 200521  200516
231 200530  200530

No na.omit, the F.WW=200525 seems to work, but lots of NA included. This is 
what is expected!! The row numbers are not the same as the above example, 
except the first row.

P[P$F.WW==200525, c(51, 52)]

F.WW R.WW
45200525  NA
NANA  NA
NA.1  NA  NA
NA.2  NA  NA
NA.3  NA  NA
57200525  200526
65200525  NA
67200525  NA
70200525  200525
NA.4  NA  NA
NA.5  NA  NA
86200525  NA

Na.omit excludes the na's. This is what I want. The concern I have is why the 
row numbers do not match any of those shown in the examples above.

na.omit(P[P$F.WW==200525, c(51, 52)])

F.WWR.WW
57200525  200526
70200525  200525
161   200525  200525
245   200525  200525
246   200525  200525
247   200525  200526
256   200525  200525
266   200525  200525
269   200525  200525
271   200525  200526
276   200525  200526
278   200525  200526

[[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] help with the maxBHHH routine

2011-05-03 Thread Ravi Varadhan
maxBHHH is *not* an in-built R function.  It is in a distributed package called 
"maxLik".  Always tell us which package is being used so that it is easier for 
us to help you.

The error message says that the gradient function is returning a 10 x 2 matrix, 
whereas you say that you have 1000's of observations and 821 parameters.  Show 
us a simplified version of your problem.  It is difficult to help you without 
seeing an example. 

Also, try running w/o the gradient and see how it works.  This is not the 
answer you wanted, but we cannot help you w/o seeing your example.

Ravi.


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Rohit Pandey [rohitpandey...@gmail.com]
Sent: Tuesday, May 03, 2011 4:53 PM
To: r-help@r-project.org
Subject: [R] help with the maxBHHH routine

Hello R community,

I have been using R's inbuilt maximum likelihood functions, for the
different methods (NR, BFGS, etc).

I have figured out how to use all of them except the maxBHHH function. This
one is different from the others as it requires an observation level
gradient.

I am using the following syntax:

maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)

where logLik is the likelihood function and returns a vector of observation
level likelihoods and nuGradient is a function that returns a matrix with
each row corresponding to a single observation and the columns corresponding
to the gradient values for each parameter (as is mentioned in the online
help).

however, this gives me the following error:

*Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
:
  the matrix returned by the gradient function (argument 'grad') must have
at least as many rows as the number of parameters (10), where each row must
correspond to the gradients of the log-likelihood function of an individual
(independent) observation:
 currently, there are (is) 10 parameter(s) but the gradient matrix has only
2 row(s)
*
It seems it is expecting as many rows as there are parameters. So, I changed
my likelihood function so that it would return the transpose of the earlier
matrix (hence returning a matrix with rows equaling parameters and columns,
observations).

However, when I run the function again, I still get an error:
*Error in gr[, fixed] <- NA : (subscript) logical subscript too long*

I have verified that my gradient function, when summed across observations
gives the same results as the in built numerical gradient (to the 11th
decimal place - after that, they differ since R's function is numerical).

I am trying to run a very large estimation (1000's of observations and 821
parameters) and all of the other methods are taking way too much time
(days). This method is our last hope and so, any help will be greatly
appreciated.

--
Thanks in advance,
Rohit
Mob: 91 9819926213

[[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] scatterplot3d using colors in groups

2011-05-03 Thread Duncan Mackay

At 10:15 04/05/2011, you wrote:

Content-Type: text/plain
Content-Disposition: inline
Content-length: 537

Hi everyone,

I would like to improve my plot and I was 
wondering if someone can help me whith it. I'm 
trying this plot using two groups, but I want to 
choice the colors (the black and white circles) 
but I don't know how to change it from here. These are my sentences:


myplot3d<- scatterplot3d(myfile$Temperature,
acantarcthus$Salinity,myfile$Abundance, type="h",
   color = as.integer(factor(myfile$groups)))

If someone is willing to help me with it I would be so glad.

José

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


Hi José

Have you seen the result of 
as.integer(factor(myfile$groups))) ? I would have given you a clue.


What you need is c("black","white") or the 
numerical col number equivalent by the order of the groups.


2 ways:

ifelse(myfile$groups == factor1, "black","white")

or if you had more factors

sapply(myfile$groups, pmatch, unique(myfile$groups) )

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email: home mac...@northnet.com.au

__
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] Watts Strogatz game

2011-05-03 Thread Andrew Robinson
Hi,

I have no familiarity with these functions --- I see that they are not
in base R --- so I suggest that at very least you identify the package
that you are using.  Better would be to contact the package maintainer
directly.  Sometimes maintainers do not read R-help.

Cheers

Andrew

On Tue, May 03, 2011 at 12:42:55AM -0700, kparamas wrote:
> Hi,
> 
> I have a erdos-renyi game with 6000 nodes and probability 0.003.
> 
> g1 = erdos.renyi.game(6000, 0.003)
> 
> How to create a Watts Strogatz game with the same probability.
> 
> g1 = watts.strogatz.game(1, 6000, ?, ?)
> What should be the third and fourth parameter to this argument.
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Watts-Strogatz-game-tp3491922p3491922.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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] scatterplot3d using colors in groups

2011-05-03 Thread Jose Bustos Melo
Hi everyone, 

I would like to improve my plot and I was wondering if someone can help me 
whith it. I'm trying this plot using two groups, but I want to choice the 
colors (the black and white circles) but I don't know how to change it from 
here. These are my sentences:

myplot3d<- scatterplot3d(myfile$Temperature,
acantarcthus$Salinity,myfile$Abundance, type="h",
   color = as.integer(factor(myfile$groups)))

If someone is willing to help me with it I would be so glad.

José

[[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] Compiling Rgraphiz on Windows 7 64bit with R-2.13.0

2011-05-03 Thread Martin Morgan

On 05/03/2011 03:23 PM, Ben Rhelp wrote:

Hi all,

I am trying to compile Rgraphiz on Windows 7 64bit with R-2.13.0. I have
installed

Rtools213.exe from [1]. The 64bit packages in [2] provided me with the 64 bit
version
of graphviz. After intalling the binary version Rgraphviz 1.30 (in 32bit) it
complains (as

expected) that:

library(Rgraphviz)

Error: package 'Rgraphviz' is not installed for 'arch=x64'

I don't understand why the 64 bit version of graphiz is provided but not one for
Rgraphviz.
Have I missed it somewhere? In any case, it is suggested to build it from
source, so I tried
following the steps of the README from the source package of Rgraphviz (see
below). I have the
same error than in [3]. Does anyone know what is going on or if Kasper found a
solution back

in 2009?

thanks in advance,

Cheers,

Ben


C:\BenSave>R --arch x64 CMD build --binary .\Rgraphviz
--binary is deprecated
* checking for file '.\Rgraphviz/DESCRIPTION' ... OK
* preparing 'Rgraphviz':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to re-build vignettes
   ---
* installing *source* package 'Rgraphviz' ...
Using the following environment variables
GRAPHVIZ_INSTALL_DIR=C:\/BenSave\/GoodiesWin64\/graphviz
GRAPHVIZ_INSTALL_MAJOR=2
GRAPHVIZ_INSTALL_MINOR=20
GRAPHVIZ_INSTALL_SUBMINOR=3


These should be set to match the version of the graphviz library you're 
using, MINOR=25 SUBMINOR=20090912.0445



Using the following compilation and linking flags for Rgraphviz
PKG_CPPFLAGS=-IC:\/BenSave\/GoodiesWin64\/graphviz/include/graphviz
PKG_LIBS=-LC:\/BenSave\/GoodiesWin64\/graphviz/bin -lgvc-4 -lgraph-4 -lcdt-4


Unfortunately, these will now be incorrect; edit Rgraphviz/configure.win 
so that the line that includes


  test ${GRAPHVIZ_INSTALL_MINOR} -eq "21"

reads

  test ${GRAPHVIZ_INSTALL_MINOR} -ge "21"

Martin



GVIZ_DEFS=-DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
Created file src/Makevars.win
Created file R/graphviz_build_version.R
** libs
cygwin warning:
   MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.0/etc/x64/Makeconf
   Preferred POSIX equivalent is: 
/cygdrive/c/PROGRA~1/R/R-213~1.0/etc/x64/Makeco
nf
   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
   Consult the user's guide for more details about POSIX paths:
 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c LL_funcs.c -o LL_funcs.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c Rgraphviz.c -o Rgraphviz.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c RgraphvizInit.c -o RgraphvizInit.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c agopen.c -o agopen.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c agread.c -o agread.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c agwrite.c -o agwrite.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c bezier.c -o bezier.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c buildEdgeList.c -o buildEdgeList.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c buildNodeList.c -o buildNodeList.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
   -O2 -Wall  -std=gnu99 -c doLayout.c -o doLayout.o
doLayout.c: In function 'getEdgeLocs':
doLayout.c:131:17: error: 'textlabel_t' has no member named 'p'
doLayout.c:132:17: error: 'textlabel_t' has no member named 'p'
doLayout.c: In function 'getNodeLayouts':
doLayout.c:243:13: error: 'textlabel_t' has no member named 'p'
doLayout.c:244:13: error: 'textlabel_t' has no member named 'p'
make: *** [doLayout.o] Error 1
ERROR: compilation fail

[R] error term for ANOVA of generalized randomized block design

2011-05-03 Thread Kelsey Ketcheson
Does anyone know how to write the code for an anova for a generalized
randomized block design?  I have two blocks (random) and three treatments
(fixed).  Each treatment has two reps at each site.  I know that for a RCBD
with no replication that an anova can be run using aov(object~Block *Trt),
but I think I need to specify an error term for the GRBD.

[[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] na.omit - Is it working properly?

2011-05-03 Thread Andrew Robinson
Hi Sarah,

I'm not sure that I understand your problem.  You have shown us three
ways to try to omit missing values, and one of them seems to work.
But you're concerned because some aspect of it doesn't match the ones
that don't work?  But they don't work!  

I wonder if you could send an example in commented, minimal,
self-contained, reproducible code ...

Cheers

Andrew

On Tue, May 03, 2011 at 12:18:03PM -0700, Kalicin, Sarah wrote:
> 
> I have a work around for this, but can someone explain why the first example 
> does not work properly? I believed it worked in the previous version of R, by 
> selecting just the rows=200525 and omitting the na's. I just upgraded to 
> 2.13. I am also concern with the row numbers being different in the 
> selections, should I be worried? FYI, I just selected the first few rows for 
> demonstration, please do not worry that the number of rows shown are not 
> equal. - Sarah
> 
> With na.omit around the column, but it is showing other values in the F.WW 
> column other than 200525, along with NA.  I was hoping that this would omit 
> all the NA's, and show all the rows that P$F.WW=200525. I believe it did with 
> the previous version of R.
> P[na.omit(P$F.WW)==200525, c(51, 52)]
>   F.WWR.WW
> 45  200525  NA
> 53  NA  NA
> 61  200534  200534
> 63  200608  200608
> 66  200522  200541
> 80  NA  NA
> 150 200521  200516
> 231 200530  200530
> 
> No na.omit, the F.WW=200525 seems to work, but lots of NA included. This is 
> what is expected!! The row numbers are not the same as the above example, 
> except the first row.
> > P[P$F.WW==200525, c(51, 52)]
> F.WW R.WW
> 45200525  NA
> NANA  NA
> NA.1  NA  NA
> NA.2  NA  NA
> NA.3  NA  NA
> 57200525  200526
> 65200525  NA
> 67200525  NA
> 70200525  200525
> NA.4  NA  NA
> NA.5  NA  NA
> 86200525  NA
> 
> Na.omit excludes the na's. This is what I want. The concern I have is why the 
> row numbers do not match any of those shown in the examples above.
> > na.omit(P[P$F.WW==200525, c(51, 52)])
> F.WWR.WW
> 57200525  200526
> 70200525  200525
> 161   200525  200525
> 245   200525  200525
> 246   200525  200525
> 247   200525  200526
> 256   200525  200525
> 266   200525  200525
> 269   200525  200525
> 271   200525  200526
> 276   200525  200526
> 278   200525  200526
> 
>   [[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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] delete excel id automatically generated

2011-05-03 Thread Andrew Robinson
Try the function

rownames()

Andrew

On Tue, May 03, 2011 at 03:29:37AM -0700, agent dunham wrote:
> Dear community, 
> 
> I uploaded an excel with read.xls. My xls file actually have a column which
> is an id, ("plot" is the id) : 
> 
> plot height area
> 347.6 5.4
> 853.2 4.1
> 895.4 8.4
> 121   6.76.2
> ...
> 1325  2.11.5
> 
> However R uses another id, this way: 
> 
> r id   plot height  area
>  1  347.6 5.4
>  2  853.2 4.1
>  3  895.4 8.4
>  4 1216.76.2
> ...
> 314  1325   2.11.5
> 
> I'd like that R used "plot" id because I delete some rows while studying
> regression, and R seems to be using the first id 1,2,3,4,...,314. Sometimes
> it's a mess to understand what R means in the plots when, for instance,
> states that data 200 is influential
> 
> Thanks in advance, u...@host.com
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/delete-excel-id-automatically-generated-tp3492147p3492147.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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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 with the maxBHHH routine

2011-05-03 Thread Andrew Robinson
I suggest that you provide some commented, minimal, self-contained,
reproducible code.

Cheers

Andrew

On Wed, May 04, 2011 at 02:23:29AM +0530, Rohit Pandey wrote:
> Hello R community,
> 
> I have been using R's inbuilt maximum likelihood functions, for the
> different methods (NR, BFGS, etc).
> 
> I have figured out how to use all of them except the maxBHHH function. This
> one is different from the others as it requires an observation level
> gradient.
> 
> I am using the following syntax:
> 
> maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)
> 
> where logLik is the likelihood function and returns a vector of observation
> level likelihoods and nuGradient is a function that returns a matrix with
> each row corresponding to a single observation and the columns corresponding
> to the gradient values for each parameter (as is mentioned in the online
> help).
> 
> however, this gives me the following error:
> 
> *Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
> :
>   the matrix returned by the gradient function (argument 'grad') must have
> at least as many rows as the number of parameters (10), where each row must
> correspond to the gradients of the log-likelihood function of an individual
> (independent) observation:
>  currently, there are (is) 10 parameter(s) but the gradient matrix has only
> 2 row(s)
> *
> It seems it is expecting as many rows as there are parameters. So, I changed
> my likelihood function so that it would return the transpose of the earlier
> matrix (hence returning a matrix with rows equaling parameters and columns,
> observations).
> 
> However, when I run the function again, I still get an error:
> *Error in gr[, fixed] <- NA : (subscript) logical subscript too long*
> 
> I have verified that my gradient function, when summed across observations
> gives the same results as the in built numerical gradient (to the 11th
> decimal place - after that, they differ since R's function is numerical).
> 
> I am trying to run a very large estimation (1000's of observations and 821
> parameters) and all of the other methods are taking way too much time
> (days). This method is our last hope and so, any help will be greatly
> appreciated.
> 
> -- 
> Thanks in advance,
> Rohit
> Mob: 91 9819926213
> 
>   [[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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] Unexp. behavior from boot with multiple statistics

2011-05-03 Thread Andrew Robinson
Your interpretation of what the output is supposed to look like is
actually correct.  Take a look at the estimates of the bias in the
BootStrap Statistics.  You will see that they are the same as the
difference between the location of colMeans of t and t0.

I hope that this helps,

Andrew

On Tue, May 03, 2011 at 12:15:05PM -0700, algorimancer wrote:
> I am attempting to use package boot to summarize and compare the performance
> of three models.  I'm using R 2.13.0 in a Win32 environment.
> 
> My statistic function returns a vector of 6 values, 3 of which are error
> rates for different models, and 3 are pairwise differences between those
> error rates.  It looks like:
> 
> multiEst<-function(dat,i)
> {
>
>   c(E1,E2,E3,E2-E1,E3-E1,E3-E2);
> }
> 
> then I call boot (using R=4 for simplicity of description) with:
> 
> multiBoot=boot(data,multiEst,R=4)
> 
> which gives reasonable results:
> 
> Bootstrap Statistics :
> original  biasstd. error
> t1* 0.07  0.3775  0.04193249
> t2* 0.08  0.3750  0.04654747
> t3* 0.04  0.4200  0.05354126
> t4* 0.01 -0.0025  0.0050
> t5*-0.03  0.0425  0.0150
> t6*-0.04  0.0450  0.01290994
> 
> and the resulting "t0" contains the expected estimates of the statistics,
> > multiBoot$t0
> [1]  0.07  0.08  0.04  0.01 -0.03 -0.04
> 
> however "t", which is supposed to contain bootstrap replicates of the
> statistic, doesn't.  It looks like this:
> > multiBoot$t
>  [,1] [,2] [,3] [,4] [,5]  [,6]
> [1,] 0.46 0.47 0.46 0.01 0.00 -0.01
> [2,] 0.39 0.39 0.39 0.00 0.00  0.00
> [3,] 0.45 0.46 0.47 0.01 0.02  0.01
> [4,] 0.49 0.50 0.52 0.01 0.03  0.02
> 
> It is not clear where these columns come from --- they clearly do not
> resemble the estimates in "t0".
> 
> If I define a separate statistic function for each desired estimate, the
> resulting "t" and "t0" are as expected, however it is important in this case
> that the separate estimates derive from the same bootstrap replicates.
> 
> Any helpful suggestions? Or have I come upon a bug in the implementation?
> 
> Note: the documentation provides the following definitions for these
> returned variables:
> 
> t0The observed value of statistic applied to data.
> t A matrix with R rows each of which is a bootstrap replicate of 
> statistic. 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Unexp-behavior-from-boot-with-multiple-statistics-tp3493300p3493300.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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] having trouble with "R CMD INSTALL"

2011-05-03 Thread Gene Leynes
Uwe,

It think the problem turned out to be with my "profile.site" file.

As I recall, temporarily deleting / renaming it was the simple fix.  I think
it had to do with something I use to parse the commandArgs

Thank you for your reply, and sorry for not responding sooner.  I didn't
think anyone responded!

Gene



2011/4/20 Uwe Ligges 

> Not sure what you are really doing, but
>
> R --vanilla CMD INSTALL something
>
> runs in a vanilla style. I just tested with a local .Rprofile under with
> R-2.13.0 under Windows.
> Perhaps it is specific to the package your are talking about? Perhaps you
> can make it available for further inspection of this problem?
>
> Uwe Ligges
>
>
>
>
>
> On 19.04.2011 01:55, Gene Leynes wrote:
>
>> Hello,
>>
>> I was having trouble passing in command line options when doing an package
>> install earlier.
>>
>>  From An Introduction in R
>>>
>>
>>  In addition, you can use25<
>>> http://cran.r-project.org/doc/manuals/R-intro.html#fn-25>options
>>>
>>> --arch=, --no-environ, --no-init-file, --no-site-file and
>>> --vanillabetween
>>> R and CMD: these affect any R processes run by the tools. (Here
>>> --vanillais equivalent to --no-environ
>>>
>>> --no-site-file --no-init-file.)
>>>
>>>  R CMD cmd arg
>>
>>
>> When I tried doing this, two unexpected things happened:
>>
>>1. --vanilla doesn't have an effect when used with R CMD  (R --vanilla
>>
>>CMD INSTALL rj_0.5.2-1.tar.gz)
>>2. When loading my functions from "Rprofile.site" that seems to
>> interfere
>>
>>with the INSTALL command.  I temporarily deleted the Rprofile.site
>> contents,
>>and the install worked as expected.  Maybe it's because I'm also
>> parsing the
>>arguments after the --args flag?
>>
>> The second item is probably "user error" on my part.
>> The first item seems like a possible R bug, but I'm not ruling out "user
>> error".  See "?user.error" for a sample error message
>>
>>
>> I finally got the package installed, but wanted to report this if it
>> really
>> is a bug.
>>
>>
>>
>> The lines below come from a DOS prompt:
>>
>> c:\Users\gene.leynes\Downloads>dir /B
>> gdata_2.8.1.zip
>> rj_0.5.2-1.tar.gz
>> c:\Users\gene.leynes\Downloads>R --vanilla
>>
>> R version 2.13.0 (2011-04-13)
>> Copyright (C) 2011 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>>   Natural language support but running in an English locale
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>>  R.Version()
>>>
>> $platform
>> [1] "i386-pc-mingw32"
>>
>> $arch
>> [1] "i386"
>>
>> $os
>> [1] "mingw32"
>>
>> $system
>> [1] "i386, mingw32"
>>
>> $status
>> [1] ""
>>
>> $major
>> [1] "2"
>>
>> $minor
>> [1] "13.0"
>>
>> $year
>> [1] "2011"
>>
>> $month
>> [1] "04"
>>
>> $day
>> [1] "13"
>>
>> $`svn rev`
>> [1] "55427"
>>
>> $language
>> [1] "R"
>>
>> $version.string
>> [1] "R version 2.13.0 (2011-04-13)"
>>
>>  q()
>>>
>>
>> c:\Users\gene.leynes\Downloads>R --vanilla CMD INSTALL rj_0.5.2-1.tar.gz
>> Function_II.R :
>> Function_IM.R :
>> Function_NAsummary.R :
>> Function_YahooAdjCloseAsZoo.R :
>> Function_addbg.R :
>> Function_bgfun.R :
>> Function_boxplot2.R :
>> Function_clipdir.R :
>> Function_clipper.R :
>> Function_clipstar.R :
>> Function_comma.R :
>> Function_count.na.R :
>> Function_dftab.R :
>> Function_enclose.R :
>> Function_eye.R :
>> Function_factors.R :
>> Function_finder.R :
>> Function_headstr.R :
>> Function_inin.R :
>> Function_lll.R :
>> Function_loader.R :
>> Function_ma.R :
>> Function_makebm.R :
>> Function_makegm.R :
>> Function_makegroups.R :
>> Function_plot100colors.R :
>> Function_plotRunningSd.R :
>> Function_saver.R :
>> Function_sourcedir.R :
>> Function_stacker.R :
>> Function_subzoo.R :
>> Function_svr.R :
>> Function_tictoc.R :
>> Function_writexls.R :
>> Function_wtt_3.0.R :
>> heatplot.R :
>> loadfuns.R :
>> Opening: nextArgrj_0.5.2-1.tar.gz
>> Warning in file(file, "r", encoding = encoding) :
>>   cannot open file 'nextArgrj_0.5.2-1.tar.gz': No such file or directory
>> Error in file(file, "r", encoding = encoding) :
>>   cannot open the connection
>> Calls: source ->  file
>> Execution halted
>>
>> c:\Users\gene.leynes\Downloads>
>>
>>[[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] Compiling Rgraphiz on Windows 7 64bit with R-2.13.0

2011-05-03 Thread Ben Rhelp
Hi all,

I am trying to compile Rgraphiz on Windows 7 64bit with R-2.13.0. I have 
installed 

Rtools213.exe from [1]. The 64bit packages in [2] provided me with the 64 bit 
version
of graphviz. After intalling the binary version Rgraphviz 1.30 (in 32bit) it 
complains (as 

expected) that:
> library(Rgraphviz)
Error: package 'Rgraphviz' is not installed for 'arch=x64'

I don't understand why the 64 bit version of graphiz is provided but not one 
for 
Rgraphviz.
Have I missed it somewhere? In any case, it is suggested to build it from 
source, so I tried
following the steps of the README from the source package of Rgraphviz (see 
below). I have the
same error than in [3]. Does anyone know what is going on or if Kasper found a 
solution back 

in 2009?

thanks in advance,

Cheers,

Ben


C:\BenSave>R --arch x64 CMD build --binary .\Rgraphviz
--binary is deprecated
* checking for file '.\Rgraphviz/DESCRIPTION' ... OK
* preparing 'Rgraphviz':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to re-build vignettes
  ---
* installing *source* package 'Rgraphviz' ...
Using the following environment variables
GRAPHVIZ_INSTALL_DIR=C:\/BenSave\/GoodiesWin64\/graphviz
GRAPHVIZ_INSTALL_MAJOR=2
GRAPHVIZ_INSTALL_MINOR=20
GRAPHVIZ_INSTALL_SUBMINOR=3
Using the following compilation and linking flags for Rgraphviz
   PKG_CPPFLAGS=-IC:\/BenSave\/GoodiesWin64\/graphviz/include/graphviz
   PKG_LIBS=-LC:\/BenSave\/GoodiesWin64\/graphviz/bin -lgvc-4 -lgraph-4 -lcdt-4
   GVIZ_DEFS=-DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
Created file src/Makevars.win
Created file R/graphviz_build_version.R
** libs
cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.0/etc/x64/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-213~1.0/etc/x64/Makeco
nf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c LL_funcs.c -o LL_funcs.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c Rgraphviz.c -o Rgraphviz.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c RgraphvizInit.c -o RgraphvizInit.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c agopen.c -o agopen.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c agread.c -o agread.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c agwrite.c -o agwrite.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c bezier.c -o bezier.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c buildEdgeList.c -o buildEdgeList.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c buildNodeList.c -o buildNodeList.o
x86_64-w64-mingw32-gcc -I"C:/PROGRA~1/R/R-213~1.0/include" -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c doLayout.c -o doLayout.o
doLayout.c: In function 'getEdgeLocs':
doLayout.c:131:17: error: 'textlabel_t' has no member named 'p'
doLayout.c:132:17: error: 'textlabel_t' has no member named 'p'
doLayout.c: In function 'getNodeLayouts':
doLayout.c:243:13: error: 'textlabel_t' has no member named 'p'
doLayout.c:244:13: error: 'textlabel_t' has no member named 'p'
make: *** [doLayout.o] Error 1
ERROR: compilation failed for package 'Rgraphviz'
* removing 'C:/Users/BVINSO~1/AppData/Local/Temp/Rtmpz6M19V/Rinst76da24d2/Rgraph
viz'
  ---
ERROR: package installation failed




[1] http://www.murdoch-sutherland.com/Rtools/
[2] http://www.stats.ox.ac.uk/pub/Rtools/goodies/Win64No_/
[3] https://stat.ethz.ch/pipermail/bioconductor/2009-March/026585.html


_

Re: [R] Overlapping x axes using Lattice

2011-05-03 Thread Breheny, Patrick
I'm not clear on what you're looking for here.  Your x-axis is numeric, why are 
you converting it to a factor?  If you keep it numeric, the labels don't 
overlap.  Or perhaps you don't want it to be numeric, in which case why not 
just change the aspect ratio of the plot until they no longer overlap?  Or 
change the axis font size?  Or put fewer labels on the axis?  There is a finite 
amount of space on the axis, so you have to either make more space, shrink the 
labels, or draw fewer of them.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Andrew McFadden
Sent: Tuesday, May 03, 2011 5:05 PM
To: r-help@r-project.org
Subject: [R] Overlapping x axes using Lattice

Hi R users

I apologise in advance for this question as I suspect it is simple and
perhaps others have had this problem. 
I am struggling to sort out how to fix the x axes so that the labels
don't overlap.

I have put the following example together to show my problem.

library(lattice)

titre <- as.factor(rep(c(10999,20999,30999,40999,50999,60999, 
2,4,45000,5,7,8),c(2,2,2,2,1,1,2,2,2,2,1,1)))
test<-rep(c("BVD","HSD"),c(10,10))
age<-as.factor(rep(c(1,2,3,4),c(5,5,5,5)))

pesti<-data.frame(titre,test,age)

histogram(~pesti[,1]|pesti[,2]+ pesti[,3]
,alternating=TRUE,tick.number=1,
stack=TRUE,type = "count", xlab="VNT",rot=c(180,180),draw=FALSE)

Thank you in advance.

Andy

Andrew McFadden MVS BVSc
Incursion Investigator
Investigation & Diagnostic Centres - Wallaceville Biosecurity New 
Zealand Ministry of Agriculture and Forestry

Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: 
Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St 
Upper Hutt





This email message and any attachment(s) is intended solely for the addressee(s)
named above. The information it contains is confidential and may be legally
privileged.  Unauthorised use of the message, or the information it contains,
may be unlawful. If you have received this message by mistake please call the
sender immediately on 64 4 8940100 or notify us by return email and erase the
original message and attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for changes
made to this email or to any attachments after transmission from the office.

[[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] ANOVA 1 too few degrees of freedom

2011-05-03 Thread Rovinpiper
Hi Richard,

Thanks for your advice.

I think that your suggestion is that I run the ANOVA with Combined.Plot as a
factor. I have tried that does not alleviate the problem.

Did I understand you properly?

Do you have another idea?

Thanks,

David

--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-1-too-few-degrees-of-freedom-tp3493349p3493632.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] Overlapping x axes using Lattice

2011-05-03 Thread Andrew McFadden
Hi R users

I apologise in advance for this question as I suspect it is simple and
perhaps others have had this problem. 
I am struggling to sort out how to fix the x axes so that the labels
don't overlap.

I have put the following example together to show my problem.

library(lattice)

titre <- as.factor(rep(c(10999,20999,30999,40999,50999,60999, 
2,4,45000,5,7,8),c(2,2,2,2,1,1,2,2,2,2,1,1)))
test<-rep(c("BVD","HSD"),c(10,10))
age<-as.factor(rep(c(1,2,3,4),c(5,5,5,5)))

pesti<-data.frame(titre,test,age)

histogram(~pesti[,1]|pesti[,2]+ pesti[,3]
,alternating=TRUE,tick.number=1,
stack=TRUE,type = "count", xlab="VNT",rot=c(180,180),draw=FALSE)

Thank you in advance.

Andy

Andrew McFadden MVS BVSc
Incursion Investigator
Investigation & Diagnostic Centres - Wallaceville Biosecurity New 
Zealand Ministry of Agriculture and Forestry

Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: 
Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St 
Upper Hutt





This email message and any attachment(s) is intended solely for the addressee(s)
named above. The information it contains is confidential and may be legally
privileged.  Unauthorised use of the message, or the information it contains,
may be unlawful. If you have received this message by mistake please call the
sender immediately on 64 4 8940100 or notify us by return email and erase the
original message and attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for changes
made to this email or to any attachments after transmission from the office.

[[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] Change the names of a dataframe

2011-05-03 Thread Duncan Murdoch

On 03/05/2011 4:43 PM, Jun Shen wrote:

Dear list,

This may sound silly. What is the right way to change the names of a
dataframe? Let's say I have this data frame (dose) with four columns with
names "ID", "DOSE", "TIME" "CMT". I want to change "DOSE" to "AMT". So I did

names(dose[2])<-'AMT'

But nothing happened. The name of the second column is still "DOSE".

Only this works

names(dose)[2]<-'AMT'

I wonder what is wrong with the first method. Thanks.



The first method says:

1.  Get dose[2].  This is a dataframe consisting of the second column of 
dose.  Store it in a temporary, unnamed variable.


2.  Changes its names to 'AMT'. This changes the names of the temporary 
variable, which then disappears.


The second method says:

1. Set the second element of the names associated with dose to 'AMT'.

That's what you want to do.

Duncan Murdoch

__
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] adaptIntegrate - how to pass additional parameters to the integrand

2011-05-03 Thread baptiste auguie
Hi,

The package maintainer is aware of this feature request. In the
meantime, I've used Currying,


require(cubature)

f <- function(x, a) cos(2*pi*x*a)  # a simple test function

adaptIntegrate(roxygen::Curry(f, a=0.2), lower=0, upper=2)

HTH,

baptiste


On 4 May 2011 05:57, Ravi Varadhan  wrote:
> Ok, I get it.
>
> require(cubature)
>
> f <- function(x, a) cos(2*pi*x*a)  # a simple test function
>
> # this works
> a <- 0.2
> adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2)
>
> # but this doesn't work
> rm(a)
> adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2, a=0.2)
>
> Ravi.
>
> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
> Of Uwe Ligges [lig...@statistik.tu-dortmund.de]
> Sent: Tuesday, May 03, 2011 7:17 AM
> To: HC
> Cc: r-help@r-project.org
> Subject: Re: [R] adaptIntegrate - how to pass additional parameters to the 
> integrand
>
> On 03.05.2011 06:43, HC wrote:
>> Hello,
>>
>> I am trying to use adaptIntegrate function but I need to pass on a few
>> additional parameters to the integrand. However, this function seems not to
>> have the flexibility of passing on such additional parameters.
>>
>> Am I missing something or this is a known limitation. Is there a good
>> alternative to such restrictions, if there at all are?
>
>
> Looks like you are talking about the cubature package rather than about
> base R. Frr the latter question: Please ask the package maintainer
> rather than the list. Ideally send him code to implement the requested
> feature and the maintainer will probably add your code. Not all package
> maintainers read R-help.
>
> For an ad hoc solution:
>
> Just use
>
> adaptIntegrate(function(x, argA=a, argB=b) f(x, argA=argA, argB=argB),
> ..)
>
> in order to set additional arguments for the function call.
>
> Uwe Ligges
>
>
>
>
>
>
>
>
>
>
>> Many thanks for your time.
>> HC
>>
>>
>> --
>> View this message in context: 
>> http://r.789695.n4.nabble.com/adaptIntegrate-how-to-pass-additional-parameters-to-the-integrand-tp3491701p3491701.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.
> __
> 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] help with the maxBHHH routine

2011-05-03 Thread Rohit Pandey
Hello R community,

I have been using R's inbuilt maximum likelihood functions, for the
different methods (NR, BFGS, etc).

I have figured out how to use all of them except the maxBHHH function. This
one is different from the others as it requires an observation level
gradient.

I am using the following syntax:

maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)

where logLik is the likelihood function and returns a vector of observation
level likelihoods and nuGradient is a function that returns a matrix with
each row corresponding to a single observation and the columns corresponding
to the gradient values for each parameter (as is mentioned in the online
help).

however, this gives me the following error:

*Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
:
  the matrix returned by the gradient function (argument 'grad') must have
at least as many rows as the number of parameters (10), where each row must
correspond to the gradients of the log-likelihood function of an individual
(independent) observation:
 currently, there are (is) 10 parameter(s) but the gradient matrix has only
2 row(s)
*
It seems it is expecting as many rows as there are parameters. So, I changed
my likelihood function so that it would return the transpose of the earlier
matrix (hence returning a matrix with rows equaling parameters and columns,
observations).

However, when I run the function again, I still get an error:
*Error in gr[, fixed] <- NA : (subscript) logical subscript too long*

I have verified that my gradient function, when summed across observations
gives the same results as the in built numerical gradient (to the 11th
decimal place - after that, they differ since R's function is numerical).

I am trying to run a very large estimation (1000's of observations and 821
parameters) and all of the other methods are taking way too much time
(days). This method is our last hope and so, any help will be greatly
appreciated.

-- 
Thanks in advance,
Rohit
Mob: 91 9819926213

[[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] Change the names of a dataframe

2011-05-03 Thread Greg Snow
In the first case you create a new data frame consisting of the 2nd column of 
the original, then change the name of the only column in that new data frame, 
then since nothing is done with that data frame it gets thrown away.  So it is 
not that nothing happened, but just that nothing useful happened.  The original 
data frame was never changed, just a copy of it.

The second method access the names, then changes the 2nd name and therefore 
changes the actual data frame of interest.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Jun Shen
> Sent: Tuesday, May 03, 2011 2:43 PM
> To: R-help
> Subject: [R] Change the names of a dataframe
> 
> Dear list,
> 
> This may sound silly. What is the right way to change the names of a
> dataframe? Let's say I have this data frame (dose) with four columns
> with
> names "ID", "DOSE", "TIME" "CMT". I want to change "DOSE" to "AMT". So
> I did
> 
> names(dose[2])<-'AMT'
> 
> But nothing happened. The name of the second column is still "DOSE".
> 
> Only this works
> 
> names(dose)[2]<-'AMT'
> 
> I wonder what is wrong with the first method. Thanks.
> 
> Jun
> 
>   [[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] turning data with start and end date into daily data

2011-05-03 Thread Dimitri Liakhovitski
Hello!

I have data that contain, among other things the date for the
beginning and for the end of a (daily) time series (see example below
- "mydata")

mystring1<-c("String 1", "String 2")
mystring2<-c("String a", "String b")
starts<-c(as.Date("2011-02-01"),as.Date("2011-03-02"))
ends<-c(as.Date("2011-03-15"),as.Date("2011-03-31"))
values<-c(2000,1)
mydata<-data.frame(starts=starts,ends=ends,values=values,mystring1=mystring1,mystring2=mystring2)
(mydata)

I have to reshape it so that: for each row of "mydata" I have daily
time series that start on the start date and end on the end date; what
used to be in the column "values" has to be distributed equally across
those dates; all other columns keep their original values.
My code below does it (see the end result "newdata"). However, to
achieve my goal, I am looping through rows of "mydata" - I am not sure
it will work with my real data set that already has thousands of rows
and also a lot of other columns with strings. I am afraid I'll run out
of memory. Is there maybe a way of doing it more efficiently?
Thanks a lot for your pointers!

newdata<-data.frame(mydate=NA,myvalues=NA,mystring1=NA,mystring2=NA)
for(i in 1:nrow(mydata)){  # i<-2
start.date = mydata[i,"starts"]
end.date =  mydata[i,"ends"]
all.dates = seq(start.date, length = end.date - start.date, by = "day")
temp.df <- data.frame(mydate = all.dates)
temp.df$myvalues = mydata[i,"values"]/length(all.dates)
temp.df[names(mydata)[4:5]] = mydata[i,4:5]
newdata<-rbind(newdata,temp.df)
}
newdata<-newdata[-1,]
(newdata);(mydata)

-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.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] Change the names of a dataframe

2011-05-03 Thread Jun Shen
Dear list,

This may sound silly. What is the right way to change the names of a
dataframe? Let's say I have this data frame (dose) with four columns with
names "ID", "DOSE", "TIME" "CMT". I want to change "DOSE" to "AMT". So I did

names(dose[2])<-'AMT'

But nothing happened. The name of the second column is still "DOSE".

Only this works

names(dose)[2]<-'AMT'

I wonder what is wrong with the first method. Thanks.

Jun

[[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] How to fit a random data into Beta distribution?

2011-05-03 Thread Steven Kennedy
library(MASS)
fitdistr(x,"beta",list(shape1=1,shape2=1))



On Tue, May 3, 2011 at 9:44 PM, Shekhar  wrote:
>
> Hi,
> I have some random data and i want to find out the parameters of Beta
> distribution ( a and b) such that this data approximately fits into
> this distribution. I have tried by plot the histograms and graph, but
> it requires lot of tuning and i am unable to do that. can anyone tell
> me how to do it programmitically in R?
>
> Regards,
> Som Shekhar
>
> __
> 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] bootstrap vignette construction and package installation

2011-05-03 Thread Murat Tasan
hi all - i'm trying to 'R CMD build' a package, but i have what
appears to be a bootstrapping problem:
i've included a vignette in my package, with R code interwoven (and
built using Sweave), but in this documentation i have a code line:
> library(MyPackage)

now, when trying to build a .tar.gz install-able version of my package
in a clean state, i remove the original compiled/installed package,
and the build fails because Sweave wants to execute the interwoven R
code even though the package hasn't yet been installed.

i got around it by temporarily just hiding the the inst/doc/
directory, installing the now-able-to-build package, then re-building
the package after the installation.
but this is a pretty clunky solution, and i imagine there's a more
elegant way to get around this bootstrapping problem that i'm just not
aware of.

any thoughts?

thanks much for any help,

-murat

__
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] ANOVA 1 too few degrees of freedom

2011-05-03 Thread Richard M. Heiberger
Most likely your combined.trt is linearly dependent on the combined.plot
factor.  Try

Anova.Trt.D.M.T.Pr.Model <- aov(Combined.Rs ~  as.factor(Combined.Plot)
.
and see if combined.plot now has the 11 df you are anticipating.

Rich

On Tue, May 3, 2011 at 3:37 PM, Rovinpiper  wrote:

> I'm running an ANOVA on some data for respiration in a forest. I am having
> a
> problem with my degrees of freedom. For one of my variables I get one fewer
> degrees of freedom than I should.
>
> I have 12 plots and I therefore expected 11 degrees of freedom, but instead
> I got 10.
>
> Any ideas?
>
> I have some code and output below:
>
>
> > class(Combined.Plot)
> [1] "character"
>
> > levels(as.factor(Combined.Plot))
>  [1] "60m"  "A1"   "B1"   "B3"   "B4"   "C5"   "C9"   "D2"   "D9"   "F60m"
> "F8"   "Q7"
>
> > nlevels(as.factor(Combined.Plot))
> [1] 12
>
> > Anova.Trt.D.M.T.Pr.Model <- aov(Combined.Rs~Combined.Trt +
> > as.factor(Combined.Plot) + as.factor(Combined.Day) +
> > Combined.Trt*as.factor(Combined.Day) +
> > Combined.Plot*as.factor(Combined.Day))
>
> Warning message:
> In model.matrix.default(mt, mf, contrasts) :
>  variable 'Combined.Plot' converted to a factor
>
> > summary(Anova.Trt.D.M.T.Pr.Model)
>   Df  Sum Sq
> Mean SqF value   Pr(>F)
>
> Combined.Trt   1   52.80
> 52.805 2.0186e+30  < 2.2e-16 ***
> as.factor(Combined.Plot) 10  677.6967.769
> 2.5907e+30  < 2.2e-16 ***
> as.factor(Combined.Day) 16  2817.47  176.092
> 6.7317e+30  < 2.2e-16 ***
> Combined.Trt:as.factor(Combined.Day)   16   47.82  2.989
> 1.1426e+29  < 2.2e-16 ***
> as.factor(Combined.Day):Combined.Plot 160  611.21   3.820 1.4604e+29 <
> 2.2e-16 ***
>
> Residuals 2040.00
> 0.000
>
> ---
>
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/ANOVA-1-too-few-degrees-of-freedom-tp3493349p3493349.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.


[R] NEW SUMMER ONLINE R COURSE: Fundamentals of Using R

2011-05-03 Thread Geoffrey Hubona
NEW SECTION BEGINS JUNE 1 (11AM-2PM ET) AND MAY 27 (6PM-9PM ET)



The non-profit organization Information Institute (
http://www.information-institute.org) is offering a live, interactive,
synchronous online course entitled Fundamentals of Using R. The registration
cost for the 14-hour, 5 week course is $225 USD (student); $295 (faculty);
and $325 (practitioner). All live, interactive class sessions are recorded
and provided to participants for their repeated post-class review. The
course is popular so we opened an additional section beginning June 1.



This course is designed for people who are curious about R, new to R, and
who would like to obtain a basic knowledge of R capabilities that apply to
any ultimate intended use of R. This course instructs about the R
environment: using workspaces; importing and exporting data; R data types,
data structures, and objects; writing simple and complex scripts; essential
R functions and packages; writing your own R functions and packages;
programming with R; publication-style 2-D and 3-D graphics capabilities
using special R packages, and many other essential topics. The course is
designed to serve as a useful knowledge foundation regardless of one’s
ultimate use of R (for example, statistical and data analyses, programming,
writing scripts or creating packages, using graphics, etc.). There is more
information at the URLs below.



The informational (and registration) site for the June 1 AM version (AM by
US Eastern Time) is here: https://www.regonline.com/R-fund-june-AM This
course runs on five consecutive Wednesdays from June 1 to June 29, from 11AM
until 2PM ET (GMT-4).



The informational (and registration) site for the PM version (PM by US
Eastern Time) is here: https://www.regonline.com/R-fund-may-PM  This course
runs on five consecutive Fridays (May 27-June 24), in the evenings from 6PM
until 9PM ET (GMT-4).



Please email ghub...@vcu.edu with any questions or for more information.



Geoff Hubona

Information Systems Department

Virginia Commonwealth 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] ANOVA 1 too few degrees of freedom

2011-05-03 Thread Rovinpiper
I'm running an ANOVA on some data for respiration in a forest. I am having a
problem with my degrees of freedom. For one of my variables I get one fewer
degrees of freedom than I should.

I have 12 plots and I therefore expected 11 degrees of freedom, but instead
I got 10.

Any ideas? 

I have some code and output below:


> class(Combined.Plot)
[1] "character"

> levels(as.factor(Combined.Plot))
 [1] "60m"  "A1"   "B1"   "B3"   "B4"   "C5"   "C9"   "D2"   "D9"   "F60m"
"F8"   "Q7"  

> nlevels(as.factor(Combined.Plot))
[1] 12

> Anova.Trt.D.M.T.Pr.Model <- aov(Combined.Rs~Combined.Trt +
> as.factor(Combined.Plot) + as.factor(Combined.Day) +
> Combined.Trt*as.factor(Combined.Day) +
> Combined.Plot*as.factor(Combined.Day))

Warning message:
In model.matrix.default(mt, mf, contrasts) :
  variable 'Combined.Plot' converted to a factor

> summary(Anova.Trt.D.M.T.Pr.Model)
   Df  Sum Sq   
Mean SqF value   Pr(>F) 
   
Combined.Trt   1   52.80  
52.805 2.0186e+30  < 2.2e-16 ***
as.factor(Combined.Plot) 10  677.6967.769
2.5907e+30  < 2.2e-16 ***
as.factor(Combined.Day) 16  2817.47  176.092  
6.7317e+30  < 2.2e-16 ***
Combined.Trt:as.factor(Combined.Day)   16   47.82  2.989  
1.1426e+29  < 2.2e-16 ***
as.factor(Combined.Day):Combined.Plot 160  611.21   3.820 1.4604e+29 <
2.2e-16 ***

Residuals 2040.00  
0.000 

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-1-too-few-degrees-of-freedom-tp3493349p3493349.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] Unexp. behavior from boot with multiple statistics

2011-05-03 Thread algorimancer
I am attempting to use package boot to summarize and compare the performance
of three models.  I'm using R 2.13.0 in a Win32 environment.

My statistic function returns a vector of 6 values, 3 of which are error
rates for different models, and 3 are pairwise differences between those
error rates.  It looks like:

multiEst<-function(dat,i)
{
   
c(E1,E2,E3,E2-E1,E3-E1,E3-E2);
}

then I call boot (using R=4 for simplicity of description) with:

multiBoot=boot(data,multiEst,R=4)

which gives reasonable results:

Bootstrap Statistics :
original  biasstd. error
t1* 0.07  0.3775  0.04193249
t2* 0.08  0.3750  0.04654747
t3* 0.04  0.4200  0.05354126
t4* 0.01 -0.0025  0.0050
t5*-0.03  0.0425  0.0150
t6*-0.04  0.0450  0.01290994

and the resulting "t0" contains the expected estimates of the statistics,
> multiBoot$t0
[1]  0.07  0.08  0.04  0.01 -0.03 -0.04

however "t", which is supposed to contain bootstrap replicates of the
statistic, doesn't.  It looks like this:
> multiBoot$t
 [,1] [,2] [,3] [,4] [,5]  [,6]
[1,] 0.46 0.47 0.46 0.01 0.00 -0.01
[2,] 0.39 0.39 0.39 0.00 0.00  0.00
[3,] 0.45 0.46 0.47 0.01 0.02  0.01
[4,] 0.49 0.50 0.52 0.01 0.03  0.02

It is not clear where these columns come from --- they clearly do not
resemble the estimates in "t0".

If I define a separate statistic function for each desired estimate, the
resulting "t" and "t0" are as expected, however it is important in this case
that the separate estimates derive from the same bootstrap replicates.

Any helpful suggestions? Or have I come upon a bug in the implementation?

Note: the documentation provides the following definitions for these
returned variables:

t0  The observed value of statistic applied to data.
t   A matrix with R rows each of which is a bootstrap replicate of 
statistic. 









--
View this message in context: 
http://r.789695.n4.nabble.com/Unexp-behavior-from-boot-with-multiple-statistics-tp3493300p3493300.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] Simple General Statistics and R question (with 3 line example) - get z value from pairwise.wilcox.test

2011-05-03 Thread peter dalgaard

On Apr 28, 2011, at 15:18 , JP wrote:

> 
> 
> I have found that when doing a wilcoxon signed ranked test you should report:
> 
> - The median value (and not the mean or sd, presumably because of the
> underlying potential non normal distribution)
> - The Z score (or value)
> - r
> - p value
> 

...printed on 40g/m^2 acid free paper with a pencil of 3B softness?

Seriously, with nonparametrics, the p value is the only thing of real interest, 
the other stuff is just attempting to check on authors doing their calculations 
properly. The median difference is of some interest, but it is not actually 
what is being tested, and in heavily tied data, it could even be zero with a 
highly significant p-value. The Z score can in principle be extracted from the 
p value (qnorm(p/2), basically) but it's obviously unstable in the extreme 
cases. What is r? The correlation? Pearson, not Spearman?

> My questions are:
> 
> - Are the above enough/correct values to report (some places even
> quote W and df) ?

df is silly, and/or blatantly wrong... 

>  What else would you suggest?
> - How do I calculate the Z score and r for the above example?
> - How do I get each statistic from the pairwise.wilcox.test call?
> 
> Many Thanks
> JP
> 
> __
> 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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] ID parameter in model

2011-05-03 Thread Göran Broström
On Mon, May 2, 2011 at 5:38 PM, Mike Harwood  wrote:
> Hello,
>
> I am apparently confused about the use of an id parameter for an event
> history/survival model, and why the EHA documentation for aftreg does
> not specify one.  All assistance and insights are appreciated.

Which version of eha are you using? The latest version documents the
use of 'id'.

> Attempting to specifiy an id variable with the documentation example
> generates an "overlapping intervals" error,

Thanks for pointing this out. It is an error (actually three) in the
data frame.
The reason is that it is "real" data; and not sufficiently checked by me.

I'll fix this in an update soon.

Thanks again,

Göran

 so I sorted the original
> mort dataframe and set subsequent entry times an id to the previous
> exit time + 0.0001.  This allowed me to see the affect of the id
> parameter on the coefficients and significance tests, and prompted my
> question.  The code I used is shown below, with the results at the
> bottom.  Thanks in advance!
>
> Mike
>
> head(mort) ## data clearly contains multiple entries for some of the
> dataframe ids
>
> no.id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort)  ##
> Inital model
> id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort, id=id)
> ## overlapping intervals error
>
> mort.sort <- ## ensure records ordered
>    mort[
>        order(mort$id, mort$enter),]
>
> ## remove overlap
> for (i in 2:nrow(mort.sort)){
>     if (mort.sort[i,'id'] == mort.sort[i-1,'id'])
>         mort.sort[i,'enter'] <- mort.sort[i-1, 'exit'] + 0.0001
>        }
>
> no.id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, data =
> mort.sort) ## initial model on modified df
> id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, id=id, data =
> mort.sort) ## with id parameter
>
>
> #=== output ===#
>> no.id.aft.sort
> Call:
> aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort)
>
> Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
> ses
>           lower    0.416     0         1           (reference)
>           upper    0.584    -0.347     0.707     0.089     0.000
>
> log(scale)                    3.603    36.704     0.065     0.000
> log(shape)                    0.331     1.393     0.058     0.000
>
> Events                    276
> Total time at risk         17045
> Max. log. likelihood      -1391.4
> LR test statistic         16.1
> Degrees of freedom        1
> Overall p-value           6.04394e-05
>> id.aft.sort
> Call:
> aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort,
>    id = id)
>
> Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
> ses
>           lower    0.416     0         1           (reference)
>           upper    0.584    -0.364     0.695     0.090     0.000
>
> log(scale)                    3.588    36.171     0.065     0.000
> log(shape)                    0.338     1.402     0.058     0.000
>
> Events                    276
> Total time at risk         17045
> Max. log. likelihood      -1390.8
> LR test statistic         17.2
> Degrees of freedom        1
> Overall p-value           3.3091e-05
>>
>
> __
> 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.
>



-- 
Göran Broström

__
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] Simple loop

2011-05-03 Thread Dennis Murphy
Hi:

Here are two more candidates, using packages plyr and data.table. Your
toy data frame is called dd below.

library(plyr)
ddply(dd, .(Site, Prof), transform, Hadj = H - min(H))
  Site Prof  H Hadj
111 248
211 160
311 67   51
412 230
512 56   33
612 45   22
721 67   21
821 460

library(data.table)
dt <- data.table(dd, key = 'Site, Prof')
dt[, list(H = H, Hadj = H - min(H)), by = 'Site, Prof']



HTH,
Dennis

On Tue, May 3, 2011 at 8:44 AM, Woida71  wrote:
> Hello everybody,
> I am beginning with loops and functions and would be glad to have help in
> the following question:
> If i have a dataframe like this
> Site  Prof  H
> 1      1     24
> 1      1     16
> 1      1     67
> 1      2     23
> 1      2     56
> 1      2     45
> 2      1     67
> 2      1     46
> And I would like to create a new column that subtracts the minimum of H from
> H, but for S1 and P1
> only the minimum of the data points falling into this category should be
> taken.
> So for example the three first numbers of the new column write: 24-16,
> 16-16, 67-16
> the following numbers refering to Site1 and Prof2 write: 23-23, 56-23,
> 45-23.
> I think with two loops one refering to the Site, the other to the Prof, it
> should be possible to automatically
> create the new column.
> Thanks a lot for any help.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.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.


[R] na.omit - Is it working properly?

2011-05-03 Thread Kalicin, Sarah

I have a work around for this, but can someone explain why the first example 
does not work properly? I believed it worked in the previous version of R, by 
selecting just the rows=200525 and omitting the na's. I just upgraded to 2.13. 
I am also concern with the row numbers being different in the selections, 
should I be worried? FYI, I just selected the first few rows for demonstration, 
please do not worry that the number of rows shown are not equal. - Sarah

With na.omit around the column, but it is showing other values in the F.WW 
column other than 200525, along with NA.  I was hoping that this would omit all 
the NA's, and show all the rows that P$F.WW=200525. I believe it did with the 
previous version of R.
P[na.omit(P$F.WW)==200525, c(51, 52)]
  F.WWR.WW
45  200525  NA
53  NA  NA
61  200534  200534
63  200608  200608
66  200522  200541
80  NA  NA
150 200521  200516
231 200530  200530

No na.omit, the F.WW=200525 seems to work, but lots of NA included. This is 
what is expected!! The row numbers are not the same as the above example, 
except the first row.
> P[P$F.WW==200525, c(51, 52)]
F.WW R.WW
45200525  NA
NANA  NA
NA.1  NA  NA
NA.2  NA  NA
NA.3  NA  NA
57200525  200526
65200525  NA
67200525  NA
70200525  200525
NA.4  NA  NA
NA.5  NA  NA
86200525  NA

Na.omit excludes the na's. This is what I want. The concern I have is why the 
row numbers do not match any of those shown in the examples above.
> na.omit(P[P$F.WW==200525, c(51, 52)])
F.WWR.WW
57200525  200526
70200525  200525
161   200525  200525
245   200525  200525
246   200525  200525
247   200525  200526
256   200525  200525
266   200525  200525
269   200525  200525
271   200525  200526
276   200525  200526
278   200525  200526

[[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] Simple loop

2011-05-03 Thread andrija djurovic
William, you are right. Thanks for clarification.

Andrija

On Tue, May 3, 2011 at 9:04 PM, William Dunlap  wrote:

>
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
> > -Original Message-
> > From: r-help-boun...@r-project.org
> > [mailto:r-help-boun...@r-project.org] On Behalf Of andrija djurovic
> > Sent: Tuesday, May 03, 2011 11:28 AM
> > To: Woida71
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Simple loop
> >
> > Hi.
> > There is no need to do this in a for loop.
> > Here is one approach:
> >
> > x <- read.table(textConnection("Site  Prof  H
> > 1  1 24
> > 1  1 16
> > 1  1 67
> > 1  2 23
> > 1  2 56
> > 1  2 45
> > 2  1 67
> > 2  1 46"), header = TRUE)
> > closeAllConnections()
> > x
> > cbind(x,newCol=unlist(tapply(x[,3],paste(x[,1],x[,2],sep=""),
> > function(x) x-min(x)))
> >Site Prof  H newCol
> > 11111 24  8
> > 11211 16  0
> > 11311 67 51
> > 12112 23  0
> > 12212 56 33
> > 12312 45 22
> > 21121 67 21
> > 21221 46  0
>
> That works when Site and Prof are ordered as shown, but if
> they are not sorted cbind(...,tapply) won't line up the the
> new entries with the old rows properly.  Try doing it on
> x[8:1,] to see this.
>
> ave() can deal that problem:
>  > cbind(x, newCol2 = with(x, ave(H, Site, Prof,
> FUN=function(y)y-min(y
>Site Prof  H newCol2
>  111 24   8
>  211 16   0
>  311 67  51
>  412 23   0
>  512 56  33
>  612 45  22
>  721 67  21
>  821 46   0
>  Warning message:
>  In min(y) : no non-missing arguments to min; returning Inf
> The warning is unfortunate: ave() calls FUN even for when
> there is no data for a particular group (Site=2, Prof=2 in this
> case).
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> >
> > Andrija
> >
> >
> > On Tue, May 3, 2011 at 5:44 PM, Woida71  wrote:
> >
> > > Hello everybody,
> > > I am beginning with loops and functions and would be glad
> > to have help in
> > > the following question:
> > > If i have a dataframe like this
> > > Site  Prof  H
> > > 1  1 24
> > > 1  1 16
> > > 1  1 67
> > > 1  2 23
> > > 1  2 56
> > > 1  2 45
> > > 2  1 67
> > > 2  1 46
> > > And I would like to create a new column that subtracts the
> > minimum of H
> > > from
> > > H, but for S1 and P1
> > > only the minimum of the data points falling into this
> > category should be
> > > taken.
> > > So for example the three first numbers of the new column
> > write: 24-16,
> > > 16-16, 67-16
> > > the following numbers refering to Site1 and Prof2 write:
> > 23-23, 56-23,
> > > 45-23.
> > > I think with two loops one refering to the Site, the other
> > to the Prof, it
> > > should be possible to automatically
> > > create the new column.
> > > Thanks a lot for any help.
> > >
> > > --
> > > View this message in context:
> > > http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.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.
> >
>

[[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] Simple loop

2011-05-03 Thread William Dunlap


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of andrija djurovic
> Sent: Tuesday, May 03, 2011 11:28 AM
> To: Woida71
> Cc: r-help@r-project.org
> Subject: Re: [R] Simple loop
> 
> Hi.
> There is no need to do this in a for loop.
> Here is one approach:
> 
> x <- read.table(textConnection("Site  Prof  H
> 1  1 24
> 1  1 16
> 1  1 67
> 1  2 23
> 1  2 56
> 1  2 45
> 2  1 67
> 2  1 46"), header = TRUE)
> closeAllConnections()
> x
> cbind(x,newCol=unlist(tapply(x[,3],paste(x[,1],x[,2],sep=""),
> function(x) x-min(x)))
>Site Prof  H newCol
> 11111 24  8
> 11211 16  0
> 11311 67 51
> 12112 23  0
> 12212 56 33
> 12312 45 22
> 21121 67 21
> 21221 46  0

That works when Site and Prof are ordered as shown, but if 
they are not sorted cbind(...,tapply) won't line up the the
new entries with the old rows properly.  Try doing it on
x[8:1,] to see this.  

ave() can deal that problem:
  > cbind(x, newCol2 = with(x, ave(H, Site, Prof,
FUN=function(y)y-min(y
Site Prof  H newCol2
  111 24   8
  211 16   0
  311 67  51
  412 23   0
  512 56  33
  612 45  22
  721 67  21
  821 46   0
  Warning message:
  In min(y) : no non-missing arguments to min; returning Inf
The warning is unfortunate: ave() calls FUN even for when
there is no data for a particular group (Site=2, Prof=2 in this
case).

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 


> 
> Andrija
> 
> 
> On Tue, May 3, 2011 at 5:44 PM, Woida71  wrote:
> 
> > Hello everybody,
> > I am beginning with loops and functions and would be glad 
> to have help in
> > the following question:
> > If i have a dataframe like this
> > Site  Prof  H
> > 1  1 24
> > 1  1 16
> > 1  1 67
> > 1  2 23
> > 1  2 56
> > 1  2 45
> > 2  1 67
> > 2  1 46
> > And I would like to create a new column that subtracts the 
> minimum of H
> > from
> > H, but for S1 and P1
> > only the minimum of the data points falling into this 
> category should be
> > taken.
> > So for example the three first numbers of the new column 
> write: 24-16,
> > 16-16, 67-16
> > the following numbers refering to Site1 and Prof2 write: 
> 23-23, 56-23,
> > 45-23.
> > I think with two loops one refering to the Site, the other 
> to the Prof, it
> > should be possible to automatically
> > create the new column.
> > Thanks a lot for any help.
> >
> > --
> > View this message in context:
> > http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.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.
> 

__
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] How do I break a foreach loop?

2011-05-03 Thread Xing Qiu
Hi,

I've noticed that the usual "break", "next" commands do not work in a
foreach loop, is there a nice way to do that?

A little more detail: I am using foreach to conduct a very time
consuming (may take several days if done sequentially) simulation
study.  The number of simulations is set to 1000.  So the command I am
using looks like this simplified version:

grandsum <- foreach(icount(1000), .combine="+") %dopar% { sim(...) }

In fact, grandsum can never take a value greater than a threshold, say
10.0.  So I want the number of iterations depend on the value of
grandsum.  Say when the grandsum is greater equal to 10.0 the
computation should be terminated to save time.  This is the for loop
version of what is in my mind:

grandsum <- 0
for (i in 1:1000) {
  if (grandsum >= 10.0) break
  else grandsum <- grandsum + sim(...)
}

Is there a way to re-write the above for loop by an equivalent
foreach/dopar loop?

Thanks very much,
Xing

__
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] Loading a FORTRAN DLL

2011-05-03 Thread vioravis
I have a FORTRAN DLL file obtained from Compaq Visual Fortran and when I try
to load the DLL into the R environment I get an error. 

> dyn.load("my_function.dll")

"This application has failed to start because MSCVRTD.dll was not found.
Re-installing this application may fix the problem."

When I tried it again, the above error doesn't appear anymore. Instead, I
get the following error:

Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared library 'D://my_function.dll':
  LoadLibrary failure:  The specified module could not be found.

Do I need to have FORTRAN installed to be able to run the DLL file??? Can
someone please help me with what is causing this error???

Thank you.

Ravi





--
View this message in context: 
http://r.789695.n4.nabble.com/Loading-a-FORTRAN-DLL-tp3493263p3493263.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] data transformation ----Box-Cox Transformations

2011-05-03 Thread John Fox
Dear Stuart,

See ?bcPower and ?powerTransform in the car package, the latter for
univariate and multivariate conditional and unconditional ML Box-Cox.

I hope this helps,
 John


John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox




> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Stuart
> Sent: May-03-11 11:37 AM
> To: r-help@r-project.org
> Subject: [R] data transformation Box-Cox Transformations
> 
> Hi
> 
> Could any one please help how I can trnasform data based on Box-Cox
> Transformations. I have massive data set with many variables. If
> possible someone can write few lines so I can read in all data set once
> and transform it.
> 
> 
> g1g2  g2
> 97.03703704   89.25925926 4.4
> 24.90740741   69.25925926 35.5556
> 62.   85.18518519 36.85185185
> 18.51851852   84.25925926 21.6667
> 93.703703795.92592593 54.07407407
> 26.6667   23. 99.25925926
> 63.   97.03703704 27.40740741
> 95.74074074   3.6 59.25925926
> 46.6667   49. 39.1667
> 21.85185185   2.592592593 63.14814815
> 94.7222   17.7778 81.
> 
> 
> any help will be much appreciated
> 
> Cheers
> Sbroad
> 
> __
> 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] Simple loop

2011-05-03 Thread andrija djurovic
Hi.
There is no need to do this in a for loop.
Here is one approach:

x <- read.table(textConnection("Site  Prof  H
1  1 24
1  1 16
1  1 67
1  2 23
1  2 56
1  2 45
2  1 67
2  1 46"), header = TRUE)
closeAllConnections()
x
cbind(x,newCol=unlist(tapply(x[,3],paste(x[,1],x[,2],sep=""),
function(x) x-min(x)))
   Site Prof  H newCol
11111 24  8
11211 16  0
11311 67 51
12112 23  0
12212 56 33
12312 45 22
21121 67 21
21221 46  0

Andrija


On Tue, May 3, 2011 at 5:44 PM, Woida71  wrote:

> Hello everybody,
> I am beginning with loops and functions and would be glad to have help in
> the following question:
> If i have a dataframe like this
> Site  Prof  H
> 1  1 24
> 1  1 16
> 1  1 67
> 1  2 23
> 1  2 56
> 1  2 45
> 2  1 67
> 2  1 46
> And I would like to create a new column that subtracts the minimum of H
> from
> H, but for S1 and P1
> only the minimum of the data points falling into this category should be
> taken.
> So for example the three first numbers of the new column write: 24-16,
> 16-16, 67-16
> the following numbers refering to Site1 and Prof2 write: 23-23, 56-23,
> 45-23.
> I think with two loops one refering to the Site, the other to the Prof, it
> should be possible to automatically
> create the new column.
> Thanks a lot for any help.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.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] Simple loop

2011-05-03 Thread Jonathan Daily
It is actually possible and preferable to do this with no loops.
Assuming your data is in a dataframe called dat:

idx <- with(dat, Site == 1 & Prof == 1)
dat <- within(dat, { new = H - ifelse(Site == 1 & Prof == 1,
min(H[idx]), min(H[!idx])) })
dat

which also serves to illuminate the difference between with and within
as a bonus.

HTH,
Jon

On Tue, May 3, 2011 at 11:44 AM, Woida71  wrote:
> Hello everybody,
> I am beginning with loops and functions and would be glad to have help in
> the following question:
> If i have a dataframe like this
> Site  Prof  H
> 1      1     24
> 1      1     16
> 1      1     67
> 1      2     23
> 1      2     56
> 1      2     45
> 2      1     67
> 2      1     46
> And I would like to create a new column that subtracts the minimum of H from
> H, but for S1 and P1
> only the minimum of the data points falling into this category should be
> taken.
> So for example the three first numbers of the new column write: 24-16,
> 16-16, 67-16
> the following numbers refering to Site1 and Prof2 write: 23-23, 56-23,
> 45-23.
> I think with two loops one refering to the Site, the other to the Prof, it
> should be possible to automatically
> create the new column.
> Thanks a lot for any help.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.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.
>



-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

__
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] Controlling the extent of ablines on plot

2011-05-03 Thread Duncan Murdoch

On 03/05/2011 1:26 PM, Ryan Utz wrote:

Well... that could work. Problem is in the actual graphs I'm making, there
are to be>30 lines per graph (as many as 60 in some cases). Any way I could
use the lines command without having to write out 60 lines of code per
figure? That's why I like ablines; you just have to specify a single value
and it will put a horizontal line at that number.

Thanks,
Ryan



Write your own abline.  For example, with your previously posted example:

xlim <- c(0, 5)
ylim <- c(0, 10)

abline2 <- function(h, v) {
  if (!missing(h)) {
n <- length(h)
segments( rep(xlim[1], n), h, rep(xlim[2], n), h)
  }
  if (!missing(v)) {
n <- length(v)
segments( rep(ylim[1], n), v, rep(ylim[2], n), v)
  }
}

Just replace your abline() call with abline2().

Duncan Murdoch

__
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] adaptIntegrate - how to pass additional parameters to the integrand

2011-05-03 Thread Ravi Varadhan
Ok, I get it.

require(cubature)

f <- function(x, a) cos(2*pi*x*a)  # a simple test function

# this works
a <- 0.2
adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2)

# but this doesn't work
rm(a)
adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2, a=0.2)

Ravi.


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Uwe Ligges [lig...@statistik.tu-dortmund.de]
Sent: Tuesday, May 03, 2011 7:17 AM
To: HC
Cc: r-help@r-project.org
Subject: Re: [R] adaptIntegrate - how to pass additional parameters to the 
integrand

On 03.05.2011 06:43, HC wrote:
> Hello,
>
> I am trying to use adaptIntegrate function but I need to pass on a few
> additional parameters to the integrand. However, this function seems not to
> have the flexibility of passing on such additional parameters.
>
> Am I missing something or this is a known limitation. Is there a good
> alternative to such restrictions, if there at all are?


Looks like you are talking about the cubature package rather than about
base R. Frr the latter question: Please ask the package maintainer
rather than the list. Ideally send him code to implement the requested
feature and the maintainer will probably add your code. Not all package
maintainers read R-help.

For an ad hoc solution:

Just use

adaptIntegrate(function(x, argA=a, argB=b) f(x, argA=argA, argB=argB),
..)

in order to set additional arguments for the function call.

Uwe Ligges










> Many thanks for your time.
> HC
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/adaptIntegrate-how-to-pass-additional-parameters-to-the-integrand-tp3491701p3491701.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.
__
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] Constructing a histogram with words as labels as height as frequency?

2011-05-03 Thread Greg Snow
?barplot

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Caitlin
> Sent: Tuesday, May 03, 2011 11:36 AM
> To: r-help@r-project.org
> Subject: [R] Constructing a histogram with words as labels as height as
> frequency?
> 
> Hi all.
> 
> I need to construct a plot showing words on the x-axis and how many
> times
> each word was given as a verbal response on the y-axis as solid bar
> (frequency). Is there a convenient function to do this in R? I
> considered
> hist(), but I'm not sure how to construct the text file. Example:
> 
> apple, 2
> pear, 14
> house, 1
> beach, 5
> computer, 15
> 
> Thanks,
> 
> ~Caitlin
> 
>   [[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] Controlling the extent of ablines on plot

2011-05-03 Thread Joshua Wiley
On Tue, May 3, 2011 at 10:40 AM, Joshua Wiley  wrote:
> The issue is the plotting region is slightly padded.  The easiest
> option, I think, would be to clip() it.  I have a general sense that
> one of the par() options would let you adjust the padding to 0, but I
> could just be imagining that (anyone else??).

Not loving it, but this is sort of what I meant...

plot(0:5, seq(0, 10, 2), axes=FALSE, xaxs = "i", yaxs = "i")
axis(1, at=c(0,1,2,2.5,3,4,5), pos=0)
axis(2, at=seq(0, 10, 2), pos=0)
abline(h = 1:5)

__
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] Controlling the extent of ablines on plot

2011-05-03 Thread Joshua Wiley
Hi Ryan,

The issue is the plotting region is slightly padded.  The easiest
option, I think, would be to clip() it.  I have a general sense that
one of the par() options would let you adjust the padding to 0, but I
could just be imagining that (anyone else??).  Anyway, here are some
options:

###
plot(0:5, seq(0, 10, 2), axes=FALSE)
axis(1, at=c(0,1,2,2.5,3,4,5), pos=0)
axis(2, at=seq(0, 10, 2), pos=0)
## using clip and abline
clip(0, 5, 0, 10)
abline(h = 1:5)
dev.new()
plot(0:5, seq(0, 10, 2), axes=FALSE)
axis(1, at=c(0,1,2,2.5,3,4,5), pos=0)
axis(2, at=seq(0, 10, 2), pos=0)
## using lines, but without retyping as much
sapply(1:5, function(y) lines(c(0, 5), c(y, y)))
## or even easier, getting the same thing with segments
segments(0, 1:5, 5, 1:5)

HTH,

Josh

On Tue, May 3, 2011 at 10:26 AM, Ryan Utz  wrote:
> Well... that could work. Problem is in the actual graphs I'm making, there
> are to be >30 lines per graph (as many as 60 in some cases). Any way I could
> use the lines command without having to write out 60 lines of code per
> figure? That's why I like ablines; you just have to specify a single value
> and it will put a horizontal line at that number.
>
> Thanks,
> Ryan
>
>
>> Maybe you could use lines()?
>>
>> plot(1:2)
>> lines(c(1,2),c(1.5,1.5))
>>
>>
>>
>
>
> --
>
> Ryan Utz, Ph.D.
> Aquatic Ecologist/STREON Scientist
> National Ecological Observatory Network
>
> Home/Cell: (724) 272-7769
> Work: (720) 746-4844 ext. 2488
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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 transformation ----Box-Cox Transformations

2011-05-03 Thread Greg Snow
There is the bct function in the TeachingDemos package that does Box-Cox 
transforms (though you could also write your own fairly simply).  The 
lappy/sapply functions will apply a function to each column of a data frame.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Stuart
> Sent: Tuesday, May 03, 2011 9:37 AM
> To: r-help@r-project.org
> Subject: [R] data transformation Box-Cox Transformations
> 
> Hi
> 
> Could any one please help how I can trnasform data based on Box-Cox
> Transformations. I have massive data set with many variables. If
> possible someone can write few lines so I can read in all data set
> once and transform it.
> 
> 
> g1g2  g2
> 97.03703704   89.25925926 4.4
> 24.90740741   69.25925926 35.5556
> 62.   85.18518519 36.85185185
> 18.51851852   84.25925926 21.6667
> 93.703703795.92592593 54.07407407
> 26.6667   23. 99.25925926
> 63.   97.03703704 27.40740741
> 95.74074074   3.6 59.25925926
> 46.6667   49. 39.1667
> 21.85185185   2.592592593 63.14814815
> 94.7222   17.7778 81.
> 
> 
> any help will be much appreciated
> 
> Cheers
> Sbroad
> 
> __
> 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] Constructing a histogram with words as labels as height as frequency?

2011-05-03 Thread Caitlin
Hi all.

I need to construct a plot showing words on the x-axis and how many times
each word was given as a verbal response on the y-axis as solid bar
(frequency). Is there a convenient function to do this in R? I considered
hist(), but I'm not sure how to construct the text file. Example:

apple, 2
pear, 14
house, 1
beach, 5
computer, 15

Thanks,

~Caitlin

[[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] Help converting a data.frame to ordered factors

2011-05-03 Thread Rob Cassidy
Hi again,
Now that I have the data.frame as ordered factors, when I try to transpose
it, I lose the factor orders.

> datfact<-data.frame(c1,c2,c96)
> sapply(datfact, class)
 c1c2c96  
[1,] "ordered" "ordered" "ordered"
[2,] "factor"  "factor"  "factor" 
>
> dafacT<-as.data.frame(t(datfact))
> sapply(datfacT,class)
   item1item2item3item4   ...
"factor" "factor" "factor" "factor" ...
> 
> 
Is there a simple way to re-impose ordering on the transposed df? or
alternatively to transpose the df without losing the ordering?

Many thanks,
Robert

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-converting-a-data-frame-to-ordered-factors-tp3490838p3492979.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] RODBC: forcing a special column to be read in as character

2011-05-03 Thread Jack T.
I've had the same problem and ended up using the xlsReadWrite package.  It
takes more time to import a sheet but does have the colClasses command.

Following your example:

library(xlsReadWrite)
read.xls("testtable", sheet = "sheet1", colClasses="character")

should worked, it did for me

--
View this message in context: 
http://r.789695.n4.nabble.com/RODBC-forcing-a-special-column-to-be-read-in-as-character-tp2993624p3493081.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] adaptIntegrate - how to pass additional parameters to the integrand

2011-05-03 Thread HC
Dr. Ligges,

Thanks a lot for providing syntax for passing additional parameters. It
worked for me and has solved my problem.

Many thanks for your quick help.
HC


--
View this message in context: 
http://r.789695.n4.nabble.com/adaptIntegrate-how-to-pass-additional-parameters-to-the-integrand-tp3491701p3492903.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] step.gam with a list of data frames

2011-05-03 Thread Kim Vanselow
Dear R-helpers,
I used the step.gam function (package gam, Trevor Hastie) on a data frame 
without problems. Then I created a list of several bootstrap samples from this 
data frame. Now I want to use the step.gam function on this list using a 
for-loop. The code is working well until the step.gam function starts. Step.gam 
is starting but then suddenly breaks (see error below). However, if I replace 
the for-loop (see below) the whole thing is working well.

for-loop with which the code does not work:

for(i in 1:4){
fit_list[[i]] <- gam(dom_teresken ~ 1, family = poisson, data = Pamir_res[[i]])
}

Replace this with:
fit_list[[1]] <- gam(dom_teresken ~ 1, family = poisson, data = Pamir_res[[1]])
fit_list[[2]] <- gam(dom_teresken ~ 1, family = poisson, data = Pamir_res[[2]])
fit_list[[3]] <- gam(dom_teresken ~ 1, family = poisson, data = Pamir_res[[3]])
fit_list[[4]] <- gam(dom_teresken ~ 1, family = poisson, data = Pamir_res[[4]])

Now everything works well. But I have to use the loop as I want to use much 
more than only 4 bootstrap samples. 


This is the error message:

Start:  dom_teresken ~ 1; AIC= 516.6801 
Trial:  dom_teresken ~  ALTITUDE + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; 
AIC= 512.2938 
Trial:  dom_teresken ~  1 + SLOPE + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; AIC= 
495.0212 
Trial:  dom_teresken ~  1 + 1 + SOUTH_EXPOSEDNESS + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 
1 + 1; AIC= 486.8359 
Trial:  dom_teresken ~  1 + 1 + 1 + WEST_EXPOSEDNESS + 1 + 1 + 1 + 1 + 1 + 1 + 
1 + 1; AIC= 529.8005 
Trial:  dom_teresken ~  1 + 1 + 1 + 1 + DISTANCE_TO_ISOBATH + 1 + 1 + 1 + 1 + 1 
+ 1 + 1Error in Pamir_res[[i]] : subscript out of bounds

This is my full code:

# take bootstrap samples
require(MIfuns) # resample functions
Pamir_res <- resample(Pamir, names= 1:4, replace=TRUE)  # take n bootstrap
# samples from data = Pamir

# calculate gam for each bootstrap sample

fit_list <- vector(4, mode = "list") # create empty list

for(i in 1:4){
fit_list[[i]] <- gam(dom_teresken ~ 1, family = poisson, data = Pamir_res[[i]])
}

gam.scope = list(
~ 1 + ALTITUDE + s(ALTITUDE, 2),
~ 1 + SLOPE + s(SLOPE, 2),
~ 1 + SOUTH_EXPOSEDNESS + s(SOUTH_EXPOSEDNESS, 2),
~ 1 + WEST_EXPOSEDNESS + s(WEST_EXPOSEDNESS, 2),
~ 1 + DISTANCE_TO_ISOBATH + s(DISTANCE_TO_ISOBATH, 2),
~ 1 + UTM_NORTHING + s(UTM_NORTHING, 2),
~ 1 + UTM_EASTING + s(UTM_EASTING, 2),
~ 1 + DISTANCE_TO_SETTLEMENT, s(DISTANCE_TO_SETTLEMENT, 2),
~ 1 + NDVI_Rededge_R_Mean + s(NDVI_Rededge_R_Mean, 2),
~ 1 + NDVI_IR_Rededge_t_Mean + s(NDVI_IR_Rededge_t_Mean, 2),
~ 1 + Bd_5_Mean + s(Bd_5_Mean, 2),
~ 1 + Bd_1t_Mean + s(Bd_1t_Mean, 2))

fit_boot <- vector(4, mode = "list") # create empty list

for(i in 1:4){
 fit_boot[[i]] <- step.gam(fit_list[[i]], scope = gam.scope, direction = 
"both", trace = TRUE)
}


I really tried to find suggestions on the internet and in nabble. Unfortunately 
I could not solve the problem. Please help me!

Thank you very much,
Kim

--

__
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] Controlling the extent of ablines on plot

2011-05-03 Thread Greg Snow
Check your par() settings, specifically "xpd".  For more control see ?clip.  If 
that does not do enough for you then use lines or segments for complete control.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Ryan Utz
> Sent: Tuesday, May 03, 2011 10:36 AM
> To: r-help@r-project.org
> Subject: [R] Controlling the extent of ablines on plot
> 
> Hi all,
> 
> I'm attempting to make a quite-specific plot where the axes cross at
> the
> origin and with gridlines for guidance. I've been using ablines to
> create
> the reference lines because I want a lot of control as to where they
> are
> placed on the axis. This command works very well for such control.
> However...
> 
> These ablines don't seem to work when I specify the origin as 0,0. They
> go
> beyond the x-axis at both ends, rendering a quite ugly graph (and they
> push
> back the y-axis title some).
> 
> Behold:
> 
> ###
> x<-c(0,1,2,3,4,5)
> y<-c(0,2,4,6,8,10)
> 
> plot(x,y, axes=FALSE)
> axis(1,at=c(0,1,2,2.5,3,4,5),pos=0)
> axis(2,at=c(0,2,4,6,8,10),pos=0)
> abline(h=c(1,2,3,4,5))
> ###
> 
> Is there any way for me to specify that these ablines should not go
> beyond
> the y-axis extent? I just want a pretty graph!
> 
> Thanks!
> Ryan
> 
> --
> 
> Ryan Utz, Ph.D.
> Aquatic Ecologist/STREON Scientist
> National Ecological Observatory Network
> 
> Home/Cell: (724) 272-7769
> Work: (720) 746-4844 ext. 2488
> 
>   [[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] Simple loop

2011-05-03 Thread Woida71
Hello everybody,
I am beginning with loops and functions and would be glad to have help in
the following question:
If i have a dataframe like this
Site  Prof  H
1  1 24
1  1 16
1  1 67
1  2 23
1  2 56
1  2 45
2  1 67
2  1 46
And I would like to create a new column that subtracts the minimum of H from
H, but for S1 and P1
only the minimum of the data points falling into this category should be
taken.
So for example the three first numbers of the new column write: 24-16,
16-16, 67-16
the following numbers refering to Site1 and Prof2 write: 23-23, 56-23,
45-23.
I think with two loops one refering to the Site, the other to the Prof, it
should be possible to automatically
create the new column.
Thanks a lot for any help.

--
View this message in context: 
http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.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] data transformation ----Box-Cox Transformations

2011-05-03 Thread Stuart
Hi

Could any one please help how I can trnasform data based on Box-Cox
Transformations. I have massive data set with many variables. If
possible someone can write few lines so I can read in all data set
once and transform it.


g1  g2  g2
97.03703704 89.25925926 4.4
24.90740741 69.25925926 35.5556
62. 85.18518519 36.85185185
18.51851852 84.25925926 21.6667
93.7037037  95.92592593 54.07407407
26.6667 23. 99.25925926
63. 97.03703704 27.40740741
95.74074074 3.6 59.25925926
46.6667 49. 39.1667
21.85185185 2.592592593 63.14814815
94.7222 17.7778 81.


any help will be much appreciated

Cheers
Sbroad

__
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] Controlling the extent of ablines on plot

2011-05-03 Thread Ryan Utz
Well... that could work. Problem is in the actual graphs I'm making, there
are to be >30 lines per graph (as many as 60 in some cases). Any way I could
use the lines command without having to write out 60 lines of code per
figure? That's why I like ablines; you just have to specify a single value
and it will put a horizontal line at that number.

Thanks,
Ryan


> Maybe you could use lines()?
>
> plot(1:2)
> lines(c(1,2),c(1.5,1.5))
>
>
>


-- 

Ryan Utz, Ph.D.
Aquatic Ecologist/STREON Scientist
National Ecological Observatory Network

Home/Cell: (724) 272-7769
Work: (720) 746-4844 ext. 2488

[[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] loading only parts of RData files?

2011-05-03 Thread Christian Schulz

Hi,

g.data  is perhaps a interesting package for you.

HTH,
Christian


Dear List members,


I would like to load R objects saved as RData file but ran into the problem 
that these objects are too large for my RAM ('Can not allocate vactor of size 
XX...'). Switching to a Linux machine is no option, neither is raising the 
memory limit.

I am now wondering whether it is possible to load only specific single objects 
saved in these *.RData files into the workspace. As these objects usually are 
multidimensional arrays, ideally I would be able to load only specific 
dimensions of these arrays. IS there any possibility to do such in R?

I know that NCDF files (and the RNetCDF package) provides possibilities to only 
read specific parts of the data into the memory, but I switching to this format 
would involve a lot of hassle so I would prefer to stay with something as 
convenient as save() and load() without switching to non R file formats.


Thanks for any suggestions
Jannis

__
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] Controlling the extent of ablines on plot

2011-05-03 Thread Jerome Asselin

On Tue, 2011-05-03 at 10:36 -0600, Ryan Utz wrote:
> Hi all,
> 
> I'm attempting to make a quite-specific plot where the axes cross at the
> origin and with gridlines for guidance. I've been using ablines to create
> the reference lines because I want a lot of control as to where they are
> placed on the axis. This command works very well for such control.
> However...
> 
> These ablines don't seem to work when I specify the origin as 0,0. They go
> beyond the x-axis at both ends, rendering a quite ugly graph (and they push
> back the y-axis title some).
> 
> Behold:
> 
> ###
> x<-c(0,1,2,3,4,5)
> y<-c(0,2,4,6,8,10)
> 
> plot(x,y, axes=FALSE)
> axis(1,at=c(0,1,2,2.5,3,4,5),pos=0)
> axis(2,at=c(0,2,4,6,8,10),pos=0)
> abline(h=c(1,2,3,4,5))
> ###
> 
> Is there any way for me to specify that these ablines should not go beyond
> the y-axis extent? I just want a pretty graph!
> 
> Thanks!
> Ryan
> 

Maybe you could use lines()?

plot(1:2)
lines(c(1,2),c(1.5,1.5))

__
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] Controlling the extent of ablines on plot

2011-05-03 Thread Ryan Utz
Hi all,

I'm attempting to make a quite-specific plot where the axes cross at the
origin and with gridlines for guidance. I've been using ablines to create
the reference lines because I want a lot of control as to where they are
placed on the axis. This command works very well for such control.
However...

These ablines don't seem to work when I specify the origin as 0,0. They go
beyond the x-axis at both ends, rendering a quite ugly graph (and they push
back the y-axis title some).

Behold:

###
x<-c(0,1,2,3,4,5)
y<-c(0,2,4,6,8,10)

plot(x,y, axes=FALSE)
axis(1,at=c(0,1,2,2.5,3,4,5),pos=0)
axis(2,at=c(0,2,4,6,8,10),pos=0)
abline(h=c(1,2,3,4,5))
###

Is there any way for me to specify that these ablines should not go beyond
the y-axis extent? I just want a pretty graph!

Thanks!
Ryan

-- 

Ryan Utz, Ph.D.
Aquatic Ecologist/STREON Scientist
National Ecological Observatory Network

Home/Cell: (724) 272-7769
Work: (720) 746-4844 ext. 2488

[[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] Sum the cell of a vector

2011-05-03 Thread Jonathan Daily
?cumsum

On Tue, May 3, 2011 at 11:32 AM, Alaios  wrote:
> Dear all,
> I would like to know what is the most time efficient way to calculate the 
> following in a huge vector.
>
> Let's say that I have the vector
>
> 1,2,3,4,5,6
> and I want to return a vector of the same length which every cell containing 
> the sum of the previous cells like this
>
> 1, 1+2, 1+2+3, 1+2+3+4, 1+2+3+4+5, 1+2+3+4+5+6
>
> What do you think is the most effective way to do that (not having to do the 
> previous sum).
> Of course I can do this with a for loop but I believe that might be a more 
> efficient way in R.
>
> I would like to thank you in advance for your help
>
> Best Regards
> Alex
>
> __
> 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.
>



-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

__
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 converting a data.frame to ordered factors

2011-05-03 Thread Rob Cassidy
Thanks, Phil. 
I could have sworn that I tried that (several times).
It works perfectly, of course.
Thanks again,
Robert

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-converting-a-data-frame-to-ordered-factors-tp3490838p3492705.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] Sum the cell of a vector

2011-05-03 Thread Alaios
Dear all,
I would like to know what is the most time efficient way to calculate the 
following in a huge vector.

Let's say that I have the vector

1,2,3,4,5,6
and I want to return a vector of the same length which every cell containing 
the sum of the previous cells like this

1, 1+2, 1+2+3, 1+2+3+4, 1+2+3+4+5, 1+2+3+4+5+6

What do you think is the most effective way to do that (not having to do the 
previous sum).
Of course I can do this with a for loop but I believe that might be a more 
efficient way in R.

I would like to thank you in advance for your help

Best Regards
Alex

__
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] Bigining with a Program of SVR

2011-05-03 Thread ypriverol
I saw the format of the caret data some days ago. It is possible to convert
my csv data with the same data a format as the caret dataset. My idea is to
use firstly the same scripts as caret tutorial, then i want to remove
problems related with data formats and incompatibilities. 

Thanks for your time

--
View this message in context: 
http://r.789695.n4.nabble.com/Bigining-with-a-Program-of-SVR-tp3484476p3492746.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] loading only parts of RData files?

2011-05-03 Thread Jannis
Dear List members,


I would like to load R objects saved as RData file but ran into the problem 
that these objects are too large for my RAM ('Can not allocate vactor of size 
XX...'). Switching to a Linux machine is no option, neither is raising the 
memory limit.

I am now wondering whether it is possible to load only specific single objects 
saved in these *.RData files into the workspace. As these objects usually are 
multidimensional arrays, ideally I would be able to load only specific 
dimensions of these arrays. IS there any possibility to do such in R?

I know that NCDF files (and the RNetCDF package) provides possibilities to only 
read specific parts of the data into the memory, but I switching to this format 
would involve a lot of hassle so I would prefer to stay with something as 
convenient as save() and load() without switching to non R file formats.


Thanks for any suggestions
Jannis

__
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] fitting distributions using fitdistr (MASS)

2011-05-03 Thread Ravi Varadhan
Your simulation example is bad.  You cannot fit a beta distribution to a data 
that is not in [0,1], leave alone negative data.

x <- runif(1007)

fitdistr(x, "beta", start=list(shape1=0.5, shape2=0.5))


But try this instead:

x <- runif(100, 1, 27)

fitdistr(x, "beta", start=list(shape1=0.5, shape2=0.5))

It seems that when "beta" and "chi-squared" are specified as the distribution 
to be estimated, the "start" parameter for optimization have to be specified by 
the user.  The code does not use any default starting value.
 
Ravi.

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Usha [usha.n...@tcs.com]
Sent: Tuesday, May 03, 2011 5:53 AM
To: r-help@r-project.org
Subject: [R] fitting distributions using fitdistr (MASS)

Please guide me through to resolve the error message that I get

this is what i have done.

>x1<- rnorm(100,2,1)
>x1fitbeta<-fitdistr(x1,"beta")
Error in fitdistr(x1, "beta") : 'start' must be a named list

Yes, I do understand that sometime for the distribution to converge to the
given set of data, it requires initial parameters of the distribution, to
start off with. Hence, i tried this

>x1fitbeta<-fitdistr(x1,densfun=dbeta, start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
  initial value in 'vmmin' is not finite

I tried with "f" and "chi-square" what i did with  "t". Please find below
the output.

> x1fitt<-fitdistr(x1,"t")
Error in fitdistr(x1, "t") : optimization failed
In addition: Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced
3: In log(s) : NaNs produced
4: In log(s) : NaNs produced
5: In log(s) : NaNs produced
6: In log(s) : NaNs produced

> x1fitt<-fitdistr(x1,"t", df=1)
Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced


> x1fitf<-fitdistr(x1,"f",start=list(df1=2,df2=3))
Warning message:
In df(x, df1, df2, log) : NaNs produced
> x1fitf
  df1 df2
  5.6733242   4.4962519
 (1.3407776) (0.9016752)

>x1fitchi<-fitdistr(x1,"chi-squared",df=3)
Error in fitdistr(x1, "chi-squared", df = 3) :
  'start' must be a named list

It is the same as what i gave for beta?!!

> x1fitbeta<-fitdistr(x1,"beta", start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
  initial value in 'vmmin' is not finite

What is the right syntaxwhy do I get error for only some, what are the
exceptions?
I dont know how rectify this error. please resolve

Thanks in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/fitting-distributions-using-fitdistr-MASS-tp3492103p3492103.html
Sent from the R help mailing list archive at Nabble.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] fitting distributions using fitdistr (MASS)

2011-05-03 Thread Prof Brian Ripley

On Tue, 3 May 2011, Usha wrote:


Please guide me through to resolve the error message that I get

this is what i have done.


x1<- rnorm(100,2,1)
x1fitbeta<-fitdistr(x1,"beta")

Error in fitdistr(x1, "beta") : 'start' must be a named list


You have many errors, starting with not reading the posting guide. 
But the main ones seem to be:


(A) A beta distribution has support (0,1).  I bet your data are not 
confined to that interval.  If true (and you failed to give the 
reproducible example the posting guide asked for), then the 
log-likelihood is -Inf ('not finite') for any value of the parameters.


fitdistr() is support software for a book: it is not a tutorial on the 
basics of maximum-likelihood estimation.


(B) As the help says

 For the following named distributions, reasonable starting values
 will be computed if ‘start’ is omitted or only partially
 specified: ‘"cauchy"’, ‘"gamma"’, ‘"logistic"’, ‘"negative
 binomial"’ (parametrized by ‘mu’ and ‘size’), ‘"t"’ and
 ‘"weibull"’.

Since beta is not one of those, you need to specify starting values.


Yes, I do understand that sometime for the distribution to converge to the
given set of data, it requires initial parameters of the distribution, to
start off with. Hence, i tried this


x1fitbeta<-fitdistr(x1,densfun=dbeta, start=list(shape1=2,shape2=3))

Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
 initial value in 'vmmin' is not finite

I tried with "f" and "chi-square" what i did with  "t". Please find below
the output.


x1fitt<-fitdistr(x1,"t")

Error in fitdistr(x1, "t") : optimization failed
In addition: Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced
3: In log(s) : NaNs produced
4: In log(s) : NaNs produced
5: In log(s) : NaNs produced
6: In log(s) : NaNs produced


x1fitt<-fitdistr(x1,"t", df=1)

Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced



x1fitf<-fitdistr(x1,"f",start=list(df1=2,df2=3))

Warning message:
In df(x, df1, df2, log) : NaNs produced

x1fitf

 df1 df2
 5.6733242   4.4962519
(1.3407776) (0.9016752)


No guarantee that your x1 values are positive, either.




x1fitchi<-fitdistr(x1,"chi-squared",df=3)

Error in fitdistr(x1, "chi-squared", df = 3) :
 'start' must be a named list

It is the same as what i gave for beta?!!


x1fitbeta<-fitdistr(x1,"beta", start=list(shape1=2,shape2=3))

Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
 initial value in 'vmmin' is not finite

What is the right syntaxwhy do I get error for only some, what are the
exceptions?
I dont know how rectify this error. please resolve

Thanks in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/fitting-distributions-using-fitdistr-MASS-tp3492103p3492103.html
Sent from the R help mailing list archive at Nabble.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.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
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] Bigining with a Program of SVR

2011-05-03 Thread Max Kuhn
See the examples at the end of:

   http://cran.r-project.org/web/packages/caret/vignettes/caretTrain.pdf

for a QSAR data set for modeling the log blood-brain barrier
concentration. SVMs are not used there but, if you use train(), the
syntax is very similar.

On Tue, May 3, 2011 at 9:38 AM, ypriverol  wrote:
> well, first of all thank for your answer. I need some example that works with
> Support Vector Regression. This is the format of my data:
>  VDP   V1        V2  
>  9.15  1234.5   10
>  9.15 2345.6 15
>  6.7    789.0     12
>  6.7    234.6     11
>  3.2   123.6      5
>  3.2   235.7      8
>
> VDP is the experimental value of the property that i want to predict with
> the model and more accurate. The other variables V1, V2 ... are the
> properties to generate the model. I need some examples that introduce me in
> this field. I read some examples from e1071 but all of them are for
> classification problems.
>
> thanks for your help in advance
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Bigining-with-a-Program-of-SVR-tp3484476p3492487.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.
>



-- 

Max

__
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] Axis trouble

2011-05-03 Thread David Winsemius


On May 3, 2011, at 7:10 AM, David Winsemius wrote:



On May 3, 2011, at 6:12 AM, swaraj basu wrote:


Hello Everyone,
I am having problem in defining specific  
axis for

plotting a vactor.

   vecAVG <- c(0.2, 0.4, 0.6, 0.2, 0.4)

names(vecAVG)<-c("brain","heart","kidney","lung","blood")


   par(mar=c(12,4.1,4.1, 2.1))

plot 
(sort 
(vecAVG 
,decreasing 
=TRUE),type="p",pch=19,col="darkslateblue",axes=FALSE,ann=FALSE)

   g_range<-range(vecAVG)

   
axis(1,at=0:length(vecAVG),lab=names(vecAVG),las=2)

  axis(2, las=1, at=0:g_range[2])

After these commands I am getting the graph but it does not have  
any Y axis.
I know I am making a silly mistake somewhere. Can someone please  
guide me.


I am guessing the you come from a different programming planet where  
vectors go from 0 upwards. This is the problem:


at=0:length(vecAVG)

Try:
at=1:length(vecAVG)

And you should post your error messages with your code.


And the simple fix to the second problem is just:

axis(2, las=1)




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


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] Axis trouble

2011-05-03 Thread David Winsemius


On May 3, 2011, at 6:12 AM, swaraj basu wrote:


Hello Everyone,
 I am having problem in defining specific  
axis for

plotting a vactor.

vecAVG <- c(0.2, 0.4, 0.6, 0.2, 0.4)

names(vecAVG)<-c("brain","heart","kidney","lung","blood")


par(mar=c(12,4.1,4.1, 2.1))

plot 
(sort 
(vecAVG 
,decreasing 
=TRUE),type="p",pch=19,col="darkslateblue",axes=FALSE,ann=FALSE)

g_range<-range(vecAVG)


axis(1,at=0:length(vecAVG),lab=names(vecAVG),las=2)

   axis(2, las=1, at=0:g_range[2])

After these commands I am getting the graph but it does not have any  
Y axis.
I know I am making a silly mistake somewhere. Can someone please  
guide me.


I am guessing the you come from a different programming planet where  
vectors go from 0 upwards. This is the problem:


at=0:length(vecAVG)

Try:
at=1:length(vecAVG)

And you should post your error messages with your 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] Bigining with a Program of SVR

2011-05-03 Thread ypriverol
well, first of all thank for your answer. I need some example that works with
Support Vector Regression. This is the format of my data:
  VDP   V1V2  
  9.15  1234.5   10
  9.15  2345.6   15 
  6.7789.0 12
  6.7234.6 11
  3.2   123.6  5
  3.2   235.7  8

VDP is the experimental value of the property that i want to predict with
the model and more accurate. The other variables V1, V2 ... are the
properties to generate the model. I need some examples that introduce me in
this field. I read some examples from e1071 but all of them are for
classification problems. 

thanks for your help in advance   

--
View this message in context: 
http://r.789695.n4.nabble.com/Bigining-with-a-Program-of-SVR-tp3484476p3492487.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] Axis trouble

2011-05-03 Thread Breheny, Patrick
The expression

0:g_range[2]

is not meaningful.  The : operator is for integers, while your data is 
continuous.  Likely, you want something along the lines of 

axis(2, las=1, at=pretty(vecAVG))

___
Patrick Breheny
Assistant Professor
Department of Biostatistics
Department of Statistics
University of Kentucky

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of swaraj basu
Sent: Tuesday, May 03, 2011 9:13 AM
To: r-help@r-project.org
Subject: [R] Axis trouble

Hello Everyone,
  I am having problem in defining specific axis for
plotting a vactor.

 vecAVG <- c(0.2, 0.4, 0.6, 0.2, 0.4)

names(vecAVG)<-c("brain","heart","kidney","lung","blood")


 par(mar=c(12,4.1,4.1, 2.1))

plot(sort(vecAVG,decreasing=TRUE),type="p",pch=19,col="darkslateblue",axes=FALSE,ann=FALSE)
 g_range<-range(vecAVG)

axis(1,at=0:length(vecAVG),lab=names(vecAVG),las=2)
axis(2, las=1, at=0:g_range[2])

After these commands I am getting the graph but it does not have any Y axis.
I know I am making a silly mistake somewhere. Can someone please guide me.

[[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] Problems with Rterm 2.13.0 - but not RGui

2011-05-03 Thread Stefan McKinnon Høj-Edwards
I've changed to the hard path in the PATH environment variable in Windows and 
it works.
If you are talking about the search path in R, I do not have a clue on how to 
test it.

Regards,
Stefan

-Oprindelig meddelelse-
Fra: Jonathan Daily [mailto:biomathjda...@gmail.com] 
Sendt: 3. maj 2011 13:59
Til: Stefan McKinnon Høj-Edwards
Cc: r-help@r-project.org
Emne: Re: [R] Problems with Rterm 2.13.0 - but not RGui

Ah ok. I suppose the fix is to get the hard path (C:/Program
Files/...) on the search path and remove the symlink from the search
path. Does that work?

2011/5/3 Stefan McKinnon Høj-Edwards :
> Yes, the message is pretty clear, but it has nothing to do with running as 
> admin.
> I have just tried to start a command line with admin privileges and the error 
> still occurs.
> Regarding Rgui, I started it by opening the shortcut.
>
> Now I've tracked down the problem a bit, and the problem appears to be 
> connected to which folder R is called from.
> And by sheer luck I've resolved the problem:
> In all previous versions of Windows, on the Danish editions, the "C:\Program 
> Files" directory was called "C:\Programmer". This appears to be the case in 
> Windows 7, but "C:\Programmer" is a symbolic link (hard/soft?) to "C:\Program 
> Files". And apparently, I've been calling R from "C:\Programmer" instead of 
> "C:\Program Files" which gave the problem.
> When/how/why I changed the PATH variable to the symbolic link is unclear, but 
> a quick check reveals that the problem did not exist in R 2.12.1:
> C:\Programmer\R\R-2.12.1\bin\i386\Rterm  # No problem
> C:\Programmer\R\R-2.13.0\bin\i386\Rterm  # Problem
>
> I will submit a bug report on this.
>
> Kind regards,
> Stefan McKinnon Edwards
>
>
> -Oprindelig meddelelse-
> Fra: Jonathan Daily [mailto:biomathjda...@gmail.com]
> Sendt: 2. maj 2011 16:59
> Til: Stefan McKinnon Høj-Edwards
> Cc: r-help@r-project.org
> Emne: Re: [R] Problems with Rterm 2.13.0 - but not RGui
>
> The message is pretty clear. Access denied means you don't have
> permission to access the path. This also explains why the packages
> fail to load - you don't have access to R's package library. It most
> likely works on RGui because you are clicking it/running it as admin
> (you did not specify how you ran RGui).
>
> 2011/5/2 Stefan McKinnon Høj-Edwards :
>> Hi all,
>>
>> I have just installed R 2.13.0 and I am experiencing problems with the 
>> terminal, but not the with the GUI interface.
>> I am Windows 7.
>>
>> When running "R" or "Rterm" from a commandline I receive the following:
>>
>> Warning message:
>> In normalizePath(path.expand(path), winslash, mustWork) :
>>  path[3]="C:/Programmer/R/R-2.13.0/library": Adgang nægtet
>>
>> R version 2.13.0 (2011-04-13)
>> Copyright (C) 2011 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> Warning message:
>> package "methods" in options("defaultPackages") was not found
>> During startup - Warning messages:
>> 1: package 'datasets' in options("defaultPackages") was not found
>> 2: package 'utils' in options("defaultPackages") was not found
>> 3: package 'grDevices' in options("defaultPackages") was not found
>> 4: package 'graphics' in options("defaultPackages") was not found
>> 5: package 'stats' in options("defaultPackages") was not found
>> 6: package 'methods' in options("defaultPackages") was not found
>>
>>
>> Notice: "C:/Programmer/" is the Danish equivalent of "C:/Program Files".
>> The first error "Adgang nægtet" is directly translated to "Access denied".
>>
>> Any suggestions as how to fix this?
>>
>> Kind regards,
>> Stefan McKinnon Edwards
>>
>> __
>> 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.
>>
>
>
>
> --
> ===
> Jon Daily
> Technician
> ===
> #!/usr/bin/env outside
> # It's great, trust me.
>



-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-proj

[R] Generating summary statistics and simple statistical analysis from my data-set: how can I automate the analysis?

2011-05-03 Thread dereksloan
I am fairly new to R and have a (for me) slightly complicated set of data to
analyse. It contains several continuous and categorical variables for a
group of individuals – e.g;

ID  Sex Age Familysize  Phone   Education
1   M   23  3   Yes Primary
2   F   25  4   Yes Secondary
3   M   33  5   No  Tertiary
4   F   45  1   Yes Secondary
5   F   67  10  Yes Secondary


I want to summarise it in a table as follows;

 All individualsMale Female 
 
Comparison between sexes 

 
(I want to put p-values in this column) 
Age Median (range)  Median (range)   Median (range)Wilcoxon rank
sum test
Family size Median (range)  Median (range)   Median (range)Wilcoxon rank
sum test
Phone   Number Yes (%)  Number Yes (%)   Number Yes (%)Chi-squared test
Education   
  
Chi-squared test
Primary  Number (%) Number (%) Number (%)
Secondary  Number (%)Number (%)  Number (%)
TertiaryNumber (%)Number (%)  Number (%)


How can I use R to do this?
For the continuous variables I know I can write code like;
summary(Age)
by(Age,data["Sex"],summary)
wilcox.test(Age~Sex)
summary(Familysize)
by(Familysize,data[“Sex”],summary)
Wilcox.test(Familysize~Sex)

but is there any way of automating/looping the analysis so that I get
summaries and comparative statistical analysis of all of the continuous
variables in a single command? I’m sure this could be done by some kind of
‘looping’ given that the analysis is always the same. Presumably I then
still have to copy the output of interest (medians, ranges, p-values) into
the summary table manually?

For each categorical variable I have really cumbersome code from which I can
extract the information I need from each variable for the summary table–
e.g,

tphone<-xtabs(~Phone+Sex,data=data)
N<-margin.table(tphone,2)
tphone1<-rbind(tphone,N)
Total<-margin.table(tphone1,1)
tphone1<-cbind(tfbise3xul1,Total)
tphone1<-t(tphone1)
tphone1<-as.data.frame(tphone1)
tphone2<-within(tphone1,{
per.No<-100*(No/N)
per.Yes<-100*(Yes/N)
tphone2<-tphone2[,c(3,2,4,1,5)]
tphone2
chisq.test(tphone)

but there must be better ways of generating the counts, percentages, and
simple statistical analysis  which I need. Again, can I loop it to do all of
my categorical variables at once?

Obviously my dataset has more continuous and categorical variables than
those shown above but I’ve abbreviated it for simplicity of explanation – I
need to write simpler/looped code so that the whole thing is not crazily
long-winded. 

Sorry that my approach so far is so bad and long-winded! R is a long uphill
curve to start with, so I’m be very grateful for any help I can get from
anyone who won’t laugh at me.

Derek


--
View this message in context: 
http://r.789695.n4.nabble.com/Generating-summary-statistics-and-simple-statistical-analysis-from-my-data-set-how-can-I-automate-th-tp3492537p3492537.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] delete excel id automatically generated

2011-05-03 Thread agent dunham
Dear community, 

I uploaded an excel with read.xls. My xls file actually have a column which
is an id, ("plot" is the id) : 

plot height area
347.6 5.4
853.2 4.1
895.4 8.4
121   6.76.2
...
1325  2.11.5

However R uses another id, this way: 

r id   plot height  area
 1  347.6 5.4
 2  853.2 4.1
 3  895.4 8.4
 4 1216.76.2
...
314  1325   2.11.5

I'd like that R used "plot" id because I delete some rows while studying
regression, and R seems to be using the first id 1,2,3,4,...,314. Sometimes
it's a mess to understand what R means in the plots when, for instance,
states that data 200 is influential

Thanks in advance, u...@host.com





--
View this message in context: 
http://r.789695.n4.nabble.com/delete-excel-id-automatically-generated-tp3492147p3492147.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] problem with Sweave and pdflatex

2011-05-03 Thread Frank Lehmann
I set the path with no spaces and run as administrator, but the problem is
not fixed. I'm not quite shure, but I can't remember the problem bevore R
version 2.13. Could it be, that the new R version causes that problem?

Frank Lehmann

-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Gesendet: Montag, 2. Mai 2011 17:52
An: Frank Lehmann
Cc: r-help@r-project.org
Betreff: Re: [R] problem with Sweave and pdflatex

Have you checked the permissions in the working directory? Is there a 
blank in your path (LaTeX does not like spaces in the path).

Uwe Ligges


On 02.05.2011 14:51, Frank Lehmann wrote:
> Hallo,
>
>
>
> when I plot figures with Sweave, I get the message "pdflatex: Permission
> denied". This problem only occurs while working on local system. When I
copy
> the *.rnw-File to my AFS drive, there is no problem at all.
>
>
>
> Here is a small example:
>
>
>
> \documentclass{scrartcl}
>
> \usepackage[OT1]{fontenc}
>
> \usepackage[latin1]{inputenc}
>
> \usepackage[ngerman]{babel}
>
> \usepackage[pdftex]{graphicx}
>
> \usepackage{Sweave}
>
>
>
> \begin{document}
>
>
>
> \setkeys{Gin}{width=\textwidth}
>
> \begin{figure}[htbp]
>
> <>=
>
> x<- 1:10
>
> plot(x)
>
> @
>
> \caption{Eine einfache Grafik}
>
> \end{figure}
>
>
>
> \end{document}
>
>
>
> Does anyone have an idea, how to solve that problem? Im working with
Windows
> XP.
>
>
>
> Thanks!
>
>
>
> Frank
>
>
>   [[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] Watts Strogatz game

2011-05-03 Thread kparamas
Hi,

I have a erdos-renyi game with 6000 nodes and probability 0.003.

g1 = erdos.renyi.game(6000, 0.003)

How to create a Watts Strogatz game with the same probability.

g1 = watts.strogatz.game(1, 6000, ?, ?)
What should be the third and fourth parameter to this argument.


--
View this message in context: 
http://r.789695.n4.nabble.com/Watts-Strogatz-game-tp3491922p3491922.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] install rdcomclient source

2011-05-03 Thread Uwe Ligges



On 03.05.2011 15:05, Richard Wang wrote:

Thanks. I didn't know that.  I just found it in Brian Ripley's page.  Is this 
the  cran extras?



Right, and under Windows it is a default repository.

Uwe Ligges



Thanks
Richard



On 3 May 2011, at 13:19, Uwe Ligges  wrote:




On 03.05.2011 14:09, Richard Wang wrote:

Thanks. One more question.  If I use install.packsges, do I need to install 
Rtool or utils package is sufficient?



It depends on how demanding the package is. For the one you mentioned, you will 
need the Rtools, since C/C++ sources are to be compiled. And it won't work out 
of the box, since some manual tweaks are required - at least the last time I 
tried.

Do you know that the package is available from CRAN extras if form of a Windows binary? 
install.packages() without the type="source"  argument should work right away.

Uwe Ligges



Thanks,
Richard


On 3 May 2011, at 12:26, Uwe Ligges   wrote:




On 02.05.2011 23:48, Richard Wang wrote:

Hi,

I'd like to ask a installation question.  I want to install a source code
through the following command,
R CMD INSTALL RDCOMClient



This is intended to be used in the shell of your OS (assuming Windows given the 
package), not in R.

 From within R use install.packages("RDCOMClient", type="source") if you really 
want to install from source.

Uwe Ligges


but get  Error: unexpected symbol in "r cmd"

Please let know if I miss anything.  I my utils package loaded.

Thanks,
Richard

[[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] Categorical bubble plot

2011-05-03 Thread Jurgens de Bruin
So I have been playing with bubble plot and I was able to create bubble plot
with relatively simple data. I am no having problems when I increase the
complexity of my data. Below is a example of my data:

phytochemicalMainClassFitValues
Name A   0.5
 A0.7
 A0.8
 B0.1
 B0.4
 B0.6

Phytochemical in on the y-axis and MainClass on the x-axis and FitValues is
the color and size of the bubble so each x-y has more than one FitValue.
Will the following still Work?

bubble = ggplot2.ggplot(dataf) + \
ggplot2.aes_string(x='mainclass', y='phytochemcial',
col='fitvalue',size='fitvalue') + \
ggplot2.geom_point()

This is done in rpy2 so it may not look like R.

Thanks!!!

On 21 April 2011 09:49, Jurgens de Bruin  wrote:

> Thanks for all the help!!!
>
>
> On 16 April 2011 08:32, Tal Galili  wrote:
>
>> Hi Jurgens,
>>
>> In the following post I show how to use balloonplot from qplots to do
>> more or less what you ask:
>>
>> http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/
>>
>> p.s: the code has a slight modification to it, so to handle overlapping
>> texts.  Dear Jim, I'd be happy if some of it might be considered into the
>> official release.
>>
>> Cheers,
>> Tal
>>
>> Contact
>> Details:---
>> Contact me: tal.gal...@gmail.com |  972-52-7275845
>> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
>> www.r-statistics.com (English)
>>
>> --
>>
>>
>>
>>
>> On Fri, Apr 15, 2011 at 4:19 PM, Ben Bolker  wrote:
>>
>>> On 04/15/2011 01:13 AM, Jurgens de Bruin wrote:
>>> > Thanks for the reply...
>>> >
>>> > with reproducible I am believe you require a dataset?
>>>
>>>   yes -- but you can make one up if you like.  e.g.
>>>
>>>
>>> dd <- expand.grid(drugclass=LETTERS[1:5],
>>>   plant=c("cactus","sequoia","mistletoe"))
>>> set.seed(101)
>>> dd$fitvalue <- runif(nrow(dd))
>>>
>>> library(ggplot2)
>>> ggplot(dd,aes(x=drugclass,y=plant,colour=fitvalue,size=fitvalue))+
>>>  geom_point()
>>>
>>>  By the way, I think you could represent your data much more
>>> clearly this way: the "Cleveland hierarchy" says that it's easier
>>> to assess quantitative values plotted along a common scale than via
>>> size or colour ...
>>>
>>> ggplot(dd,aes(x=drugclass,y=fitvalue,colour=plant))+
>>>  geom_point()+geom_line(aes(group=plant))
>>>
>>>
>>>
>>> > The size of the bubbles will be related to the fitvalues.
>>> >
>>> >
>>> >
>>> > On 14 April 2011 17:57, Ben Bolker >> > > wrote:
>>> >
>>> > Jurgens de Bruin  gmail.com >
>>> writes:
>>> >
>>> > >
>>> > > Hi,
>>> > >
>>> > > I do not have much R experience just the basics, so please excuse
>>> > > any obvious questions.
>>> > >
>>> > > I would like to create bubble plot that have Categorical data on
>>> > the x and y
>>> > > axis and then the diameter if the bubble the value related to x
>>> and y.
>>> > >  Attached to the email is a pic of what I would like to do.
>>> > >
>>> >
>>> >  A reproducible example would be great.
>>> >
>>> > something along the lines of
>>> >
>>> > library(ggplot2)
>>> >
>>> ggplot(mydata,aes(x=drugclass,y=plant,colour=fitvalue,size=?))+geom_point()
>>> >
>>> >  it's not clear from your description what determines the size.
>>> >  From a labeling point of view, switching x and y might be useful.
>>> >
>>> > __
>>> > 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.
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> > Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures
>>> salutations/
>>> > distinti saluti/siong/duì yú/привет
>>> >
>>> > Jurgens de Bruin
>>>
>>> __
>>>
>>> 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.
>>>
>>
>>
>
>
> --
> Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures salutations/
> distinti saluti/siong/duì yú/привет
>
> Jurgens de Bruin
>



-- 
Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures salutations/
distinti saluti/siong/duì yú/привет

Jurgens 

Re: [R] Lasso with Categorical Variables

2011-05-03 Thread Clemontina Alexander
Thanks for all your help and I apologize for not being clear in the
beginning. I will try the "group lasso" packages. From the paper, it
seems like that is what I want to do. Thanks again!



On Tue, May 3, 2011 at 2:40 AM, Nick Sabbe  wrote:
> For performance reasons, I advise on using the following function instead of
> model.matrix:
>
> factorsToDummyVariables<-function(dfr, betweenColAndLevel="")
> {
>        nc<-dim(dfr)[2]
>        firstRow<-dfr[1,]
>        coln<-colnames(dfr)
>        retval<-do.call(cbind, lapply(seq(nc), function(ci){
>                        if(is.factor(firstRow[,ci]))
>                        {
>                                lvls<-levels(firstRow[,ci])[-1]
>                                stretchedcols<-sapply(lvls, function(lvl){
>                                                rv<-dfr[,ci]==lvl
>                                                mode(rv)<-"integer"
>                                                return(rv)
>                                        })
>                                if(!is.matrix(stretchedcols))
> stretchedcols<-matrix(stretchedcols, nrow=1)
>                                colnames(stretchedcols)<-paste(coln[ci],
> lvls, sep=betweenColAndLevel)
>                                return(stretchedcols)
>                        }
>                        else
>                        {
>                                curcol<-matrix(dfr[,ci], ncol=1)
>                                colnames(curcol)<-coln[ci]
>                                return(curcol)
>                        }
>                }))
>        rownames(retval)<-rownames(dfr)
>        return(retval)
> }
>
>
> Just for comparison: here is my old version of the same function, using
> model.matrix:
>
> factorsToDummyVariables.old<-function(dfrPredictors,
> form=paste("~",paste(colnames(dfrPredictors), collapse="+"), sep=""))
> {
>        #note: this function seems to operate quite slowly!
>        #Because it is used often, it may be worth improving its speed
>        dfrTmp<-model.frame(dfrPredictors, na.action=na.pass)
>        frm<-as.formula(form)
>        mm<-model.matrix(frm, data=dfrTmp)
>        retval<-as.matrix(mm)[,-1]
>
>        return(retval)
> }
>
> In a testcase with a reasonably big dataset, I compared the speeds:
>
> #system.time(tmp.fd.convds.full.man<-manualFactorsToDummyVariables(ds))
> ##   user  system elapsed
> ##   9.44    0.00    9.48
> #system.time(tmp.fd.convds.full<-factorsToDummyVariables.old(ds))
> ##   user  system elapsed
> ##  15.49    0.00   15.64
> #system.time(invisible(factorsToDummyVariables (ds[10,])))
> ##   user  system elapsed
> ##   0.36    0.00    0.36
> #system.time(invisible(factorsToDummyVariables.old (ds[10,])))
> ##   user  system elapsed
> ##   2.18    0.00    2.20
> #system.time(invisible(factorsToDummyVariables (ds[20:30,])))
> ##   user  system elapsed
> ##   0.34    0.00    0.38
> #system.time(invisible(factorsToDummyVariables.old (ds[20:30,])))
> ##   user  system elapsed
> ##   2.11    0.00    2.15
>
> If you have to do this quite often, the difference surely adds up...
> More improvements may be possible.
> This function only works if you don't include interactions, though.
>
>
> Nick Sabbe
> --
> ping: nick.sa...@ugent.be
> link: http://biomath.ugent.be
> wink: A1.056, Coupure Links 653, 9000 Gent
> ring: 09/264.59.36
>
> -- Do Not Disapprove
>
>
>
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of David Winsemius
> Sent: maandag 2 mei 2011 20:48
> To: Steve Lianoglou
> Cc: r-help@r-project.org
> Subject: Re: [R] Lasso with Categorical Variables
>
>
> On May 2, 2011, at 10:51 AM, Steve Lianoglou wrote:
>
>> Hi,
>>
>> On Mon, May 2, 2011 at 12:45 PM, Clemontina Alexander > > wrote:
>>> Hi! This is my first time posting. I've read the general rules and
>>> guidelines, but please bear with me if I make some fatal error in
>>> posting. Anyway, I have a continuous response and 29 predictors made
>>> up of continuous variables and nominal and ordinal categorical
>>> variables. I'd like to do lasso on these, but I get an error. The way
>>> I am using "lars" doesn't allow for the factors. Is there a special
>>> option or some other method in order to do lasso with cat. variables?
>>>
>>> Here is and example (considering ordinal variables as just nominal):
>>>
>>> set.seed(1)
>>> Y <- rnorm(10,0,1)
>>> X1 <- factor(sample(x=LETTERS[1:4], size=10, replace = TRUE))
>>> X2 <- factor(sample(x=LETTERS[5:10], size=10, replace = TRUE))
>>> X3 <- sample(x=30:55, size=10, replace=TRUE)  # think age
>>> X4 <- rchisq(10, df=4, ncp=0)
>>> X <- data.frame(X1,X2,X3,X4)
>>>
 str(X)
>>> 'data.frame':   10 obs. of  4 variables:
>>>  $ X1: Factor w/ 4 levels "A","B","C","D": 4 1 3 1 2 2 1 2 4 2
>>>  $ X2: Factor w/ 5 levels "E","F","G","H",..: 3 4 3 2 5 5 5 1 5 3
>>>  $ X3: int  51 46 50 44 43 50 30 42 49 48
>>>  $ X4: num  2.86 1.55 1.94 2.45 2.75 ...
>>>
>>>
>>> I'd like to do

[R] How to fit a random data into Beta distribution?

2011-05-03 Thread Shekhar
Hi,
I have some random data and i want to find out the parameters of Beta
distribution ( a and b) such that this data approximately fits into
this distribution. I have tried by plot the histograms and graph, but
it requires lot of tuning and i am unable to do that. can anyone tell
me how to do it programmitically in R?

Regards,
Som Shekhar

__
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] fitting distributions using fitdistr (MASS)

2011-05-03 Thread Usha
Please guide me through to resolve the error message that I get

this is what i have done.

>x1<- rnorm(100,2,1)
>x1fitbeta<-fitdistr(x1,"beta")
Error in fitdistr(x1, "beta") : 'start' must be a named list

Yes, I do understand that sometime for the distribution to converge to the
given set of data, it requires initial parameters of the distribution, to
start off with. Hence, i tried this

>x1fitbeta<-fitdistr(x1,densfun=dbeta, start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280, 
: 
  initial value in 'vmmin' is not finite

I tried with "f" and "chi-square" what i did with  "t". Please find below
the output.

> x1fitt<-fitdistr(x1,"t")
Error in fitdistr(x1, "t") : optimization failed
In addition: Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced
3: In log(s) : NaNs produced
4: In log(s) : NaNs produced
5: In log(s) : NaNs produced
6: In log(s) : NaNs produced

> x1fitt<-fitdistr(x1,"t", df=1)
Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced


> x1fitf<-fitdistr(x1,"f",start=list(df1=2,df2=3))
Warning message:
In df(x, df1, df2, log) : NaNs produced
> x1fitf
  df1 df2   
  5.6733242   4.4962519 
 (1.3407776) (0.9016752)

>x1fitchi<-fitdistr(x1,"chi-squared",df=3)
Error in fitdistr(x1, "chi-squared", df = 3) : 
  'start' must be a named list

It is the same as what i gave for beta?!!

> x1fitbeta<-fitdistr(x1,"beta", start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280, 
: 
  initial value in 'vmmin' is not finite

What is the right syntaxwhy do I get error for only some, what are the
exceptions?
I dont know how rectify this error. please resolve

Thanks in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/fitting-distributions-using-fitdistr-MASS-tp3492103p3492103.html
Sent from the R help mailing list archive at Nabble.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] Axis trouble

2011-05-03 Thread swaraj basu
Hello Everyone,
  I am having problem in defining specific axis for
plotting a vactor.

 vecAVG <- c(0.2, 0.4, 0.6, 0.2, 0.4)

names(vecAVG)<-c("brain","heart","kidney","lung","blood")


 par(mar=c(12,4.1,4.1, 2.1))

plot(sort(vecAVG,decreasing=TRUE),type="p",pch=19,col="darkslateblue",axes=FALSE,ann=FALSE)
 g_range<-range(vecAVG)

axis(1,at=0:length(vecAVG),lab=names(vecAVG),las=2)
axis(2, las=1, at=0:g_range[2])

After these commands I am getting the graph but it does not have any Y axis.
I know I am making a silly mistake somewhere. Can someone please guide me.

[[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] removing columns

2011-05-03 Thread David Winsemius


On May 3, 2011, at 4:24 AM, Uwe Ligges wrote:




On 03.05.2011 13:16, nuncio m wrote:

Hi list,

I have a matrix with all elements of some columns are zeroes.  Is it
possible to remove these columns:



Xnew <- X[ , as.logical(colSums(X)), drop=FALSE]


A counter-example:

X <- matrix(c(1,1,1,-1,0,1,1,1,1),3)

A fix:
> Xnew <- X[ , as.logical(colSums(abs(X))), drop=FALSE]
> Xnew
 [,1] [,2] [,3]
[1,]1   -11
[2,]101
[3,]111



Uwe Ligges



and create a new matrix
nuncio



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] Rodbc quesion: how to reliably determine the data type?

2011-05-03 Thread David Winsemius


On May 3, 2011, at 2:10 AM, Albert-Jan Roskam wrote:


Hi Jeff,

Ah, thanks a lot! Yes, meanwhile I also switched to csv. This still  
requires
knowledge about the regional settings (Sys.getlocale), but it's a  
lot more

transparent.


I'm quite new to R and I must say that stuff like this is eating up  
a LOT of my

time. All those invisible data type conversions are driving me nuts.
StringsAsFactors=F should be the default, for instance.



You can set that (if spelled correctly) with options in  
your .Rprofile, and some knowledgeable people have made that choice.


--
David.


Cheers!!
Albert-Jan

~~
All right, but apart from the sanitation, the medicine, education,  
wine, public
order, irrigation, roads, a fresh water system, and public health,  
what have the

Romans ever done for us?
~~




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] Categorical bubble plot

2011-05-03 Thread Ben Bolker
On 11-05-03 09:23 AM, Jurgens de Bruin wrote:
> So I have been playing with bubble plot and I was able to create bubble
> plot with relatively simple data. I am no having problems when I
> increase the complexity of my data. Below is a example of my data:
> 
> phytochemicalMainClassFitValues
> Name A   0.5
>  A0.7
>  A0.8
>  B0.1
>  B0.4
>  B0.6 
> 
> Phytochemical in on the y-axis and MainClass on the x-axis and FitValues
> is the color and size of the bubble so each x-y has more than one
> FitValue. Will the following still Work?
> 
> bubble = ggplot2.ggplot(dataf) + \
> ggplot2.aes_string(x='mainclass', y='phytochemcial',
> col='fitvalue',size='fitvalue') + \
> ggplot2.geom_point()
> 
> This is done in rpy2 so it may not look like R.
> 

  I would expect so, although having the bubbles overlaid on each other
may make it hard to see the results clearly.  Did you try it and see
what happens?
  In general it is better if you can provide us with full/reproducible
examples so we don't have to speculate.
  You might want to set the points partly transparent (e.g.
ggplot2.geom_point(alpha=0.5)).
  However, at this point I would also consider changing the way you are
plotting the data.  As I may have said previously (or may have been
tempted but kept my mouth shut), colour and size are at the bottom of
the "Cleveland hierarchy" -- that is, it's very hard to to reliably
interpret quantitative information on the basis of size and colour.  A
dot chart of some form would probably convey the information more
accurately.

   Ben Bolker


> Thanks!!!
> 
> On 21 April 2011 09:49, Jurgens de Bruin  > wrote:
> 
> Thanks for all the help!!! 
> 
> 
> On 16 April 2011 08:32, Tal Galili  > wrote:
> 
> Hi Jurgens,
> 
> In the following post I show how to use balloonplot from qplots
> to do more or less what you ask:
> 
> http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/
> 
> p.s: the code has a slight modification to it, so to handle
> overlapping texts.  Dear Jim, I'd be happy if some of it might
> be considered into the official release.
> 
> Cheers,
> Tal
> 
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com 
> |  972-52-7275845
> Read me: www.talgalili.com  (Hebrew) |
> www.biostatistics.co.il 
> (Hebrew) | www.r-statistics.com 
> (English)
> 
> --
> 
> 
> 
> 
> On Fri, Apr 15, 2011 at 4:19 PM, Ben Bolker  > wrote:
> 
> On 04/15/2011 01:13 AM, Jurgens de Bruin wrote:
> > Thanks for the reply...
> >
> > with reproducible I am believe you require a dataset?
> 
>  yes -- but you can make one up if you like.  e.g.
> 
> 
> dd <- expand.grid(drugclass=LETTERS[1:5],
>   plant=c("cactus","sequoia","mistletoe"))
> set.seed(101)
> dd$fitvalue <- runif(nrow(dd))
> 
> library(ggplot2)
> ggplot(dd,aes(x=drugclass,y=plant,colour=fitvalue,size=fitvalue))+
>  geom_point()
> 
>  By the way, I think you could represent your data much more
> clearly this way: the "Cleveland hierarchy" says that it's
> easier
> to assess quantitative values plotted along a common scale
> than via
> size or colour ...
> 
> ggplot(dd,aes(x=drugclass,y=fitvalue,colour=plant))+
>  geom_point()+geom_line(aes(group=plant))
> 
> 
> 
> > The size of the bubbles will be related to the fitvalues.
> >
> >
> >
> > On 14 April 2011 17:57, Ben Bolker  
> > >> wrote:
> >
> > Jurgens de Bruin  gmail.com
>  > writes:
> >
> > >
> > > Hi,
> > >
> > > I do not have much R experience just the basics, so
> please excuse
> > > any obvious questions.
> > >
> > > I would like to create bubble plot that have
>  

Re: [R] install rdcomclient source

2011-05-03 Thread Richard Wang
Thanks. I didn't know that.  I just found it in Brian Ripley's page.  Is this 
the  cran extras?

Thanks
Richard



On 3 May 2011, at 13:19, Uwe Ligges  wrote:

> 
> 
> On 03.05.2011 14:09, Richard Wang wrote:
>> Thanks. One more question.  If I use install.packsges, do I need to install 
>> Rtool or utils package is sufficient?
> 
> 
> It depends on how demanding the package is. For the one you mentioned, you 
> will need the Rtools, since C/C++ sources are to be compiled. And it won't 
> work out of the box, since some manual tweaks are required - at least the 
> last time I tried.
> 
> Do you know that the package is available from CRAN extras if form of a 
> Windows binary? install.packages() without the type="source"  argument should 
> work right away.
> 
> Uwe Ligges
> 
> 
>> Thanks,
>> Richard
>> 
>> 
>> On 3 May 2011, at 12:26, Uwe Ligges  wrote:
>> 
>>> 
>>> 
>>> On 02.05.2011 23:48, Richard Wang wrote:
 Hi,
 
 I'd like to ask a installation question.  I want to install a source code
 through the following command,
 R CMD INSTALL RDCOMClient
>>> 
>>> 
>>> This is intended to be used in the shell of your OS (assuming Windows given 
>>> the package), not in R.
>>> 
>>> From within R use install.packages("RDCOMClient", type="source") if you 
>>> really want to install from source.
>>> 
>>> Uwe Ligges
>>> 
 but get  Error: unexpected symbol in "r cmd"
 
 Please let know if I miss anything.  I my utils package loaded.
 
 Thanks,
 Richard
 
[[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] latex, eps graphics and transparent colors / sam2p

2011-05-03 Thread Michael Friendly

On 04/13/2011 05:06 PM, Ben Bolker wrote:
> Thomas Lumley  uw.edu>  writes:
>
>>
>> On Thu, Apr 14, 2011 at 5:30 AM,
>>   Michael Friendly  yorku.ca>  wrote:
>>> I have a diagram to be included in latex, where all my figures are .eps
>>> graphics (so pdflatex is not an option)
>>
>> You could use the pdf() device and then use pdf2ps to convert to 
PostScript.

>
>Clever.
>
> [snip]
>
>> There's now an adjustcolor() function in base R to do this.
>>
>
>That makes my solution more or less obsolete.
>

This is a follow-up to this thread, for which I thank everyone who replied.

I could have fiddled with adjustcolor() to avoid using transparent 
colors, but instead did some tests on generating .png or .pdf files

with transparent colors and then converting to .eps.

I tried the following, in various combinations [running on ubuntu 10.02 
linux]

  input file: foo.{pdf,png}
  converters: pdf2ps, pdftopdf, convert (ImageMagick)

All of these gave really *huge* output files, by a factor of 10-20 times
the original.

Finally, I remembered (the badly named) sam2p utility,
http://pts.szit.bme.hu/sam2p/
http://code.google.com/p/sam2p/

I'm not sure what magic it uses for compression, but the results are 
quite impressive compared with the competition.


Bottom line: the combination of .pdf + sam2p seems to work best in my 
tests, below.  The result is even smaller than the input file, and

I can't tell the difference in the onscreen display.

 % ls -l foo.*
-rw-r--r-- 1 friendly staff 11794 2011-04-29 08:31 foo.pdf
-rw-r--r-- 1 friendly staff 20775 2011-04-29 08:32 foo.png
euclid: /tmp % pdf2ps foo.pdf foo-pdf2ps.eps
euclid: /tmp % pdftops foo.pdf foo-pdftops.eps
euclid: /tmp % convert foo.pdf foo-convert-pdf.eps
euclid: /tmp % convert foo.png foo-convert-png.eps
euclid: /tmp % sam2p foo.png foo-sam2p-png.eps
This is sam2p v0.47-1.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG 
PNM GIF89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.

sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: foo.png
sam2p: Notice: writeTTT: using template: l23
sam2p: Notice: applyProfile: applied OutputRule #37
sam2p: Notice: job: written OutputFile: foo-sam2p-png.eps
Success.


sam2p foo.pdf foo-sam2p-pdf.eps
This is sam2p v0.47-1.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG 
PNM GIF89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
gs_cmd=(gs -r72 -q -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dLastPage=1 
-sDEVICE=pnmraw -dDELAYSAFER -dBATCH -dNOPAUSE -sOutputFile=%D  -- %S)

sam2p: Notice: job: read InputFile: foo.pdf
sam2p: Notice: writeTTT: using template: l23
sam2p: Notice: applyProfile: applied OutputRule #27
sam2p: Notice: job: written OutputFile: foo-sam2p-pdf.eps
Success.
euclid: /tmp % ls -l foo*
-rw-r--r-- 1 friendly staff 1139852 2011-05-03 08:41 foo-convert-pdf.eps
-rw-r--r-- 1 friendly staff 2924149 2011-05-03 08:41 foo-convert-png.eps
-rw-r--r-- 1 friendly staff   11794 2011-04-29 08:31 foo.pdf
-rw-r--r-- 1 friendly staff 1687255 2011-05-03 08:41 foo-pdf2ps.eps
-rw-r--r-- 1 friendly staff 2775130 2011-05-03 08:41 foo-pdftops.eps
-rw-r--r-- 1 friendly staff   20775 2011-04-29 08:32 foo.png
-rw-r--r-- 1 friendly staff8701 2011-05-03 08:44 foo-sam2p-pdf.eps
-rw-r--r-- 1 friendly staff   35926 2011-05-03 08:42 foo-sam2p-png.eps
euclid: /tmp %

__
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] install rdcomclient source

2011-05-03 Thread Uwe Ligges



On 03.05.2011 14:09, Richard Wang wrote:

Thanks. One more question.  If I use install.packsges, do I need to install 
Rtool or utils package is sufficient?



It depends on how demanding the package is. For the one you mentioned, 
you will need the Rtools, since C/C++ sources are to be compiled. And it 
won't work out of the box, since some manual tweaks are required - at 
least the last time I tried.


Do you know that the package is available from CRAN extras if form of a 
Windows binary? install.packages() without the type="source"  argument 
should work right away.


Uwe Ligges



Thanks,
Richard


On 3 May 2011, at 12:26, Uwe Ligges  wrote:




On 02.05.2011 23:48, Richard Wang wrote:

Hi,

I'd like to ask a installation question.  I want to install a source code
through the following command,
R CMD INSTALL RDCOMClient



This is intended to be used in the shell of your OS (assuming Windows given the 
package), not in R.

 From within R use install.packages("RDCOMClient", type="source") if you really 
want to install from source.

Uwe Ligges


but get  Error: unexpected symbol in "r cmd"

Please let know if I miss anything.  I my utils package loaded.

Thanks,
Richard

[[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] install rdcomclient source

2011-05-03 Thread Richard Wang
Thanks. One more question.  If I use install.packsges, do I need to install 
Rtool or utils package is sufficient?

Thanks,
Richard


On 3 May 2011, at 12:26, Uwe Ligges  wrote:

> 
> 
> On 02.05.2011 23:48, Richard Wang wrote:
>> Hi,
>> 
>> I'd like to ask a installation question.  I want to install a source code
>> through the following command,
>> R CMD INSTALL RDCOMClient
> 
> 
> This is intended to be used in the shell of your OS (assuming Windows given 
> the package), not in R.
> 
> From within R use install.packages("RDCOMClient", type="source") if you 
> really want to install from source.
> 
> Uwe Ligges
> 
>> but get  Error: unexpected symbol in "r cmd"
>> 
>> Please let know if I miss anything.  I my utils package loaded.
>> 
>> Thanks,
>> Richard
>> 
>>[[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] Problems with Rterm 2.13.0 - but not RGui

2011-05-03 Thread Søren Højsgaard
A safe way out of this mess is to install R somewhere else. 

For example, create a directory c:\Programs and install R there. 

Regards
Søren


-Oprindelig meddelelse-
Fra: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] På 
vegne af Jonathan Daily
Sendt: 3. maj 2011 13:59
Til: Stefan McKinnon Høj-Edwards
Cc: r-help@r-project.org
Emne: Re: [R] Problems with Rterm 2.13.0 - but not RGui

Ah ok. I suppose the fix is to get the hard path (C:/Program
Files/...) on the search path and remove the symlink from the search
path. Does that work?

2011/5/3 Stefan McKinnon Høj-Edwards :
> Yes, the message is pretty clear, but it has nothing to do with running as 
> admin.
> I have just tried to start a command line with admin privileges and the error 
> still occurs.
> Regarding Rgui, I started it by opening the shortcut.
>
> Now I've tracked down the problem a bit, and the problem appears to be 
> connected to which folder R is called from.
> And by sheer luck I've resolved the problem:
> In all previous versions of Windows, on the Danish editions, the "C:\Program 
> Files" directory was called "C:\Programmer". This appears to be the case in 
> Windows 7, but "C:\Programmer" is a symbolic link (hard/soft?) to "C:\Program 
> Files". And apparently, I've been calling R from "C:\Programmer" instead of 
> "C:\Program Files" which gave the problem.
> When/how/why I changed the PATH variable to the symbolic link is unclear, but 
> a quick check reveals that the problem did not exist in R 2.12.1:
> C:\Programmer\R\R-2.12.1\bin\i386\Rterm  # No problem
> C:\Programmer\R\R-2.13.0\bin\i386\Rterm  # Problem
>
> I will submit a bug report on this.
>
> Kind regards,
> Stefan McKinnon Edwards
>
>
> -Oprindelig meddelelse-
> Fra: Jonathan Daily [mailto:biomathjda...@gmail.com]
> Sendt: 2. maj 2011 16:59
> Til: Stefan McKinnon Høj-Edwards
> Cc: r-help@r-project.org
> Emne: Re: [R] Problems with Rterm 2.13.0 - but not RGui
>
> The message is pretty clear. Access denied means you don't have
> permission to access the path. This also explains why the packages
> fail to load - you don't have access to R's package library. It most
> likely works on RGui because you are clicking it/running it as admin
> (you did not specify how you ran RGui).
>
> 2011/5/2 Stefan McKinnon Høj-Edwards :
>> Hi all,
>>
>> I have just installed R 2.13.0 and I am experiencing problems with the 
>> terminal, but not the with the GUI interface.
>> I am Windows 7.
>>
>> When running "R" or "Rterm" from a commandline I receive the following:
>>
>> Warning message:
>> In normalizePath(path.expand(path), winslash, mustWork) :
>>  path[3]="C:/Programmer/R/R-2.13.0/library": Adgang nægtet
>>
>> R version 2.13.0 (2011-04-13)
>> Copyright (C) 2011 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> Warning message:
>> package "methods" in options("defaultPackages") was not found
>> During startup - Warning messages:
>> 1: package 'datasets' in options("defaultPackages") was not found
>> 2: package 'utils' in options("defaultPackages") was not found
>> 3: package 'grDevices' in options("defaultPackages") was not found
>> 4: package 'graphics' in options("defaultPackages") was not found
>> 5: package 'stats' in options("defaultPackages") was not found
>> 6: package 'methods' in options("defaultPackages") was not found
>>
>>
>> Notice: "C:/Programmer/" is the Danish equivalent of "C:/Program Files".
>> The first error "Adgang nægtet" is directly translated to "Access denied".
>>
>> Any suggestions as how to fix this?
>>
>> Kind regards,
>> Stefan McKinnon Edwards
>>
>> __
>> 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.
>>
>
>
>
> --
> ===
> Jon Daily
> Technician
> ===
> #!/usr/bin/env outside
> # It's great, trust me.
>



-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

__
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

Re: [R] Problems with Rterm 2.13.0 - but not RGui

2011-05-03 Thread Jonathan Daily
Ah ok. I suppose the fix is to get the hard path (C:/Program
Files/...) on the search path and remove the symlink from the search
path. Does that work?

2011/5/3 Stefan McKinnon Høj-Edwards :
> Yes, the message is pretty clear, but it has nothing to do with running as 
> admin.
> I have just tried to start a command line with admin privileges and the error 
> still occurs.
> Regarding Rgui, I started it by opening the shortcut.
>
> Now I've tracked down the problem a bit, and the problem appears to be 
> connected to which folder R is called from.
> And by sheer luck I've resolved the problem:
> In all previous versions of Windows, on the Danish editions, the "C:\Program 
> Files" directory was called "C:\Programmer". This appears to be the case in 
> Windows 7, but "C:\Programmer" is a symbolic link (hard/soft?) to "C:\Program 
> Files". And apparently, I've been calling R from "C:\Programmer" instead of 
> "C:\Program Files" which gave the problem.
> When/how/why I changed the PATH variable to the symbolic link is unclear, but 
> a quick check reveals that the problem did not exist in R 2.12.1:
> C:\Programmer\R\R-2.12.1\bin\i386\Rterm  # No problem
> C:\Programmer\R\R-2.13.0\bin\i386\Rterm  # Problem
>
> I will submit a bug report on this.
>
> Kind regards,
> Stefan McKinnon Edwards
>
>
> -Oprindelig meddelelse-
> Fra: Jonathan Daily [mailto:biomathjda...@gmail.com]
> Sendt: 2. maj 2011 16:59
> Til: Stefan McKinnon Høj-Edwards
> Cc: r-help@r-project.org
> Emne: Re: [R] Problems with Rterm 2.13.0 - but not RGui
>
> The message is pretty clear. Access denied means you don't have
> permission to access the path. This also explains why the packages
> fail to load - you don't have access to R's package library. It most
> likely works on RGui because you are clicking it/running it as admin
> (you did not specify how you ran RGui).
>
> 2011/5/2 Stefan McKinnon Høj-Edwards :
>> Hi all,
>>
>> I have just installed R 2.13.0 and I am experiencing problems with the 
>> terminal, but not the with the GUI interface.
>> I am Windows 7.
>>
>> When running "R" or "Rterm" from a commandline I receive the following:
>>
>> Warning message:
>> In normalizePath(path.expand(path), winslash, mustWork) :
>>  path[3]="C:/Programmer/R/R-2.13.0/library": Adgang nægtet
>>
>> R version 2.13.0 (2011-04-13)
>> Copyright (C) 2011 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> Warning message:
>> package "methods" in options("defaultPackages") was not found
>> During startup - Warning messages:
>> 1: package 'datasets' in options("defaultPackages") was not found
>> 2: package 'utils' in options("defaultPackages") was not found
>> 3: package 'grDevices' in options("defaultPackages") was not found
>> 4: package 'graphics' in options("defaultPackages") was not found
>> 5: package 'stats' in options("defaultPackages") was not found
>> 6: package 'methods' in options("defaultPackages") was not found
>>
>>
>> Notice: "C:/Programmer/" is the Danish equivalent of "C:/Program Files".
>> The first error "Adgang nægtet" is directly translated to "Access denied".
>>
>> Any suggestions as how to fix this?
>>
>> Kind regards,
>> Stefan McKinnon Edwards
>>
>> __
>> 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.
>>
>
>
>
> --
> ===
> Jon Daily
> Technician
> ===
> #!/usr/bin/env outside
> # It's great, trust me.
>



-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

__
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] install rdcomclient source

2011-05-03 Thread Uwe Ligges



On 02.05.2011 23:48, Richard Wang wrote:

Hi,

I'd like to ask a installation question.  I want to install a source code
through the following command,
R CMD INSTALL RDCOMClient



This is intended to be used in the shell of your OS (assuming Windows 
given the package), not in R.


From within R use install.packages("RDCOMClient", type="source") if you 
really want to install from source.


Uwe Ligges


but get  Error: unexpected symbol in "r cmd"

Please let know if I miss anything.  I my utils package loaded.

Thanks,
Richard

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


  1   2   >