Re: [R] Installing package QRMlib

2012-02-28 Thread Pfaff, Bernhard Dr.
Dear all:

well, what Duncan has suggested would work in principle. However, the 
dependencies of QRMlib as contained in the archive have been deprecated and the 
package maintainer (cc'ed to this email directly) is pretty close to a 
re-release of his package on CRAN, whereby primarily the outdated package 
dependency to fSeries is changed to timeSeries. 
Hence, before grabbing the deprecated package dependencies on R-Forge and 
install these, it might be worth waiting for the re-submittance of QRMlib to 
CRAN, given that it will be made in due course. Scott, do you have any further 
information whence QRMlib will be made available again on CRAN?

Best,
Bernhard

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von Duncan Murdoch
Gesendet: Montag, 27. Februar 2012 21:16
An: R. Michael Weylandt
Cc: r-help@r-project.org; DT54321
Betreff: Re: [R] Installing package QRMlib

On 27/02/2012 3:01 PM, R. Michael Weylandt wrote:
 Do you perhaps need to add install.packages(...,  type=src)? Just a
 (untested) guess...

That should be type=source, and that should solve the problem, assuming 
Deepan has the necessary tools installed.  If not, he can get them from CRAN in 
the bin/windows/Rtools directory.

Duncan Murdoch

 Michael

 On Mon, Feb 27, 2012 at 12:07 PM, DT54321deepan.tailo...@gmail.com  wrote:
   Hi,
   I am having real problems downloading the package 'QRMlib'. The 
  tar.gz file  is shown here:
 
   http://cran.r-project.org/src/contrib/Archive/QRMlib/
 
   I have downloaded this to my local folder and entered the following 
  command:
 
   nstall.packages(myLocalFolder/QRMlib_1.4.5.1.tar.gz, repos = 
  NULL)
 
   but I am getting the following error message
 
   Installing package(s) into 'C:/Program Files/R/R-2.14.1/library'
   (as 'lib' is unspecified)
   Warning in install.packages :
 error 1 in extracting from zip file  Warning in install.packages 
  :
 cannot open compressed file 'QRMlib_1.4.5.1.tar.gz/DESCRIPTION', 
  probable  reason 'No such file or directory'
   Error in install.packages : cannot open the connection
 
   What am I doing wrong??
 
   Thanks
 
   --
   View this message in context: 
  http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p44
  25269.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.
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Principal Components for matrices with NA

2012-02-28 Thread Mark Difford
On Feb 27, 2012 at 9:30pm Joyous Fisher wrote:

 Q: is there a way to do princomp or another method where every row has at 
 least one missing column?

You have several options. Try function nipals in packages ade4 and plspm.
Also look at package pcaMethods (on Bioconductor), where you will find a
full range of options for carrying out principal component analysis using
matrices with missing values.

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Principal-Components-for-matrices-with-NA-tp4425930p4427216.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] Conditional density estimation in R and integration

2012-02-28 Thread fReak


Hey there,


I have the following problem: 

I need to carry out a nonparametric conditional density estimation -- pretty
much what can be achieved using the np package. However, I need to be able
to use the output of the np package in such a way that i get a continuous
function as output, which can be integrated on any given interval between
-Inf and Inf. This integration will of have to be across mutliple dimension
since I am working with a conditional pdf. Any advise on how to accomplish
this? I suspect that I need to use some kind of interpolation package to get
from the output of the np package to getting a function that can be
integrated, but that is exacly where I am stuck

Thanks for your help!

--
View this message in context: 
http://r.789695.n4.nabble.com/Conditional-density-estimation-in-R-and-integration-tp4427356p4427356.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 analysis

2012-02-28 Thread nontokozo mhlanga
 Please assist me with  all the tests including risk factor analysis i  can
use to analyse the enclosed database established from a questionnaire survey
to test for the prevalence of tuberculosis in humans .

Thank you

Nonty

--
View this message in context: 
http://r.789695.n4.nabble.com/data-analysis-tp4427257p4427257.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] macro function

2012-02-28 Thread mrzung
hi, 

I know how to use the for loop function like: 

for(i in 1:ncol(mat)){ 
mat[i]-b[i,2] 
} 

but, in this case 

r1-b[1,1] 
r2-b[2,1] 
r3-b[3,1] 
r4-b[4,1] 

* 
* 
* 

r3002-b[3002,1] 
r3003-b[3003,1] 

- must make vectors 

how should I make a efficient code for that? 

Is there anything in R like SAS MACRO function? 

--
View this message in context: 
http://r.789695.n4.nabble.com/macro-function-tp4427385p4427385.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] Error message: object of type 'closure' is not subsettable

2012-02-28 Thread Aparna Sampath
Hi All

I am trying to use the unlist() in R to a list variable.  The following
statements are within a function. 
{
denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n) 
 returnValue - l2 / (denominator + 11)
  attr(returnValue,numerator) - l2
  attr(returnValue,denominator) - denominator
  returnValue
}

And when I try to unlist the variable returnValue

 numerators - unlist(testStatistics[numerator,])
  denominators - unlist(testStatistics[denominator,])

I get the following error: 

Error in testStatistics[numerator, ] : 
  object of type 'closure' is not subsettable

I read some threads in R help on this error and they had asked to check if
we are using the right datatype to the right function. But in my case it is
pretty straightforward since I just list it in one function and try to
unlist it later. Any suggestions?
Thanks for the help :)

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-not-subsettable-tp3752886p4427399.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 analysis

2012-02-28 Thread Hans Ekbrand
On Mon, Feb 27, 2012 at 11:04:13PM -0800, nontokozo mhlanga wrote:
  Please assist me with  all the tests including risk factor analysis i  can
 use to analyse the enclosed database established from a questionnaire survey
 to test for the prevalence of tuberculosis in humans .

That's quite a general request. I think you should try to formulate a
specific question.

Have you read the posting-guide? http://www.R-project.org/posting-guide.html

Also, I don't think the list accepts attached files.

-- 
Hans Ekbrand (http://sociologi.cjb.net) h...@sociologi.cjb.net

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] macro function

2012-02-28 Thread Joshua Wiley
Hi,

There is not anything really like macro functions in R (and honestly,
that is probably a good thing).  Most the times I have seen people
generating thousands of variables (vectors in your case) it is due to
a lack of understanding how lists can be utilized to simplify code.
If you give us some context on what all these vectors will be used
for, we may be able to suggest an easier way to accomplish your goals.

If you must create vectors:

sapply(1:3003, function(i) {
  assign(paste(r, i, sep = ''), rnorm(1), envir = .GlobalEnv)
})

or with a for loop:

for (i in 1:3003) {
  assign(paste(r, i, sep = ''), rnorm(1), envir = .GlobalEnv)
}

HTH,

Josh

On Tue, Feb 28, 2012 at 12:14 AM, mrzung mrzun...@gmail.com wrote:
 hi,

 I know how to use the for loop function like:

 for(i in 1:ncol(mat)){
 mat[i]-b[i,2]
 }

 but, in this case

 r1-b[1,1]
 r2-b[2,1]
 r3-b[3,1]
 r4-b[4,1]

 *
 *
 *

 r3002-b[3002,1]
 r3003-b[3003,1]

 - must make vectors

 how should I make a efficient code for that?

 Is there anything in R like SAS MACRO function?

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/macro-function-tp4427385p4427385.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.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://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] Error message: object of type 'closure' is not subsettable

2012-02-28 Thread Joshua Wiley
Hi Aparna,

Can you please post a reproducible example?  It is difficult to
provide much concrete help without having testStatistics.  One thing
you might try is looking at:

str(testStatistics[numerator,])

is it actually a list?  If it is not (most likely given the error) and
it is supposed to be, you need to figure out what aspect of the
generation of it is going awry.

Cheers,

Josh

On Tue, Feb 28, 2012 at 12:23 AM, Aparna Sampath
aparna.sampat...@gmail.com wrote:
 Hi All

 I am trying to use the unlist() in R to a list variable.  The following
 statements are within a function.
 {
 denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n)
  returnValue - l2 / (denominator + 11)
  attr(returnValue,numerator) - l2
  attr(returnValue,denominator) - denominator
  returnValue
 }

 And when I try to unlist the variable returnValue

  numerators - unlist(testStatistics[numerator,])
  denominators - unlist(testStatistics[denominator,])

 I get the following error:

Error in testStatistics[numerator, ] :
  object of type 'closure' is not subsettable

 I read some threads in R help on this error and they had asked to check if
 we are using the right datatype to the right function. But in my case it is
 pretty straightforward since I just list it in one function and try to
 unlist it later. Any suggestions?
 Thanks for the help :)

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-not-subsettable-tp3752886p4427399.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.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://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] Error message: object of type 'closure' is not subsettable

2012-02-28 Thread Joshua Wiley
Hi Aparna,

If you have not defined testStatistics in your code, but it is a
function, then either you defined it at some earlier point and it was
never removed, or some other package you loaded defines it.

You could try using your code in a clean R session (make sure that an
old workspace is not automatically loaded; one way would be by closing
R, deleting the old workspace, and then starting a new instance).

Cheers,

Josh

On Tue, Feb 28, 2012 at 1:37 AM, Aparna Sampath
aparna.sampat...@gmail.com wrote:
 Hi Josh

 Kindly find below the code as it is executed:

 test.functional.t - function(res.em1,res.em2,mint,maxt,se.m=0,points=300)
 {
   at - seq(mint,maxt,length.out=points)
   by - at[2] - at[1]

   mu1 - spline(x=res.em1$tau,y=res.em1$eta,xout=at,method=natural)$y
 l2 - functional.norm(mu1,mu2,by=by)

   s1 - mean(sapply(1:res.em1$n,
     function(i)
     {
       v -
 spline(x=res.em1$tau,y=res.em1$vi[[i]],xout=at,method=natural)$y
       functional.norm(v,by=by)^2
     }))
 denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n) ### formula for se
   returnValue - l2 / (denominator + se.m)

   attr(returnValue,numerator) - l2
   attr(returnValue,denominator) - denominator

   returnValue
 }

 moderated.functional.t -
 function(testStatistics,alpha.step=0.05,quantile.step=0.01)
 {
   numerators - unlist(testStatistics[numerator,])
   denominators - unlist(testStatistics[denominator,])
 }

 I get my error in the function above moderated.functional.t. testStatistics
 is shown to be a function(x) when I type it in R console. But there is no
 function definition for testStatistics in the code. My R understanding is
 still elementary.

 Thanks
 Aparna




 On Tue, Feb 28, 2012 at 5:25 PM, Joshua Wiley jwiley.ps...@gmail.com
 wrote:

 Hi Aparna,

 Can you please post a reproducible example?  It is difficult to
 provide much concrete help without having testStatistics.  One thing
 you might try is looking at:

 str(testStatistics[numerator,])

 is it actually a list?  If it is not (most likely given the error) and
 it is supposed to be, you need to figure out what aspect of the
 generation of it is going awry.

 Cheers,

 Josh

 On Tue, Feb 28, 2012 at 12:23 AM, Aparna Sampath
 aparna.sampat...@gmail.com wrote:
  Hi All
 
  I am trying to use the unlist() in R to a list variable.  The following
  statements are within a function.
  {
  denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n)
   returnValue - l2 / (denominator + 11)
   attr(returnValue,numerator) - l2
   attr(returnValue,denominator) - denominator
   returnValue
  }
 
  And when I try to unlist the variable returnValue
 
   numerators - unlist(testStatistics[numerator,])
   denominators - unlist(testStatistics[denominator,])
 
  I get the following error:
 
 Error in testStatistics[numerator, ] :
   object of type 'closure' is not subsettable
 
  I read some threads in R help on this error and they had asked to check
  if
  we are using the right datatype to the right function. But in my case it
  is
  pretty straightforward since I just list it in one function and try to
  unlist it later. Any suggestions?
  Thanks for the help :)
 
  --
  View this message in context:
  http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-not-subsettable-tp3752886p4427399.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.



 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/




 --
 Aparna Sampath
 Master of Science (Bioinformatics)
 Nanyang Technological University
 Mob no : +65 91601854



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://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] asking for a script

2012-02-28 Thread Petr PIKAL
Hi

 
 Dear who may concern,
 I am sending you this email to ask if I could have someone help me to 
 write this script I am interested in.
 I am requesting the script for performing variance-stabilizing 
 normalizations on the R language. Could you please help me on that?
 If I am asking a wrong person, could you please tell me the right email 
 address I should contact?

Maybe you shall ask google. I tried 

variance-stabilizing normalizations

and as a second hit I got

Variance Stabilization and Normalization
using the vsn package in R

Is this what you wanted?

Regards
Petr



 Appreciated!
 Thanks!
 
 Regards
 
 Ruijuan Luo
 
 
[[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] Non linear regression with complex equation

2012-02-28 Thread jeff_hawkes
Apologies for the phrasing of the question.
I've sorted the problem (thanks Bert Gunter) by using the curly brackets {}
as below (using a simplified version of my real model). I hope this helps
someone else!

Jeff
---
 data
  Alpha ip   X
1 0.7106967  0.3616727 0.006027879
2 2.1678517  5.0615917 0.084359861
3 4.4066250 11.2282945 0.187138242
4 9.8495694 18.0534974 0.300891624
527.7247098 29.2064434 0.486774057
670.6931430 35.3946092 0.589910153
7   133.1240255 46.0347288 0.767245480
8   214.7851844 49.3811149 0.823018582
9   359.5511036 58.5069583 0.975115972
10  748.1840127 57.3744477 0.956240795
11 2129.9844080 60.000 1.0
 c-1.83e-9
 cFe=c
 model-nls({Fe1-cFe/(Alpha+1+k*c)
+ X~Alpha/(Alpha+1+k*c/(1+k*Fe1))},start=list(k=1e10))
 summary(model)

Formula: X ~ Alpha/(Alpha + 1 + k * c/(1 + k * Fe1))

Parameters:
   Estimate Std. Error t value Pr(|t|)
k 3.491e+10  7.190e+09   4.856 0.000665 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.05589 on 10 degrees of freedom

Number of iterations to convergence: 8 
Achieved convergence tolerance: 2.393e-06 


--
View this message in context: 
http://r.789695.n4.nabble.com/Non-linear-regression-with-complex-equation-tp4425942p4427617.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] Bayesian Hidden Markov Models

2012-02-28 Thread Oscar Rueda
Dear James, 

Basically you just need the values (y) and the positions (in your case it
would be the index of the times series). The chromosome argument does not
apply to your case so it can be a vector of ones.
If the positions are at the same distance between (equally spaced) then the
model will be homogeneous.

So for example something like this would be enough:
 library(RJaCGH)
 y - c(rnorm(100,0,1), rnorm(20, 2, 1), rnorm(50, 0, 1))
 Pos - 1:length(y)
 Chrom - rep(1, length(y))
 res - RJaCGH(y=y, Pos=Pos, Chrom=Chrom)
 summary(res)

However, it uses a Reversible Jump algorithm and therefore jumps between
models with different hidden states. I would suggest you take a look at the
vignette that comes with the package or the paper that is referenced there
for specific details of the model it fits.


Hope it helps, 
Oscar 
 


On 28/2/12 04:52, monkeylan lanjin...@yahoo.com.cn wrote:

 Dear Doctor Oscar,
  
 Sorry for not noticing that you are the author of the RJaCGH package.
 
 But I noticed that hidden Markov model in your package is with non-homogeneous
 transition probabilities. Here in my work, the HMM is just a first-order
 homogeneous Markov chain, i.e. the  transition  matrix is constant.
  
 So, Could you please tell me how can I adjust the R functions in your package
 to implement my analysis?
  
 Best Regards,
  
 James Allan
 
 
 --- 12年2月27日,周一, Oscar Rueda [via R]
 ml-node+s789695n4424152...@n4.nabble.com 写道:
 
 
 发件人: Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com
 主题: Re: Bayesian Hidden Markov Models
 收件人: monkeylan lanjin...@yahoo.com.cn
 日期: 2012年2月27日,周一,下午6:05
 
 
 Dear James,
 Although designed for the analysis of copy number CGH microarrays, RJaCGH
 uses a Bayesian HMM model.
 
 Cheers,
 Oscar
 
 
 On 27/2/12 08:32, monkeylan [hidden email] wrote:
 
 
 Dear R buddies,
 
 Recently, I attempt to model the US/RMB Exchange rate log-return time series
 with a *Hidden Markov model (first order Markov Chain  mixed Normal
 distributions). *
 
 I have applied the RHmm package to accomplish this task, but the results are
 not so satisfying.
 So, I would like to try a *Bayesian method *for the parameter estimation of
 the Hidden Markov model.
 
 Could anyone kindly tell me which R package can perform Bayesian estimation
 of the model?
 
 Many thanks for your help and time.
 
 Best Regards,
 James Allan
 
 
 --
 View this message in context:
 
http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946
.
 html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 [hidden email] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 Oscar M. Rueda, PhD.
 Postdoctoral Research Fellow, Breast Cancer Functional Genomics.
 Cancer Research UK Cambridge Research Institute.
 Li Ka Shing Centre, Robinson Way.
 Cambridge CB2 0RE
 England
 
 
 
 
 NOTICE AND DISCLAIMER
 This e-mail (including any attachments) is intended for ...{{dropped:16}}
 
 __
 [hidden email] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 
 
 If you reply to this email, your message will be added to the discussion
 below:http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p44
 24152.html
 To unsubscribe from Bayesian Hidden Markov Models, click here.
 NAML
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4427000.
 html
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]
 

Oscar M. Rueda, PhD.
Postdoctoral Research Fellow, Breast Cancer Functional Genomics.
Cancer Research UK Cambridge Research Institute.
Li Ka Shing Centre, Robinson Way.
Cambridge CB2 0RE 
England 




NOTICE AND DISCLAIMER
This e-mail (including any attachments) is intended for the above-named 
person(s). If you are not the intended recipient, notify the sender 
immediately, delete this email from your system and do not disclose or use for 
any purpose. 

We may monitor all incoming and outgoing emails in line with current 
legislation. We have taken steps to ensure that this email and attachments are 
free from any virus, but it remains your responsibility to ensure that viruses 
do not adversely affect you. 
Cancer Research UK
Registered in England and Wales
Company Registered Number: 4325234.
Registered Charity Number: 1089464 and Scotland SC041666
Registered Office Address: Angel Building, 407 St John Street, London EC1V 4AD.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] aggregating specific parts in zoo index column to perform sliding average

2012-02-28 Thread Gabor Grothendieck
On Mon, Feb 27, 2012 at 10:17 PM, knavero knav...@gmail.com wrote:
 Here's my code:

 http://pastebin.com/0yRxEVtm

 The important parts are uncommented and should be easy to find using the
 link above. For the following line of code, I plan on looking for a way to
 offset it up 7 rows so that the 15 minute timestamp would be considered the
 median of the subset being averaged to find the mean:

 avgCool = aggregate(intCool, trunc(time(intCool), times(00:15:00)), mean)

 Currently the issue is that, with the truncate function, it truncates but
 really rounds down the time series values to the 15 minute time stamp
 earlier in the series. For example, let's say we have one minute intervals
 0:00, 0:01, 0:02,,0:37. It takes 0:00 - 0:14 and replaces that with
 0:00. Then it sees 0:15, and changes values from 0:15 - 0:29 to 0:15. In
 effect, aggregating the values and creating subsets.

 What I want to do here is change 0:00 - 0:07 to 0:00, change 0:08 - 0:22 to
 0:15, and change 0:23 - 0:37 to 0:30 in which 0:15 and 0:30 are the medians
 of each subset. Anyway, I hope that makes sense. Any ideas on which function
 will make this an easy job? Much thanks in advance.

Add 7.5 minutes before truncating so if x is your times, e.g. x -
times(0:15/(24 * 60)), then try this:

min15 - times(00:15:00)
trunc(x + min15/2, min15)


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] compare two data frames of different dimensions and onlykeep unique rows

2012-02-28 Thread Arnaud Gaboury
TY very much for your setdiffDF(). It does the job perfectly.

Arnaud Gaboury
 
A2CT2 Ltd.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Petr Savicky
Sent: lundi 27 février 2012 20:41
To: r-help@r-project.org
Subject: Re: [R] compare two data frames of different dimensions and onlykeep 
unique rows

On Mon, Feb 27, 2012 at 07:10:57PM +0100, Arnaud Gaboury wrote:
 No, but I tried your way too.
 
 In fact, the only three unique rows are these ones:
 
  Product Price Nbr.Lots
Cocoa  24405
Cocoa  24501
Cocoa  24406
 
 Here is a dirty working trick I found :
 
  df-merge(exportfile,reported,all.y=T)
  df1-merge(exportfile,reported)
  dff1-do.call(paste,df)
  dff-do.call(paste,df)
  dff1-do.call(paste,df1)
  df[!dff %in% dff1,]
   Product Price Nbr.Lots
 3   Cocoa  24405
 4   Cocoa  24501
  
 
 My two problems are : I do think it is not so a clean code, then I won't know 
 by advance which of my two df will have the greates dimension (I can add some 
 lines to deal with it, but again, seems very heavy).

Hi.

Try the following.

  setdiffDF - function(A, B)
  {
  A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ]
  }

  df1 - setdiffDF(reported, exportfile)
  df2 - setdiffDF(exportfile, reported)
  rbind(df1, df2)

I obtained

 Product Price Nbr.Lots
  3Cocoa  24405
  4Cocoa  24501
  31   Cocoa  24406

Is this correct? I see the row

  Cocoa  2440.006

only in exportfile and not in reported.

The trick with paste() is not a bad idea. A variant of it is used also in the 
base function duplicated.matrix(), since it contains

  apply(x, MARGIN, function(x) paste(x, collapse = \r))

If speed is critical, then possibly the paste() trick written for the whole 
columns, for example

  paste(df[[1]], df[[2]], df[[3]], sep=\r)

and then setdiff() can be better.

Hope this helps.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] colour by z value, persp in raster package

2012-02-28 Thread Omphalodes Verna
Hi all!
 
My question is how to colour pixels by z value in persp plot in raster package. 
Here is an example:
 
 
x - seq(-1.95, 1.95, length = 30)
y - seq(-1.95, 1.95, length = 35)
z - outer(x, y, function(a,b) a*b^2)
r1 - raster(nrows=35, ncols=30, xmn=0, xmx=30, ymn = 0, ymx = 35)
r1[] - c(z)
persp(r1)
 
There already exist some function to produce persp plot for anothe classes, but 
I have no idea how deal with RasterLayer object.
 
Thanks all!
 
OV

[[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] kmeans: how to retrieve clusters

2012-02-28 Thread ikuzar
Hi, 

Ok, I understand what you mean.

I wanted to get sorted data group by cluster  in output ...
But I have to do it myself using kres$cluster

thanks for your help

--
View this message in context: 
http://r.789695.n4.nabble.com/kmeans-how-to-retrieve-clusters-tp4426427p4427543.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] Installing package QRMlib

2012-02-28 Thread DT54321
Thanks for the reply guys. Well, I've tried the following command after
installing the package dependancies including timeSeries:

install.packages(file_name, type = source, repos = NULL)
 
Ans still no luck...I get the following error message:

Installing package(s) into ‘C:/Program Files/R/R-2.14.1/library’
(as ‘lib’ is unspecified)
* installing *source* package 'QRMlib' ...
** Creating default NAMESPACE file
** libs
ERROR: compilation failed for package 'QRMlib'
* removing 'C:/Program Files/R/R-2.14.1/library/QRMlib'
* restoring previous 'C:/Program Files/R/R-2.14.1/library/QRMlib'
Warning in install.packages :
  running command 'C:/PROGRA~1/R/R-214~1.1/bin/i386/R CMD INSTALL -l
C:/Program Files/R/R-2.14.1/library   
my_local_folder/QRMlib_1.4.5.1.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘my_local_folder/QRMlib_1.4.5.1.tar.gz’ had
non-zero exit status

Any ideas??

--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4427627.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] Error message: object of type 'closure' is not subsettable

2012-02-28 Thread Aparna Sampath
Hi Josh

Kindly find below the code as it is executed:

test.functional.t - function(res.em1,res.em2,mint,maxt,se.m=0,points=300)
{
  at - seq(mint,maxt,length.out=points)
  by - at[2] - at[1]

  mu1 - spline(x=res.em1$tau,y=res.em1$eta,xout=at,method=natural)$y
l2 - functional.norm(mu1,mu2,by=by)

  s1 - mean(sapply(1:res.em1$n,
function(i)
{
  v -
spline(x=res.em1$tau,y=res.em1$vi[[i]],xout=at,method=natural)$y
  functional.norm(v,by=by)^2
}))
denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n) ### formula for se
  returnValue - l2 / (denominator + se.m)

  attr(returnValue,numerator) - l2
  attr(returnValue,denominator) - denominator

  returnValue
}

moderated.functional.t -
function(testStatistics,alpha.step=0.05,quantile.step=0.01)
{
  numerators - unlist(testStatistics[numerator,])
  denominators - unlist(testStatistics[denominator,])
}

I get my error in the function above moderated.functional.t. testStatistics
is shown to be a function(x) when I type it in R console. But there is no
function definition for testStatistics in the code. My R understanding is
still elementary.

Thanks
Aparna




On Tue, Feb 28, 2012 at 5:25 PM, Joshua Wiley jwiley.ps...@gmail.comwrote:

 Hi Aparna,

 Can you please post a reproducible example?  It is difficult to
 provide much concrete help without having testStatistics.  One thing
 you might try is looking at:

 str(testStatistics[numerator,])

 is it actually a list?  If it is not (most likely given the error) and
 it is supposed to be, you need to figure out what aspect of the
 generation of it is going awry.

 Cheers,

 Josh

 On Tue, Feb 28, 2012 at 12:23 AM, Aparna Sampath
 aparna.sampat...@gmail.com wrote:
  Hi All
 
  I am trying to use the unlist() in R to a list variable.  The following
  statements are within a function.
  {
  denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n)
   returnValue - l2 / (denominator + 11)
   attr(returnValue,numerator) - l2
   attr(returnValue,denominator) - denominator
   returnValue
  }
 
  And when I try to unlist the variable returnValue
 
   numerators - unlist(testStatistics[numerator,])
   denominators - unlist(testStatistics[denominator,])
 
  I get the following error:
 
 Error in testStatistics[numerator, ] :
   object of type 'closure' is not subsettable
 
  I read some threads in R help on this error and they had asked to check
 if
  we are using the right datatype to the right function. But in my case it
 is
  pretty straightforward since I just list it in one function and try to
  unlist it later. Any suggestions?
  Thanks for the help :)
 
  --
  View this message in context:
 http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-not-subsettable-tp3752886p4427399.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.



 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/




-- 
Aparna Sampath
Master of Science (Bioinformatics)
Nanyang Technological University
Mob no : +65 91601854

[[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] Error in solve.default(res$hessian * n.used) :Lapack routine dgesv: system is exactly singular

2012-02-28 Thread Vinicius Magalhães
Hi there!

I´m a noob when it comes to R and I´m using it to run statisc analysis.

With the code for ARIMA below I´m getting this error: Error in
solve.default(res$hessian * n.used) :Lapack routine dgesv: system is
exactly singular

The code is:

 s.ts - ts(x[,7], start = 2004, fre=12)
 get.best.arima - function (x.ts, maxord=c(1,1,1,1,1,1))
+ {
+ best.aic - 1e8
+ n - length(x.ts)
+ for (p in 0:maxord[1]) for (d in 0:maxord[2]) for (q in 0:maxord[3])
+  for (P in 0:maxord[4]) for (D in 0:maxord[5]) for (Q in 0:maxord[6])
+  {
+ fit - arima(x.ts, order=c(p,d,q),
+ seas = list(order=c(P,D,Q),
+ frequency(x.ts)), method = CSS)
+ fit.aic - -2 * fit$loglik + (log(n) + 1) * length(fit$coef)
+ if (fit.aic  best.aic)
+ {
+ best.aic - fit.aic
+ best.fit - fit
+ best.model - c(p,d,q,P,D,Q)
+ }
+ }
+ list(best.aic,best.fit,best.model)
+ }
 best.arima.ss - get.best.arima(log(s.ts),maxord = c(2,2,2,2,2,2))

Error in solve.default(res$hessian * n.used) :
  Lapack routine dgesv: system is exactly singular


 s.ts

 Jan FebMarAprMay
Jun  Jul Aug
2004 143. 160. 205. 180. 160. 160. 155. 160.
2005 148. 185. 195. 195. 175. 175. 170. 165.
2006 188. 203. 213. 198. 180. 180. 190. 188.
2007 168. 200. 210. 185. 175. 190. 190. 193.
2008 167. 190. 210. 205. 190. 190. 200. 175.
   Sep Oct Nov Dec
2004 150. 140. 135. 150.
2005 160. 155. 155. 153.
2006 193. 184. 170. 165.
2007 180. 180. 175. 165.
2008 175. 165. 161.6667 161.6667


-- 
Vinicius Macedo Magalhães
(21) 9584-1533

[[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] Interpreting the Results of GLM

2012-02-28 Thread sazzle
Hi, I'm wondering if you can help me, this is a really simple query but I
keep getting confused.  I have run a GLM to see how boldness varies over
time following a particular treatment.  The results are as follows... 

Call: glm(formula = boldtwentyfour ~ treatment + boldcontrol)
Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-1.7577  -0.5469   0.0456   0.5515   1.5327  
Coefficients:  Estimate Std. Error t value Pr(|t|)  
(Intercept)0.8312 0.5444   1.527   0.1363  
treatmentPBS   0.1391 0.2842   0.490   0.6277  
boldcontrol0.4899 0.2157   2.271   0.0298 *
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
(Dispersion parameter for gaussian family taken to be 0.7131691)
Null deviance: 27.243  on 35  degrees of freedom
Residual deviance: 23.535  on 33  degrees of freedom
AIC: 94.862  Number of Fisher Scoring iterations: 2

Basically, where I am having trouble is that I have several GLMs like this
and need to display the results in a table and am required to display the
intercept, estimates, 95% confidence and the errors.  I am confused as to
which values are which as for the intercept there are four different values
which all seem to relate to everything else I need to report, while
everything else would go unreported.  From this table of output from R can
you help me to identify which value is which? 
Thanks, 
Sarah.


--
View this message in context: 
http://r.789695.n4.nabble.com/Interpreting-the-Results-of-GLM-tp4427732p4427732.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] how to append element at last position in array dynamically

2012-02-28 Thread sagarnikam123
 h-array()
 h
[1] NA
 append(h,9)
[1] NA  9

but what it append.
 h
[1] NA


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-append-element-at-last-position-in-array-dynamically-tp4427893p4427893.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] kmeans: how to retrieve clusters

2012-02-28 Thread R. Michael Weylandt
But it won't be hard at allyou can likely get what you need using
the tapply() function (or ave)

Michael

On Tue, Feb 28, 2012 at 4:33 AM, ikuzar raz...@hotmail.fr wrote:
 Hi,

 Ok, I understand what you mean.

 I wanted to get sorted data group by cluster  in output ...
 But I have to do it myself using kres$cluster

 thanks for your help

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/kmeans-how-to-retrieve-clusters-tp4426427p4427543.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] how to get file name/file path

2012-02-28 Thread sagarnikam123
i open a table
table-read.table(file.choose(),skip=1)

at  sometime i forget which file i open,so i want file name/file path 



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-get-file-name-file-path-tp4428126p4428126.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] macro function

2012-02-28 Thread mrzung
Actually, what I really want to do is that,


annual productivity data(2011)

   firts date  2011-01-01 2011-01-02
 
2011-01-03  2011-01-04  2011-01-05  * *
*
A2011-02-03   0
0 0
0  0 * * *
B2011-01-02   0   
10   11   12
  
13* * *
C2011-04-02   00
  
11   12   13
  
* * *
D2011-02-02   0
0 0
0  0   * * *
E2011-11-020
0 0
0  0  * * *
*
*
*

I have this annual productivity data(2011) and I need to convert this as
D-Day data. That is to say,  I need this form.

 firts date   D-DAYD+1  
 
D+2  D+3D+4 
* * *
A   2011-02-03   0 0

0 0 
0 * * *
B   2011-01-02   010
  
11   12   13
   
* * *
C   2011-04-02   00 
 
11   12   13
  
* * *
D   2011-02-02   0 0

0 0 
0   * * *
E   2011-11-020
0 0
0  0  * * *
  
*
*
*

D-day is the first date and each cells are day-productivity of the day.

how can I make a code for that?

--
View this message in context: 
http://r.789695.n4.nabble.com/macro-function-tp4427385p4428131.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 append element at last position in array dynamically

2012-02-28 Thread R. Michael Weylandt
You need to reassign the value of append back to h -- in more
technical terms, this is a pass-by-value rather than pass-by-reference
behavior:

h - append(h, 9)

This is not likely to be efficient in production code, however.

Michael

On Tue, Feb 28, 2012 at 7:15 AM, sagarnikam123 sagarnikam...@gmail.com wrote:
 h-array()
 h
 [1] NA
 append(h,9)
 [1] NA  9

 but what it append.
 h
 [1] NA


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/how-to-append-element-at-last-position-in-array-dynamically-tp4427893p4427893.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] indexing??

2012-02-28 Thread helin_susam
Hello All,

My algorithm as follows;
y - c(1,1,1,0,0,1,0,1,0,0)
x - c(1,0,0,1,1,0,0,1,1,0)

n - length(x)

t - matrix(cbind(y,x), ncol=2)

z = x+y

for(j in 1:length(x)) {
out - vector(list, )

for(i in 1:10) {

t.s - t[sample(n,n,replace=T),]

y.s - t.s[,1]
x.s - t.s[,2]

z.s - y.s+x.s

out[[i]] - list(ff - (z.s), finding=any (y.s==y[j]))
kk - sapply(out, function(x) {x$finding})
ff - out[! kk]
}

I tried to find the total of the two vectors as statistic by using
bootstrap. Finally, I want to get the values which do not contain the y's
each elemet. In the algorithm ti is referred to ff. But i get always the
same result ;
 ff
list()
 kk
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
Because, my y vector contains only 2 elements, and probably all of the
bootstrap resamples  include 1, or all of resamples include 0. So I can
not find the true matches. Can anyone help me about how to be?
Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/indexing-tp4428210p4428210.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 get file name/file path

2012-02-28 Thread R. Michael Weylandt
Use this line instead:

table - read.table(fileIchoose - file.choose(), skip = 1)

This will have the side effect of creating fileIchoose as a variable
containing a file path.

Michael

On Tue, Feb 28, 2012 at 8:34 AM, sagarnikam123 sagarnikam...@gmail.com wrote:
 i open a table
 table-read.table(file.choose(),skip=1)

 at  sometime i forget which file i open,so i want file name/file path



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/how-to-get-file-name-file-path-tp4428126p4428126.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] Installing package QRMlib

2012-02-28 Thread Pfaff, Bernhard Dr.
As stated, you need to install the *deprecated* dependencies of QRMlib as shown 
in its DESCRIPTION as well as the reverse dependent *deprecated* packages. 
These can still be fetched from R-Forge (Rmetrics project). The package 
'timeSeries' will become a dependency of the to be re-released QRMlib package 
on CRAN.  

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von DT54321
Gesendet: Dienstag, 28. Februar 2012 11:10
An: r-help@r-project.org
Betreff: Re: [R] Installing package QRMlib

Thanks for the reply guys. Well, I've tried the following command after 
installing the package dependancies including timeSeries:

install.packages(file_name, type = source, repos = NULL)
 
Ans still no luck...I get the following error message:

Installing package(s) into ‘C:/Program Files/R/R-2.14.1/library’
(as ‘lib’ is unspecified)
* installing *source* package 'QRMlib' ...
** Creating default NAMESPACE file
** libs
ERROR: compilation failed for package 'QRMlib'
* removing 'C:/Program Files/R/R-2.14.1/library/QRMlib'
* restoring previous 'C:/Program Files/R/R-2.14.1/library/QRMlib'
Warning in install.packages :
  running command 'C:/PROGRA~1/R/R-214~1.1/bin/i386/R CMD INSTALL -l
C:/Program Files/R/R-2.14.1/library   
my_local_folder/QRMlib_1.4.5.1.tar.gz' had status 1 Warning in 
install.packages :
  installation of package ‘my_local_folder/QRMlib_1.4.5.1.tar.gz’ had non-zero 
exit status

Any ideas??

--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4427627.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.
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 append element at last position in array dynamically

2012-02-28 Thread jim holtman
'append' returns a value that you have assign back to the object you
want, in this case 'h'

h - append(h, 9)

On Tue, Feb 28, 2012 at 7:15 AM, sagarnikam123 sagarnikam...@gmail.com wrote:
 h-array()
 h
 [1] NA
 append(h,9)
 [1] NA  9

 but what it append.
 h
 [1] NA


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/how-to-append-element-at-last-position-in-array-dynamically-tp4427893p4427893.html
 Sent from the R help mailing list archive at Nabble.com.

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



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error message: object of type 'closure' is not subsettable

2012-02-28 Thread Petr PIKAL
Hi

Difficult to without knowing what objects you are operating your 
functions.

I get

 test.functional.t(1:10,1:10,3,4)
Error in res.em1$eta : $ operator is invalid for atomic vectors
 moderated.functional.t(1:10)
Error in testStatistics[numerator, ] : incorrect number of dimensions

And without suitable objects for those functions to operate it is 
impossible to come with reasonable suggestion.

Anyway there is a function on your system which is called testStatistics 
and you can not subset functions, hence your error. I did not find this 
function in R pacages but I can not say that it is really not there.

You can get rid of this function by

rm(testStatistics)

Regards
Petr


 
 Kindly find below the code as it is executed:
 
 test.functional.t - 
function(res.em1,res.em2,mint,maxt,se.m=0,points=300)
 {
   at - seq(mint,maxt,length.out=points)
   by - at[2] - at[1]
 
   mu1 - spline(x=res.em1$tau,y=res.em1$eta,xout=at,method=natural)$y
 l2 - functional.norm(mu1,mu2,by=by)
 
   s1 - mean(sapply(1:res.em1$n,
 function(i)
 {
   v -
 spline(x=res.em1$tau,y=res.em1$vi[[i]],xout=at,method=natural)$y
   functional.norm(v,by=by)^2
 }))
 denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n) ### formula for se
   returnValue - l2 / (denominator + se.m)
 
   attr(returnValue,numerator) - l2
   attr(returnValue,denominator) - denominator
 
   returnValue
 }
 
 moderated.functional.t -
 function(testStatistics,alpha.step=0.05,quantile.step=0.01)
 {
   numerators - unlist(testStatistics[numerator,])
   denominators - unlist(testStatistics[denominator,])
 }
 
 I get my error in the function above moderated.functional.t. 
testStatistics
 is shown to be a function(x) when I type it in R console. But there is 
no
 function definition for testStatistics in the code. My R understanding 
is
 still elementary.
 
 Thanks
 Aparna
 
 
 
 
 On Tue, Feb 28, 2012 at 5:25 PM, Joshua Wiley 
jwiley.ps...@gmail.comwrote:
 
  Hi Aparna,
 
  Can you please post a reproducible example?  It is difficult to
  provide much concrete help without having testStatistics.  One thing
  you might try is looking at:
 
  str(testStatistics[numerator,])
 
  is it actually a list?  If it is not (most likely given the error) and
  it is supposed to be, you need to figure out what aspect of the
  generation of it is going awry.
 
  Cheers,
 
  Josh
 
  On Tue, Feb 28, 2012 at 12:23 AM, Aparna Sampath
  aparna.sampat...@gmail.com wrote:
   Hi All
  
   I am trying to use the unlist() in R to a list variable.  The 
following
   statements are within a function.
   {
   denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n)
returnValue - l2 / (denominator + 11)
attr(returnValue,numerator) - l2
attr(returnValue,denominator) - denominator
returnValue
   }
  
   And when I try to unlist the variable returnValue
  
numerators - unlist(testStatistics[numerator,])
denominators - unlist(testStatistics[denominator,])
  
   I get the following error:
  
  Error in testStatistics[numerator, ] :
object of type 'closure' is not subsettable
  
   I read some threads in R help on this error and they had asked to 
check
  if
   we are using the right datatype to the right function. But in my 
case it
  is
   pretty straightforward since I just list it in one function and try 
to
   unlist it later. Any suggestions?
   Thanks for the help :)
  
   --
   View this message in context:
  http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-
 not-subsettable-tp3752886p4427399.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.
 
 
 
  --
  Joshua Wiley
  Ph.D. Student, Health Psychology
  Programmer Analyst II, Statistical Consulting Group
  University of California, Los Angeles
  https://joshuawiley.com/
 
 
 
 
 -- 
 Aparna Sampath
 Master of Science (Bioinformatics)
 Nanyang Technological University
 Mob no : +65 91601854
 
[[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] indexing??

2012-02-28 Thread Petr PIKAL
Hi

 
 My algorithm as follows;
 y - c(1,1,1,0,0,1,0,1,0,0)
 x - c(1,0,0,1,1,0,0,1,1,0)
 
 n - length(x)
 
 t - matrix(cbind(y,x), ncol=2)

Do not use t, it is a function for transposing matrix and after you 
redefine it you can get nasty surprise in future.

tt - cbind(y,x)

is enough

 
 z = x+y
 
 for(j in 1:length(x)) {
 out - vector(list, )
 
 for(i in 1:10) {
 
 t.s - t[sample(n,n,replace=T),]

t.s - tt[sample(n,n,replace=T),]

 
 y.s - t.s[,1]
 x.s - t.s[,2]
 
 z.s - y.s+x.s
 
 out[[i]] - list(ff - (z.s), finding=any (y.s==y[j]))

Here you compare vector y.s with one element of y as y.s is set of (0,1) 
values y is either 0 or 1, any tests if there is any match so only in rare 
case where all values in y.s are 0 and y[something] is 1 you get FALSE

 kk - sapply(out, function(x) {x$finding})

finding is (almost) always TRUE therefore kk is TRUE

 ff - out[! kk]
 }
 


 I tried to find the total of the two vectors as statistic by using
 bootstrap. Finally, I want to get the values which do not contain the 
y's
 each elemet. In the algorithm ti is referred to ff. But i get always 
the
 same result ;

I do not understand your intention so it is difficult to help. What is 
total of two vectors? sum?

What does it mean to get values which do not contain y's each element? 

Maybe you shall rethink your code and first try to evaluate each line 
separately to see what it does and if the result is same as you intended.

Regards
Petr


  ff
 list()
  kk
  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 Because, my y vector contains only 2 elements, and probably all of the
 bootstrap resamples  include 1, or all of resamples include 0. So I 
can
 not find the true matches. Can anyone help me about how to be?
 Thanks.
 
 --
 View this message in context: http://r.789695.n4.nabble.com/indexing-
 tp4428210p4428210.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] macro function

2012-02-28 Thread Petr PIKAL
Hi

Your mail is quite messy. what is ***? How your data are structured?

str(your.data)

Please submit part of your data by

dput(your.data)

and show what the output shall be.

Regards
Petr

 
 Actually, what I really want to do is that,
 
  
 annual productivity data(2011)
 
firts date  2011-01-01 2011-01-02 
 
 2011-01-03  2011-01-04  2011-01-05 * *
 *
 A2011-02-03   0  
 0 0  
 0  0 * * *
 B2011-01-02   0  
 10   11  
 12 
 13* * *
 C2011-04-02   0  
 0 
 11   12  
 13 
 * * *
 D2011-02-02   0  
 0 0  
 0  0   * * *
 E2011-11-020  
 0 0  
 0  0  * * *
 *
 *
 *
 
 I have this annual productivity data(2011) and I need to convert this 
as
 D-Day data. That is to say,  I need this form.
 
  firts date   D-DAY D+1 
 D+2  D+3 D+4 
 * * *
 A   2011-02-03   0  
 0 
 0 0  
 0 * * *
 B   2011-01-02   0  
 10 
 11   12  
 13 
 * * *
 C   2011-04-02   0  
 0 
 11   12  
 13 
 * * *
 D   2011-02-02   0  
 0 
 0 0  
 0   * * *
 E   2011-11-020  
 0 0  
 0  0  * * *
 
 *
 *
 *
 
 D-day is the first date and each cells are day-productivity of the 
day.
 
 how can I make a code for that?
 
 --
 View this message in context: http://r.789695.n4.nabble.com/macro-
 function-tp4427385p4428131.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] indexing??

2012-02-28 Thread Petr Savicky
On Tue, Feb 28, 2012 at 05:59:24AM -0800, helin_susam wrote:
 Hello All,
 
 My algorithm as follows;
 y - c(1,1,1,0,0,1,0,1,0,0)
 x - c(1,0,0,1,1,0,0,1,1,0)
 
 n - length(x)
 
 t - matrix(cbind(y,x), ncol=2)
 
 z = x+y
 
 for(j in 1:length(x)) {
 out - vector(list, )
 
 for(i in 1:10) {
 
 t.s - t[sample(n,n,replace=T),]
 
 y.s - t.s[,1]
 x.s - t.s[,2]
 
 z.s - y.s+x.s
 
 out[[i]] - list(ff - (z.s), finding=any (y.s==y[j]))
 kk - sapply(out, function(x) {x$finding})
 ff - out[! kk]
 }
 
 I tried to find the total of the two vectors as statistic by using
 bootstrap. Finally, I want to get the values which do not contain the y's
 each elemet. In the algorithm ti is referred to ff. But i get always the
 same result ;
  ff
 list()
  kk
  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 Because, my y vector contains only 2 elements, and probably all of the
 bootstrap resamples  include 1, or all of resamples include 0. So I can
 not find the true matches. Can anyone help me about how to be?

Hi.

First of all, there are some unclear points in your code.
In particular, i would expect } between the line

  out[[i]] - list(...

and

  kk - sapply(...

Moreover, i do not see, why the loop over j contains the
loop over i. I would expect these loops be disjoint,
since the loop over i collects all the samples to a list.

The following code is a modification, which i suggest
as an alternative.

  y - c(1:5, 1:5)
  x - c(1,0,0,1,1,0,0,1,1,0)
 
  n - length(x)
 
  t - matrix(cbind(y,x), ncol=2)
 
  z = x+y
 
  # generate 10 bootstrap samples and keep z.s, y.s
  out - vector(list, 10)
  for(i in 1:10) {
t.s - t[sample(n,n,replace=T),]
y.s - t.s[,1]
x.s - t.s[,2]
z.s - y.s+x.s
out[[i]] - list(zz = z.s, yy =y.s)
  }

  # check, which replications do not contain y[j] in their y.s,
  # and take the OR of these conditions over j
  ff - rep(FALSE, times=length(out))
  for(j in 1:length(y)) {
 kk - sapply(out, function(x) {any(x$yy == y[j])})
 ff - ff | (! kk)
  }
  out[ff]

With the original y - c(1,1,1,0,0,1,0,1,0,0), the probability
that a bootstrap sample contains only 1's or only 0's is
2 * (1/2)^10, so i replaced the vector y with another, where
a missing value is more frequent. I obtained, for example

  [[1]]
  [[1]]$zz
   [1] 2 2 5 2 3 2 3 2 2 6
  
  [[1]]$yy
   [1] 1 1 5 1 3 2 3 2 1 5   # 4 is missing
  
  
  [[2]]
  [[2]]$zz
   [1] 5 5 5 5 3 5 2 5 6 4
  
  [[2]]$yy
   [1] 4 4 5 4 3 5 2 5 5 3  # 1 is missing
  
  
  [[3]]
  [[3]]$zz
   [1] 5 2 5 1 5 1 2 5 5 5
  
  [[3]]$yy
   [1] 4 2 5 1 5 1 1 4 5 4  # 3 is missing
 
Hope this helps.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Installing package QRMlib

2012-02-28 Thread jthetzel
I think you'll need to install fEcofin from CRAN, and then the following
.tar.gz files from the CRAN archives:
fUtilities
fCalenday
fSeries

And then try installing the QRMlib .tar.gz.

If you're still having problems, try: 
C:/Program Files/R/R-2.14.0/bin/x64/R CMD check QRMlib_1.4.5.1.tar.gz
(or whatever is equivalent for your R installation) from the Windows command
prompt .  That will output more useful information on errors and warnings.


Jeremy


Jeremy Hetzel
Boston University



Pfaff, Bernhard Dr. wrote
 
 As stated, you need to install the *deprecated* dependencies of QRMlib as
 shown in its DESCRIPTION as well as the reverse dependent *deprecated*
 packages. These can still be fetched from R-Forge (Rmetrics project). The
 package 'timeSeries' will become a dependency of the to be re-released
 QRMlib package on CRAN.  
 
 -Ursprüngliche Nachricht-
 Von: r-help-bounces@ [mailto:r-help-bounces@] Im Auftrag von DT54321
 Gesendet: Dienstag, 28. Februar 2012 11:10
 An: r-help@
 Betreff: Re: [R] Installing package QRMlib
 
 Thanks for the reply guys. Well, I've tried the following command after
 installing the package dependancies including timeSeries:
 
 install.packages(file_name, type = source, repos = NULL)
  
 Ans still no luck...I get the following error message:
 
 Installing package(s) into ‘C:/Program Files/R/R-2.14.1/library’
 (as ‘lib’ is unspecified)
 * installing *source* package 'QRMlib' ...
 ** Creating default NAMESPACE file
 ** libs
 ERROR: compilation failed for package 'QRMlib'
 * removing 'C:/Program Files/R/R-2.14.1/library/QRMlib'
 * restoring previous 'C:/Program Files/R/R-2.14.1/library/QRMlib'
 Warning in install.packages :
   running command 'C:/PROGRA~1/R/R-214~1.1/bin/i386/R CMD INSTALL -l
 C:/Program Files/R/R-2.14.1/library   
 my_local_folder/QRMlib_1.4.5.1.tar.gz' had status 1 Warning in
 install.packages :
   installation of package ‘my_local_folder/QRMlib_1.4.5.1.tar.gz’ had
 non-zero exit status
 
 Any ideas??
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4427627.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 *
 Confidentiality Note: The information contained in this message,
 and any attachments, may contain confidential and/or privileged
 material. It is intended solely for the person(s) or entity to
 which it is addressed. Any review, retransmission, dissemination,
 or taking of any action in reliance upon this information by
 persons or entities other than the intended recipient(s) is
 prohibited. If you received this in error, please contact the
 sender and delete the material from any computer.
 *
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

-
Jeremy T. Hetzel
Boston University
--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4428517.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] vlookup type function

2012-02-28 Thread Priyan Fernando
Hi

I''m looking for an Excel Vlookup type function in R.

Example:
list - c(1,2,3,4,5,6,7)
base - c(2.2,3,5.2)

What I want is, for each number in base, the highest value in list,
which is equal to or less than the number in base

So the results would be:

base         list
2.2  -- 2
3    -- 3
5.2  --  5

Thanks for your help!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cluster GUI package worth publishing/enhancing?

2012-02-28 Thread Todd Gillette
For a school course I and a partner developed a GUI in R designed to
enable exploration of data via visualization of hierarchical
clustering and correlation of cluster partitions with external
metadata. The key features were the ability to load in a distance
matrix (most GUI-based clustering programs require feature vector
input), and the ability to dynamically subset the data via the GUI
built using a user-provided meta data file. I didn't think this was
sufficient to publish a package, but it did seem like it could make
for a good foundation. I so far have not come across other software
that provides all of these features. I was hoping to get initial
feedback in terms of whether anyone thought this, with or without
certain enhancements, might be worthwhile. For a sense of what the
existing tool looks like and what it does:
http://mason.gmu.edu/~tgillett/R_Cluster_GUI/RClusterGUI.html

We intend to extend the tool to enable feature vector input,
additional forms of visualization beyond cluster dendrogram,
multidimensional scaling of distance matrix input, internal and
external cluster statistics (e.g. Davies-Bouldin index, Rand index),
random subsampling of data to account for the instability of clusters,
and non-hierarchical clustering methods. Obviously a well-organized
GUI is important, and we would seek out feedback and perhaps partner
developers.

I'd appreciate any direct feedback here, or suggestions of more
appropriate forums for getting feedback and having a discussion on the
topic.

Thank you,
Todd Gillette

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vlookup type function

2012-02-28 Thread Petr Savicky
On Tue, Feb 28, 2012 at 09:02:04PM +0530, Priyan Fernando wrote:
 Hi
 
 I''m looking for an Excel Vlookup type function in R.
 
 Example:
 list - c(1,2,3,4,5,6,7)
 base - c(2.2,3,5.2)
 
 What I want is, for each number in base, the highest value in list,
 which is equal to or less than the number in base
 
 So the results would be:
 
 base         list
 2.2  -- 2
 3    -- 3
 5.2  --  5

Hi.

Try the following.

  unlist(lapply(base, FUN = function(x) max(list[list = x])))

Hope this helps.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vlookup type function

2012-02-28 Thread Berend Hasselman

On 28-02-2012, at 16:32, Priyan Fernando wrote:

 Hi
 
 I''m looking for an Excel Vlookup type function in R.
 
 Example:
 list - c(1,2,3,4,5,6,7)
 base - c(2.2,3,5.2)
 
 What I want is, for each number in base, the highest value in list,
 which is equal to or less than the number in base
 
 So the results would be:
 
 base list
 2.2  -- 2
 3-- 3
 5.2  --  5

Don't use list as an object name. It is a standard R function.

vlist - c(1,2,3,4,5,6,7)
base - c(2.2,3,5.2)

findInterval(base, vlist)

Berend

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vlookup type function

2012-02-28 Thread William Dunlap
findInterval returns the index (into list) of what
you want.  Use [ to get the numbers at the bottom of
the found intervals:

   list - c(1,2,3,4,5,6,7)
   base - c(2.2,3,5.2)
   findInterval(base, list)
  [1] 2 3 5
   findInterval(base+100, list+100)
  [1] 2 3 5
   (list+100)[.Last.value]
  [1] 102 103 105

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 Priyan Fernando
 Sent: Tuesday, February 28, 2012 7:32 AM
 To: r-help@r-project.org
 Subject: [R] vlookup type function
 
 Hi
 
 I''m looking for an Excel Vlookup type function in R.
 
 Example:
 list - c(1,2,3,4,5,6,7)
 base - c(2.2,3,5.2)
 
 What I want is, for each number in base, the highest value in list,
 which is equal to or less than the number in base
 
 So the results would be:
 
 base         list
 2.2  -- 2
 3    -- 3
 5.2  --  5
 
 Thanks for your help!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] vlookup type function

2012-02-28 Thread Petr Savicky
On Tue, Feb 28, 2012 at 09:02:04PM +0530, Priyan Fernando wrote:
 Hi
 
 I''m looking for an Excel Vlookup type function in R.
 
 Example:
 list - c(1,2,3,4,5,6,7)
 base - c(2.2,3,5.2)
 
 What I want is, for each number in base, the highest value in list,
 which is equal to or less than the number in base
 
 So the results would be:
 
 base         list
 2.2  -- 2
 3    -- 3
 5.2  --  5

Hi.

If base may contain numbers smaller than all numbers in list,
the the following modification of the previous suggestion does
not generate a warning.

  list - c(1,2,3,4,5,6,7)
  base - c(0, 2.2, 3, 5.2, 8)
  unlist(lapply(base, FUN=function(x) max(list[list = x], -Inf)))

  [1] -Inf2357

Hope this helps.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Installing package QRMlib

2012-02-28 Thread DT54321
According to the QRMlib package pdf, 

http://www.mirrorservice.org/sites/lib.stat.cmu.edu/R/CRAN/doc/packages/QRMlib.pdf

the package depennds on methods, fCalendar, fEcofin, mvtnorm,
chron,its,Hmisc. I have installed all of these (some were retrieved from
archive and some were retrieved from CRAN) and still getting errors.

I'm just wondering whether anyone has successfully loaded QRMlib??

--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4428600.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] Volcano Plot

2012-02-28 Thread aishsk
Hi I am using the ggplot2 package for the volcano plot and I am using the
following code for the same:

g = ggplot(data=data, aes(x=data[11], y=-log10(data[12]), colour=threshold))
+
+   geom_point(alpha=0.4, size=1.75) +
+   opts(legend.position = none) +
+   xlim(c(-10, 10)) + ylim(c(0, 15)) +
+   xlab(log2 fold change) + ylab(-log10 p-value)

data[11] is a column of the fold change values and data[12] contains the P
values and I am getting a following error:

Error: geom_point requires the following missing aesthetics: x, y
 What can be done for the same ? 
And if not what other package may I use for the same in which I don't have
to use a lmfit model?
Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Volcano-Plot-tp4428622p4428622.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] Table into a list

2012-02-28 Thread Alemtsehai Abate
Perhaps, the following does it as well.

(d - data.frame(x1=letters[2*1:4 - 1], x2=letters[2*1:4]))

c(t(d))


Alemtsehai




 Hello,
 I am looking for a way to transform an array into a list (or a string).
 My array has two columns 1 and 2, and I would like to create a list of
the
 values.

 Let's say I have :

   x1   x2
 1  a  b
 2  c  d
 3  e  f
 4  g  h

 What I would like to obtain is a,b,c,d,e,f,g,h.

 I tried without success melt and reshape ( reshape(my_array,
 direction=long, varying=1:2) ) but I cannot get it work.

 Thanks a lot !!!
 thomas

[[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] Off Topic: Lowess on Yahoo

2012-02-28 Thread Bert Gunter
Folks:

Graphics afficianados might enjoy this link (although conditional
probability is also mentioned!):

http://news.yahoo.com/blogs/signal/republican-nomination-extends-march-candidates-face-weakening-odds-152347629.html

Pay attention to the graph. Never thought I'd see the phrase lowess
trend on Yahoo.

It looks like the graphs could have actually been drawn in R. Does
anyone no whether or not this is so?

Cheers,
Bert

-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dotplot edition

2012-02-28 Thread Jose Bustos Melo
Hi everyone,
Im very new with R and I would like to change the size text (names) in the ylab 
in a dotplot. I have checked many webpages and R sites,  but I have not found 
any help.
This is the same structure of the plot in R graph Gallery: 
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=150

thanks in thanks is advance
José



Mi code is this:

### setup the key
k - simpleKey( c( Perdidas ,  Contestadas ) )
k$points$fill - c(lightblue, lightgreen)
k$points$pch - 21
k$points$col - black
k$points$cex - 1

cliente100RD- cliente100[order(cliente100$porc_perd),]

### create the plot
dotplot( rownames(cliente100RD) ~ perdida + contestada , data = cliente100RD, 
horiz = T,
 main=Llamadas Enero 2012: RM,sub=Clientes ROI,
    par.settings = list( 
        superpose.symbol = list( 
            pch = 21, 
            fill = c( lightblue, lightgreen), 
            cex = 2, 
            col = black  
        )
     ) , xlab = n° de llamadas, key = k, 
     panel = function(x, y, ...){
       panel.dotplot( x, y, ... )
       grid.text( 
               unit( x, native) , unit( y, native) , 
            label = x, gp = gpar( cex = .5 ) )
     } ) 

###
[[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] Installing package QRMlib

2012-02-28 Thread DT54321
In command prompt, I direct to the following directory:

C:\Program Files\R\R-2.14.1\bin

Now I enter:

R CMD check my_local_folder\QRMlib_1.4.5.1.tar.gz

The following appears:

* using log directory 'C:/Program Files/R/R-2.14.1/bin/QRMlib.Rcheck'
* using R version 2.14.1 (2011-12-22)
* using platform: i386-pc-mingw32 (32-bit)
* using session charset: ISO8859-1
* checking for file 'QRMlib/DESCRIPTION' ... OK
* this is package 'QRMlib' version '1.4.5.1'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... NOTE
As from R 2.14.0 all packages need a namespace.
One will be generated on installation, but it is better to handcraft a
NAMESPACE file: R CMD build will produce a suitable starting point.
* checking for .dll and .exe files ... OK
* checking whether package 'QRMlib' can be installed ... ERROR
Installation failed.
See 'C:/Program Files/R/R-2.14.1/bin/QRMlib.Rcheck/00install.out' for
details.



--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4428988.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] indexing??

2012-02-28 Thread helin_susam
Dear Petr Pikal and Petr Savicky thank you for your replies..

If the y vector contains different elements my algorithm gives this result;
y - c(1,2,3,4,5,6,7,8,9,10) 
x - c(1,0,0,1,1,0,0,1,1,0) 

n - length(x) 

t - matrix(cbind(y,x), ncol=2) 

z = x+y 

for(j in 1:length(x)) { 
out - vector(list, ) 

for(i in 1:10) { 

t.s - t[sample(n,n,replace=T),] 

y.s - t.s[,1] 
x.s - t.s[,2] 

z.s - y.s+x.s 

out[[i]] - list(ff - (z.s), finding=any (y.s==y[j])) 
kk - sapply(out, function(x) {x$finding}) 
ff - out[! kk] 
} 
}

 kk
 [1]  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE
 ff
[[1]]
[[1]][[1]]
 [1] 5 7 3 2 2 6 7 2 6 6

[[1]]$finding
[1] FALSE


[[2]]
[[2]][[1]]
 [1]  7 10  6  2  2  2  6  6  9  3

[[2]]$finding
[1] FALSE

Here, the two situations are FALSE, that is 5th and 10th bootstrap
re-samples do not contain one (or more) element(s) of original vector (y). 

How can I get the similar result when the y vector includes the only
response variable (1 or 0) ? That is
y - c(1,1,1,0,0,1,0,1,0,0) 

Many thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/indexing-tp4428210p4428746.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] Installing package QRMlib

2012-02-28 Thread jthetzel
Next, you should check C:/Program
Files/R/R-2.14.1/bin/QRMlib.Rcheck/00install.out for details on the error.


DT54321 wrote
 
 In command prompt, I direct to the following directory:
 
 C:\Program Files\R\R-2.14.1\bin
 
 Now I enter:
 
 R CMD check my_local_folder\QRMlib_1.4.5.1.tar.gz
 
 The following appears:
 
 * using log directory 'C:/Program Files/R/R-2.14.1/bin/QRMlib.Rcheck'
 * using R version 2.14.1 (2011-12-22)
 * using platform: i386-pc-mingw32 (32-bit)
 * using session charset: ISO8859-1
 * checking for file 'QRMlib/DESCRIPTION' ... OK
 * this is package 'QRMlib' version '1.4.5.1'
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking if there is a namespace ... NOTE
 As from R 2.14.0 all packages need a namespace.
 One will be generated on installation, but it is better to handcraft a
 NAMESPACE file: R CMD build will produce a suitable starting point.
 * checking for .dll and .exe files ... OK
 * checking whether package 'QRMlib' can be installed ... ERROR
 Installation failed.
 See 'C:/Program Files/R/R-2.14.1/bin/QRMlib.Rcheck/00install.out' for
 details.
 

-
Jeremy T. Hetzel
Boston University
--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4429041.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] macro function

2012-02-28 Thread mrzung
I really appreciate to your attention.

I want to change the data form A into B


http://r.789695.n4.nabble.com/file/n4428807/1.png 


http://r.789695.n4.nabble.com/file/n4428807/2.png 


In fact, there are 1095 column in data A. 
Specifically, variable publish_day is when some book in the same row is
published and 
D-1, D-2 means the term after the publish day.
Of course, the cells in data mean productivity in the day.

What can be effecient way to do it?



--
View this message in context: 
http://r.789695.n4.nabble.com/macro-function-tp4427385p4428807.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] Installing package QRMlib

2012-02-28 Thread jthetzel
I installed fEcofin, fUtilities, fCalenday, and fSeries from the CRAN
archives and was able to install and load QRMlib.

Which errors does R CMD check QRMlib_1.4.5.1.tar.gz show?



DT54321 wrote
 
 According to the QRMlib package pdf, 
 
 http://www.mirrorservice.org/sites/lib.stat.cmu.edu/R/CRAN/doc/packages/QRMlib.pdf
 
 the package depennds on methods, fCalendar, fEcofin, mvtnorm,
 chron,its,Hmisc. I have installed all of these (some were retrieved from
 archive and some were retrieved from CRAN) and still getting errors.
 
 I'm just wondering whether anyone has successfully loaded QRMlib??
 

-
Jeremy T. Hetzel
Boston University
--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4428842.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] macro function

2012-02-28 Thread Rui Barradas
Hello,

Is it just a columns names issue?
Try (DF is your data, 'A' or other data.frame)


# colNames - colnames(DF)
colNames - c(name, publish day, 2011-01-01, 2011-01-02,
2011-01-03, 2011-01-04, 2011-01-05)
x - as.Date(colNames[-(1:2)])
x
[1] 2011-01-01 2011-01-02 2011-01-03 2011-01-04 2011-01-05

y - difftime(x[-1], x[1], units=days)
y - as.integer(y)
y
[1] 1 2 3 4

colNames[3] - D-Day
colNames[-(1:3)] - paste(D, y, sep=+)
colNames
[1] namepublish day D-Day   D+1 D+2
[6] D+3 D+4
# colnames(DF) - colNames

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/macro-function-tp4427385p4429055.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] indexing??

2012-02-28 Thread Petr Savicky
On Tue, Feb 28, 2012 at 08:50:45AM -0800, helin_susam wrote:
 Dear Petr Pikal and Petr Savicky thank you for your replies..
 
 If the y vector contains different elements my algorithm gives this result;
 y - c(1,2,3,4,5,6,7,8,9,10) 
 x - c(1,0,0,1,1,0,0,1,1,0) 
 
 n - length(x) 
 
 t - matrix(cbind(y,x), ncol=2) 
 
 z = x+y 
 
 for(j in 1:length(x)) { 
 out - vector(list, ) 
 
 for(i in 1:10) { 
 
 t.s - t[sample(n,n,replace=T),] 
 
 y.s - t.s[,1] 
 x.s - t.s[,2] 
 
 z.s - y.s+x.s 
 
 out[[i]] - list(ff - (z.s), finding=any (y.s==y[j])) 
 kk - sapply(out, function(x) {x$finding}) 
 ff - out[! kk] 
 } 
 }

Hi.

It is hard to debug a code, which we do not understand.
Both me and Petr Pikal expressed objections against your
code. It would help us to reply your question, if you take
our objections and suggestions into account or explain,
what we do not understand well.

Can you comment on the suggestions from the previous emails?

I would like to add one more. Why do you use

  ff - (z.s)

inside

  out[[i]] - list(ff - (z.s), finding=any (y.s==y[j]))

?

This expression includes the value into the list, but not
under the name ff and rewrites the global variable ff instead.

If you want to include (z.s) as a component named as ff, then use 

  list(ff = (z.s), finding...

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dotplot edition

2012-02-28 Thread Patrick Connolly
There seems to be a clash of character sets so I can't see just what
you're trying to do, but I think you'll find out how to adjust the
text size with a scales list.  Check out how it's used in the help for
xyplot.


HTH

On Tue, 28-Feb-2012 at 06:05PM +, Jose Bustos Melo wrote:

| Hi everyone,
| Im very new with R and I would like to change the size text (names) in the 
ylab in a dotplot. I have checked many webpages and R sites,? but I have not 
found any help.
| This is the same structure of the plot in R graph Gallery: 
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=150
| 
| thanks in thanks is advance
| Jos?
| 
| 
| 
| Mi code is this:
| 
| ### setup the key
| k - simpleKey( c( Perdidas ,? Contestadas ) )
| k$points$fill - c(lightblue, lightgreen)
| k$points$pch - 21
| k$points$col - black
| k$points$cex - 1
| 
| cliente100RD- cliente100[order(cliente100$porc_perd),]
| 
| ### create the plot
| dotplot( rownames(cliente100RD) ~ perdida + contestada , data = 
cliente100RD, horiz = T,
| ?main=Llamadas Enero 2012: RM,sub=Clientes ROI,
| ??? par.settings = list( 
| ??? ??? superpose.symbol = list( 
| ??? ??? ??? pch = 21, 
| ??? ??? ??? fill = c( lightblue, lightgreen), 
| ??? ??? ??? cex = 2, 
| ??? ??? ??? col = black? 
| ??? ??? )
| ??? ?) , xlab = n? de llamadas, key = k, 
| ??? ?panel = function(x, y, ...){
| ??? ?? panel.dotplot( x, y, ... )
| ??? ?? grid.text( 
| ??? ?? ??? ??? unit( x, native) , unit( y, native) , 
| ??? ??? ??? label = x, gp = gpar( cex = .5 ) )
| ??? ?} ) 
| 
| ###
|  [[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.


-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] update.formula has 512 char buffer?

2012-02-28 Thread Chris Hane
Hello,

I am trying to paste together a formula to use in the mob function of
party. This means the formula will be of the form y ~ x1+ ...+xM | z1+..zN.

I am doing some preliminary fits of y ~ x1+ ...+xM, then want to add the
conditional part of the equation using update().

Here's the test code:
var1 - 1:78
x1 - paste(x, var1, sep=)
f1 - paste(f, var1[1:10], sep=)

# use first 77 variables
fmla - as.formula( paste(y ~ , paste(x1[1:77], collapse= + , sep=),
sep=))
fmla2 - update(fmla, paste(. ~ . | , paste(f1, collapse=  + ), sep=))

# CHANGE x to all 78 variables
fmla - as.formula( paste(y ~ , paste(x1, collapse= + , sep=),
sep=))
fmla2 - update(fmla, paste(. ~ . | , paste(f1, collapse=  + ), sep=))

I have run this in Windows and Linux (64 bit) and both fail when using all
78 terms (and anything more than 78 terms). The error message contains
Error in parse(text = x) : :1:514: unexpected ')'.

Changing the length of the names of the x variables will break the update()
with fewer variables, but always with an error referring to just more than
512 characters.  There is nothing special about 77 or 78 variables here; I
want to do this with hundreds of variables.

Is there a workaround to this?

[[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] indexing??

2012-02-28 Thread Petr Savicky
On Tue, Feb 28, 2012 at 08:50:45AM -0800, helin_susam wrote:
 Dear Petr Pikal and Petr Savicky thank you for your replies..
 
 If the y vector contains different elements my algorithm gives this result;
 y - c(1,2,3,4,5,6,7,8,9,10) 
 x - c(1,0,0,1,1,0,0,1,1,0) 
 
 n - length(x) 
 
 t - matrix(cbind(y,x), ncol=2) 
 
 z = x+y 
 
 for(j in 1:length(x)) { 
 out - vector(list, ) 
 
 for(i in 1:10) { 
 
 t.s - t[sample(n,n,replace=T),] 
 
 y.s - t.s[,1] 
 x.s - t.s[,2] 
 
 z.s - y.s+x.s 
 
 out[[i]] - list(ff - (z.s), finding=any (y.s==y[j])) 
 kk - sapply(out, function(x) {x$finding}) 
 ff - out[! kk] 
 } 
 }
 
  kk
  [1]  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE
  ff
 [[1]]
 [[1]][[1]]
  [1] 5 7 3 2 2 6 7 2 6 6
 
 [[1]]$finding
 [1] FALSE
 
 
 [[2]]
 [[2]][[1]]
  [1]  7 10  6  2  2  2  6  6  9  3
 
 [[2]]$finding
 [1] FALSE
 
 Here, the two situations are FALSE, that is 5th and 10th bootstrap
 re-samples do not contain one (or more) element(s) of original vector (y). 

Hi.

Your code generates a new list out for each j. This means
that you generate a list out, test the presence of y[1]
in its components, then delete out, replace it by a new
list and test the presence of y[2] in this new list, then
out is deleted and replaced by another out, etc.

This is probably not, what you want. Is this correct?

Petr Savicky.

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


Re: [R] data analysis

2012-02-28 Thread David Winsemius


On Feb 28, 2012, at 4:16 AM, Hans Ekbrand wrote:


On Mon, Feb 27, 2012 at 11:04:13PM -0800, nontokozo mhlanga wrote:
Please assist me with  all the tests including risk factor analysis  
i  can
use to analyse the enclosed database established from a  
questionnaire survey

to test for the prevalence of tuberculosis in humans .


That's quite a general request. I think you should try to formulate a
specific question.

Have you read the posting-guide? http://www.R-project.org/posting-guide.html


Yes.



Also, I don't think the list accepts attached files.



That last statement is incorrect, but there are specific requirements.  
Generally mail clients will send .txt, .png, .pdf. and .ps files with  
the proper mime type so that the mail server will accept.



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


[R] Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names

2012-02-28 Thread Ben Ganzfried
Hey,

I just googled my error and many things came up.  I followed the leads and
read the ?read.delim page; I tried changing header = TRUE, and row.names =
TRUE-- but I've still been having trouble fixing it, so I would greatly
appreciate any help you can provide.  Here is my code:

rm(list=ls())
source(../../functions.R)

uncurated - read.csv(../uncurated/GSE3141_full_pdata.csv, as.is
=TRUE,row.names=1)
celfile.dir - ../../../DATA/GSE3141/RAW

##initial creation of curated dataframe
curated - initialCuratedDF(rownames(uncurated),
template.filename=template.csv)


The error occurs when I run this line:
 curated - initialCuratedDF(rownames(uncurated),
template.filename=template.csv)
Error in read.table(file = file, header = header, sep = sep, quote = quote,
 :
  more columns than column name


I would greatly appreciate any help.

Thanks!

Ben

[[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] update.formula has 512 char buffer?

2012-02-28 Thread Bert Gunter
Your code seems to be screwed up. There are no (small) size
limitations on formulas (afaik).

The following worked fine for me:

x - paste(x,1:100,sep=,collapse =  + )
part1 - paste(y,x,sep= ~ )
part2 - paste(f,1:50, sep=,collapse =  + )
fml - formula(paste(part1,part2,sep= | ))

Cheers,
Bert

On Tue, Feb 28, 2012 at 11:11 AM, Chris Hane
christopher.a.h...@gmail.com wrote:
 Hello,

 I am trying to paste together a formula to use in the mob function of
 party. This means the formula will be of the form y ~ x1+ ...+xM | z1+..zN.

 I am doing some preliminary fits of y ~ x1+ ...+xM, then want to add the
 conditional part of the equation using update().

 Here's the test code:
 var1 - 1:78
 x1 - paste(x, var1, sep=)
 f1 - paste(f, var1[1:10], sep=)

 # use first 77 variables
 fmla - as.formula( paste(y ~ , paste(x1[1:77], collapse= + , sep=),
 sep=))
 fmla2 - update(fmla, paste(. ~ . | , paste(f1, collapse=  + ), sep=))

 # CHANGE x to all 78 variables
 fmla - as.formula( paste(y ~ , paste(x1, collapse= + , sep=),
 sep=))
 fmla2 - update(fmla, paste(. ~ . | , paste(f1, collapse=  + ), sep=))

 I have run this in Windows and Linux (64 bit) and both fail when using all
 78 terms (and anything more than 78 terms). The error message contains
 Error in parse(text = x) : :1:514: unexpected ')'.

 Changing the length of the names of the x variables will break the update()
 with fewer variables, but always with an error referring to just more than
 512 characters.  There is nothing special about 77 or 78 variables here; I
 want to do this with hundreds of variables.

 Is there a workaround to this?

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] colour by z value, persp in raster package

2012-02-28 Thread David Winsemius


On Feb 28, 2012, at 4:34 AM, Omphalodes Verna wrote:


Hi all!

My question is how to colour pixels by z value in persp plot in  
raster package. Here is an example:



x - seq(-1.95, 1.95, length = 30)
y - seq(-1.95, 1.95, length = 35)
z - outer(x, y, function(a,b) a*b^2)
r1 - raster(nrows=35, ncols=30, xmn=0, xmx=30, ymn = 0, ymx = 35)
r1[] - c(z)
persp(r1)

There already exist some function to produce persp plot for anothe  
classes, but I have no idea how deal with RasterLayer object.


Is that really an example? After going to the trouble of correcting  
the error in this code from failing to load the raster package, I now  
see that there is no connection between the values of x, y, or x with  
the raster-call.


 r1[] - as.matrix(z)
Error in .local(x, values) : cannot use a matrix with these dimensions
Error in .local(x, i, j, ..., value) :
cannot replace values on this raster (it is too large
 persp(r1)
Error: hasValues(x) is not TRUE

#   Post some useful 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] memory management

2012-02-28 Thread Sam Steingold
My basic worry is that the GC does not work properly,
i.e., the unreachable data is never collected.

 * Bert Gunter thagre.ore...@trar.pbz [2012-02-27 14:35:14 -0800]:

 This appears to be the sort of query that (with apologies to other R
 gurus) only Brian Ripley or Luke Tierney could figure out. R generally
 passes by value into function calls (but not *always*), so often
 multiple copies of objects are made during the course of calls. I
 would speculate that this is what might be going on below -- maybe
 even that's what you meant.

 Just a guess on my part, of course, so treat accordingly.

 -- Bert

 On Mon, Feb 27, 2012 at 1:03 PM, Sam Steingold s...@gnu.org wrote:
 It appears that the intermediate data in functions is never GCed even
 after the return from the function call.
 R's RSS is 4 Gb (after a gc()) and

 sum(unlist(lapply(lapply(ls(),get),object.size)))
 [1] 1009496520

 (less than 1 GB)

 how do I figure out where the 3GB of uncollected garbage is hiding?

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://jihadwatch.org http://memri.org
http://palestinefacts.org http://truepeace.org http://iris.org.il
I may be getting older, but I refuse to grow up!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] memory management

2012-02-28 Thread Bert Gunter
On Tue, Feb 28, 2012 at 11:57 AM, Sam Steingold s...@gnu.org wrote:
 My basic worry is that the GC does not work properly,
 i.e., the unreachable data is never collected.

Highly unlikely. Such basic inner R code has been well tested over 20
years.  I believe that you merely don't understand the inner guts of
what R is doing here, which is the essence of my response. (Clearly, I
make no claim that I do either).

I suggest you move on.

-- Bert


 * Bert Gunter thagre.ore...@trar.pbz [2012-02-27 14:35:14 -0800]:

 This appears to be the sort of query that (with apologies to other R
 gurus) only Brian Ripley or Luke Tierney could figure out. R generally
 passes by value into function calls (but not *always*), so often
 multiple copies of objects are made during the course of calls. I
 would speculate that this is what might be going on below -- maybe
 even that's what you meant.

 Just a guess on my part, of course, so treat accordingly.

 -- Bert

 On Mon, Feb 27, 2012 at 1:03 PM, Sam Steingold s...@gnu.org wrote:
 It appears that the intermediate data in functions is never GCed even
 after the return from the function call.
 R's RSS is 4 Gb (after a gc()) and

 sum(unlist(lapply(lapply(ls(),get),object.size)))
 [1] 1009496520

 (less than 1 GB)

 how do I figure out where the 3GB of uncollected garbage is hiding?

 --
 Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 
 11.0.11004000
 http://www.childpsy.net/ http://jihadwatch.org http://memri.org
 http://palestinefacts.org http://truepeace.org http://iris.org.il
 I may be getting older, but I refuse to grow up!



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] macro function

2012-02-28 Thread David Winsemius


On Feb 28, 2012, at 12:10 PM, mrzung wrote:


I really appreciate to your attention.

I want to change the data form A into B


http://r.789695.n4.nabble.com/file/n4428807/1.png


http://r.789695.n4.nabble.com/file/n4428807/2.png


Please use text copied versions of  dput(a) and dput(b) rather than  
posting bitmapped images of your screen.





In fact, there are 1095 column in data A.
Specifically, variable publish_day is when some book in the same  
row is

published and
D-1, D-2 means the term after the publish day.
Of course, the cells in data mean productivity in the day.

What can be effecient way to do it?


Specify what you want tot do in English. Asking how to create 1000  
separate variable is almost certainly to be the wrong way to go. If  
you wanted a list with names like that we can probably help.



--

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] memory management

2012-02-28 Thread William Dunlap
Look into environments that may be stored
with your data.  object.size(obj) does not
report on the size of the environment(s)
associated with obj.  E.g.,

   f - function(n) {
  +d - data.frame(y=rnorm(n), x1=rnorm(n), x2=rnorm(n))
  +terms(data=d, y~.)
  + }
   z - f(1e6)
   object.size(z)
  1760 bytes
   eapply(environment(z), object.size)
  $d
  24000520 bytes

  $n
  32 bytes
That happens because formula objects (like function
objects) contain a reference to the environment in
which they were created and that environmentwill not
be destroyed until the last reference to it is gone.
You might be able write code using, e.g., the codetools
package to walk through your objects looking for all
distinct environments that they reference (directly
and indirectly, via ancestors of environments directly
referenced).  Then you can add up the sizes of things
in those environments.

Another possible reason for your problem is that by using ls()
instead of ls(all=TRUE) you are not looking at datasets
whose names start with a dot.

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 Sam Steingold
 Sent: Tuesday, February 28, 2012 11:58 AM
 To: r-help@r-project.org; Bert Gunter
 Subject: Re: [R] memory management
 
 My basic worry is that the GC does not work properly,
 i.e., the unreachable data is never collected.
 
  * Bert Gunter thagre.ore...@trar.pbz [2012-02-27 14:35:14 -0800]:
 
  This appears to be the sort of query that (with apologies to other R
  gurus) only Brian Ripley or Luke Tierney could figure out. R generally
  passes by value into function calls (but not *always*), so often
  multiple copies of objects are made during the course of calls. I
  would speculate that this is what might be going on below -- maybe
  even that's what you meant.
 
  Just a guess on my part, of course, so treat accordingly.
 
  -- Bert
 
  On Mon, Feb 27, 2012 at 1:03 PM, Sam Steingold s...@gnu.org wrote:
  It appears that the intermediate data in functions is never GCed even
  after the return from the function call.
  R's RSS is 4 Gb (after a gc()) and
 
  sum(unlist(lapply(lapply(ls(),get),object.size)))
  [1] 1009496520
 
  (less than 1 GB)
 
  how do I figure out where the 3GB of uncollected garbage is hiding?
 
 --
 Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 
 11.0.11004000
 http://www.childpsy.net/ http://jihadwatch.org http://memri.org
 http://palestinefacts.org http://truepeace.org http://iris.org.il
 I may be getting older, but I refuse to grow up!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] update.formula has 512 char buffer?

2012-02-28 Thread Duncan Murdoch

On 28/02/2012 2:46 PM, Bert Gunter wrote:

Your code seems to be screwed up. There are no (small) size
limitations on formulas (afaik).

The following worked fine for me:

x- paste(x,1:100,sep=,collapse =  + )
part1- paste(y,x,sep= ~ )
part2- paste(f,1:50, sep=,collapse =  + )
fml- formula(paste(part1,part2,sep= | ))


I think the problem is in R, not in what Chris did.  It seems to be in 
update.formula, or terms.formula, or some related function.


I'll try to track it down.

Duncan


Cheers,
Bert

On Tue, Feb 28, 2012 at 11:11 AM, Chris Hane
christopher.a.h...@gmail.com  wrote:
  Hello,

  I am trying to paste together a formula to use in the mob function of
  party. This means the formula will be of the form y ~ x1+ ...+xM | z1+..zN.

  I am doing some preliminary fits of y ~ x1+ ...+xM, then want to add the
  conditional part of the equation using update().

  Here's the test code:
  var1- 1:78
  x1- paste(x, var1, sep=)
  f1- paste(f, var1[1:10], sep=)

  # use first 77 variables
  fmla- as.formula( paste(y ~ , paste(x1[1:77], collapse= + , sep=),
  sep=))
  fmla2- update(fmla, paste(. ~ . | , paste(f1, collapse=  + ), sep=))

  # CHANGE x to all 78 variables
  fmla- as.formula( paste(y ~ , paste(x1, collapse= + , sep=),
  sep=))
  fmla2- update(fmla, paste(. ~ . | , paste(f1, collapse=  + ), sep=))

  I have run this in Windows and Linux (64 bit) and both fail when using all
  78 terms (and anything more than 78 terms). The error message contains
  Error in parse(text = x) : :1:514: unexpected ')'.

  Changing the length of the names of the x variables will break the update()
  with fewer variables, but always with an error referring to just more than
  512 characters.  There is nothing special about 77 or 78 variables here; I
  want to do this with hundreds of variables.

  Is there a workaround to this?

  [[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] Cleaning up messy Excel data

2012-02-28 Thread Noah Silverman
Unfortunately, some data I need to work with was delivered in a rather messy 
Excel file.  I want to import into R and clean up some things so that I can do 
my analysis.  Pulling in a CSV from Excel is the easy part.

My current challenge is dealing with some text mixed in the values.  
i.e.   118   5.7   2.0  3.7 

Since this column in Excel has a 2.0 value, then R reads the column as a 
factor with levels.  Ideally, I want to convert it a normal vector of scalars 
and code code the 2.0 as 0.  

Can anyone suggest an easy way to do this?

Thanks!


--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095


[[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] Cleaning up messy Excel data

2012-02-28 Thread jim holtman
First of all when reading in the CSV file, use 'as.is = TRUE' to
prevent the changing to factors.

Now that things are character in that column, you can use some pattern
expressions (gsub, regex, ...) to search for and change your data.
E.g.,

sub(.*, 0, yourCol)

should do it for you.

On Tue, Feb 28, 2012 at 4:27 PM, Noah Silverman noahsilver...@ucla.edu wrote:
 Unfortunately, some data I need to work with was delivered in a rather messy 
 Excel file.  I want to import into R and clean up some things so that I can 
 do my analysis.  Pulling in a CSV from Excel is the easy part.

 My current challenge is dealing with some text mixed in the values.
 i.e.   118   5.7   2.0  3.7

 Since this column in Excel has a 2.0 value, then R reads the column as a 
 factor with levels.  Ideally, I want to convert it a normal vector of scalars 
 and code code the 2.0 as 0.

 Can anyone suggest an easy way to do this?

 Thanks!


 --
 Noah Silverman
 UCLA Department of Statistics
 8117 Math Sciences Building
 Los Angeles, CA 90095


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



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cleaning up messy Excel data

2012-02-28 Thread Robert Baer
-Original Message- 
From: Noah Silverman

Sent: Tuesday, February 28, 2012 3:27 PM
To: r-help
Subject: [R] Cleaning up messy Excel data

Unfortunately, some data I need to work with was delivered in a rather messy 
Excel file.  I want to import into R and clean up some things so that I can 
do my analysis.  Pulling in a CSV from Excel is the easy part.


My current challenge is dealing with some text mixed in the values.
i.e.   118   5.7   2.0  3.7

Since this column in Excel has a 2.0 value, then R reads the column as a 
factor with levels.  Ideally, I want to convert it a normal vector of 
scalars and code code the 2.0 as 0.


Can anyone suggest an easy way to do this?
--
?as.character
will show you how to change the factor column into a character column. 
Then, you can replace text using any of a number of procedures.

see for example
?gsub

finally, you can use as.numeric if you want numbers.  Coding is best done 
in the context of factors, so you might want to consider where replacing  2 
with NA is more appropriate than replacing with 0.  In this end, the choice 
might be context sensitive.


Rob

--
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cleaning up messy Excel data

2012-02-28 Thread Noah Silverman
That's exactly what I need.

Thank You!!


--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095

On Feb 28, 2012, at 1:42 PM, jim holtman wrote:

 First of all when reading in the CSV file, use 'as.is = TRUE' to
 prevent the changing to factors.
 
 Now that things are character in that column, you can use some pattern
 expressions (gsub, regex, ...) to search for and change your data.
 E.g.,
 
 sub(.*, 0, yourCol)
 
 should do it for you.
 
 On Tue, Feb 28, 2012 at 4:27 PM, Noah Silverman noahsilver...@ucla.edu 
 wrote:
 Unfortunately, some data I need to work with was delivered in a rather messy 
 Excel file.  I want to import into R and clean up some things so that I can 
 do my analysis.  Pulling in a CSV from Excel is the easy part.
 
 My current challenge is dealing with some text mixed in the values.
 i.e.   118   5.7   2.0  3.7
 
 Since this column in Excel has a 2.0 value, then R reads the column as a 
 factor with levels.  Ideally, I want to convert it a normal vector of 
 scalars and code code the 2.0 as 0.
 
 Can anyone suggest an easy way to do this?
 
 Thanks!
 
 
 --
 Noah Silverman
 UCLA Department of Statistics
 8117 Math Sciences Building
 Los Angeles, CA 90095
 
 
[[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.
 
 
 
 -- 
 Jim Holtman
 Data Munger Guru
 
 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.


[[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] memory management

2012-02-28 Thread Sam Steingold
 * William Dunlap jqha...@gvopb.pbz [2012-02-28 20:19:06 +]:

 Look into environments that may be stored with your data.

thanks, but I see nothing like that:

for (n in ls(all.names = TRUE)) {
  o - get(n)
  print(object.size(o), units=Kb)
  e - environment(o)
  if (!identical(e,NULL)  !identical(e,.GlobalEnv)) {
print(e)
print(eapply(e,object.size))
  }
}
25.8 Kb
0.5 Kb
49.1 Kb
0.1 Kb
30.8 Kb
13.6 Kb
17.4 Kb
59.4 Kb
52.2 Kb
0.1 Kb
3.9 Kb
49.1 Kb
21.2 Kb
0.1 Kb
0.1 Kb
51 Kb
13.2 Kb
53.5 Kb
18.1 Kb
64.3 Kb
25.8 Kb
33.5 Kb
0.1 Kb
0.1 Kb
8 Kb
10 Kb
15.7 Kb
15.6 Kb
9.9 Kb
401672.7 Kb
19.1 Kb
76 Kb
12 Kb
32.4 Kb
156.3 Kb
13.1 Kb
20.5 Kb
21.8 Kb
10.8 Kb

sum(unlist(lapply(lapply(ls(all.names = TRUE),get),object.size)))
[1] 412351928

i.e., total of data is about 400MB.
why does the process take in access of 1GB?

top: 1235m 1.1g 4452 S0 14.6   7:12.27 R

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://pmw.org.il http://camera.org
http://dhimmi.com http://palestinefacts.org http://ffii.org
Fighting for peace is like screwing for virginity.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] memory management

2012-02-28 Thread William Dunlap
You need to walk through the objects, checking for
environments on each component or attribute of an
object.  You also have to look at the parent.env
of each environment found.  E.g.,
   f - function(n) {
  +   d - data.frame(y = rnorm(n), x = rnorm(n))
  +   lm(y ~ poly(x, 4), data=d)
  + }
   z - f(1e5)
   environment(z)
  NULL
   object.size(z)
  21610708 bytes
   sapply(z, object.size)
   coefficients residuals   effects 
384   4400104   1200336 
   rank fitted.valuesassign 
 32   440010456 
 qr   df.residual   xlevels 
760123232   104 
   call terms model 
508  2804   4004276
   environment(z$terms)
  environment: 0x0abb86e4
   eapply(environment(z$terms), object.size)
  $d
  1600448 bytes

  $n
  32 bytes

Coding this is tedious; the codetools package may make it
easier.  Summing the sizes may well give an overestimate
of the memory actually used, since several objects may
share the same memory.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: Sam Steingold [mailto:sam.steing...@gmail.com] On Behalf Of Sam 
 Steingold
 Sent: Tuesday, February 28, 2012 2:56 PM
 To: r-help@r-project.org; William Dunlap
 Subject: Re: memory management
 
  * William Dunlap jqha...@gvopb.pbz [2012-02-28 20:19:06 +]:
 
  Look into environments that may be stored with your data.
 
 thanks, but I see nothing like that:
 
 for (n in ls(all.names = TRUE)) {
   o - get(n)
   print(object.size(o), units=Kb)
   e - environment(o)
   if (!identical(e,NULL)  !identical(e,.GlobalEnv)) {
 print(e)
 print(eapply(e,object.size))
   }
 }
 25.8 Kb
 0.5 Kb
 49.1 Kb
 0.1 Kb
 30.8 Kb
 13.6 Kb
 17.4 Kb
 59.4 Kb
 52.2 Kb
 0.1 Kb
 3.9 Kb
 49.1 Kb
 21.2 Kb
 0.1 Kb
 0.1 Kb
 51 Kb
 13.2 Kb
 53.5 Kb
 18.1 Kb
 64.3 Kb
 25.8 Kb
 33.5 Kb
 0.1 Kb
 0.1 Kb
 8 Kb
 10 Kb
 15.7 Kb
 15.6 Kb
 9.9 Kb
 401672.7 Kb
 19.1 Kb
 76 Kb
 12 Kb
 32.4 Kb
 156.3 Kb
 13.1 Kb
 20.5 Kb
 21.8 Kb
 10.8 Kb
 
 sum(unlist(lapply(lapply(ls(all.names = TRUE),get),object.size)))
 [1] 412351928
 
 i.e., total of data is about 400MB.
 why does the process take in access of 1GB?
 
 top: 1235m 1.1g 4452 S0 14.6   7:12.27 R
 
 --
 Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 
 11.0.11004000
 http://www.childpsy.net/ http://pmw.org.il http://camera.org
 http://dhimmi.com http://palestinefacts.org http://ffii.org
 Fighting for peace is like screwing for virginity.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cleaning up messy Excel data

2012-02-28 Thread Stephen Sefick
Just replace that value with zero.  If you provide some reproducible 
code I could probably give you a solution.

?dput
good luck,

Stephen

On 02/28/2012 03:27 PM, Noah Silverman wrote:

Unfortunately, some data I need to work with was delivered in a rather messy 
Excel file.  I want to import into R and clean up some things so that I can do 
my analysis.  Pulling in a CSV from Excel is the easy part.

My current challenge is dealing with some text mixed in the values.
i.e.   118   5.72.0  3.7

Since this column in Excel has a 2.0 value, then R reads the column as a factor with 
levels.  Ideally, I want to convert it a normal vector of scalars and code code the 2.0 
as 0.

Can anyone suggest an easy way to do this?

Thanks!


--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095


[[alternative HTML version deleted]]

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


--
Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

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

-K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

  -Robert Gentleman

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] group calculations with other columns for the ride

2012-02-28 Thread Ben quant
Hello,

I can get the median for each factor, but I'd like another column to go
with each factor. The nm column is a long name for the lvls column. So
unique work except for the order can get messed up.

Example:
x =
data.frame(val=1:10,lvls=c('cat2',rep(cat1,4),rep(cat2,4),'cat1'),nm=c('longname2',rep(longname1,4),rep(longname2,4),'longname1'))
 x
val lvlsnm
11 cat2 longname2
22 cat1 longname1
33 cat1 longname1
44 cat1 longname1
55 cat1 longname1
66 cat2 longname2
77 cat2 longname2
88 cat2 longname2
99 cat2 longname2
10  10 cat1 longname1

unique doesn't work in data.frame:
 mdn = do.call(rbind,lapply(split(x[,1], x[,2]), median))
 data.frame(mdn,ln=as.character(unique(x[,3])))
mdnln
cat1   4 longname2
cat2   7 longname1

I want:
mdnln
cat1   4 longname1
cat2   7 longname2

Thank you very much!

PS - looking for simple'ish solutions. I know I can do it with loops and
merges, but is there an option I am not using here?

Ben

[[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] group calculations with other columns for the ride

2012-02-28 Thread ilai
 aggregate(val~lvls+nm,data=x,FUN='median')



On Tue, Feb 28, 2012 at 4:43 PM, Ben quant ccqu...@gmail.com wrote:
 Hello,

 I can get the median for each factor, but I'd like another column to go
 with each factor. The nm column is a long name for the lvls column. So
 unique work except for the order can get messed up.

 Example:
 x =
 data.frame(val=1:10,lvls=c('cat2',rep(cat1,4),rep(cat2,4),'cat1'),nm=c('longname2',rep(longname1,4),rep(longname2,4),'longname1'))
  x
 val lvls        nm
 1    1 cat2 longname2
 2    2 cat1 longname1
 3    3 cat1 longname1
 4    4 cat1 longname1
 5    5 cat1 longname1
 6    6 cat2 longname2
 7    7 cat2 longname2
 8    8 cat2 longname2
 9    9 cat2 longname2
 10  10 cat1 longname1

 unique doesn't work in data.frame:
  mdn = do.call(rbind,lapply(split(x[,1], x[,2]), median))
  data.frame(mdn,ln=as.character(unique(x[,3])))
 mdn        ln
 cat1   4 longname2
 cat2   7 longname1

 I want:
 mdn        ln
 cat1   4 longname1
 cat2   7 longname2

 Thank you very much!

 PS - looking for simple'ish solutions. I know I can do it with loops and
 merges, but is there an option I am not using here?

 Ben

        [[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] group calculations with other columns for the ride

2012-02-28 Thread Ben quant
Excellent! I wonder why I haven't seen aggregate before.
Thanks!

ben

On Tue, Feb 28, 2012 at 4:51 PM, ilai ke...@math.montana.edu wrote:

  aggregate(val~lvls+nm,data=x,FUN='median')



 On Tue, Feb 28, 2012 at 4:43 PM, Ben quant ccqu...@gmail.com wrote:
  Hello,
 
  I can get the median for each factor, but I'd like another column to go
  with each factor. The nm column is a long name for the lvls column. So
  unique work except for the order can get messed up.
 
  Example:
  x =
 
 data.frame(val=1:10,lvls=c('cat2',rep(cat1,4),rep(cat2,4),'cat1'),nm=c('longname2',rep(longname1,4),rep(longname2,4),'longname1'))
   x
  val lvlsnm
  11 cat2 longname2
  22 cat1 longname1
  33 cat1 longname1
  44 cat1 longname1
  55 cat1 longname1
  66 cat2 longname2
  77 cat2 longname2
  88 cat2 longname2
  99 cat2 longname2
  10  10 cat1 longname1
 
  unique doesn't work in data.frame:
   mdn = do.call(rbind,lapply(split(x[,1], x[,2]), median))
   data.frame(mdn,ln=as.character(unique(x[,3])))
  mdnln
  cat1   4 longname2
  cat2   7 longname1
 
  I want:
  mdnln
  cat1   4 longname1
  cat2   7 longname2
 
  Thank you very much!
 
  PS - looking for simple'ish solutions. I know I can do it with loops and
  merges, but is there an option I am not using here?
 
  Ben
 
 [[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] Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names

2012-02-28 Thread R. Michael Weylandt
What is initialCuratedDF? I'm not seeing it in any standard location
so there's no way to debug it...

Also see inline.

Michael

On Tue, Feb 28, 2012 at 2:41 PM, Ben Ganzfried ben.ganzfr...@gmail.com wrote:
 Hey,

 I just googled my error and many things came up.  I followed the leads and
 read the ?read.delim page; I tried changing header = TRUE, and row.names =
 TRUE-- but I've still been having trouble fixing it, so I would greatly
 appreciate any help you can provide.  Here is my code:


PLEASE don't ever do this -- it's potentially very destructive to
anyone who tries to copy your script to help you.
David also mentioned this when you posted the same code ~ 6 months ago.

 ## rm(list=ls()) ## ALWAYS WRAP IN COMMENTS IF YOU ARE GOING TO INSIST ON 
 INCLUDING IT
 source(../../functions.R)

 uncurated - read.csv(../uncurated/GSE3141_full_pdata.csv, as.is
 =TRUE,row.names=1)
 celfile.dir - ../../../DATA/GSE3141/RAW

 ##initial creation of curated dataframe
 curated - initialCuratedDF(rownames(uncurated),
 template.filename=template.csv)


 The error occurs when I run this line:
 curated - initialCuratedDF(rownames(uncurated),
 template.filename=template.csv)
 Error in read.table(file = file, header = header, sep = sep, quote = quote,
  :
  more columns than column name


 I would greatly appreciate any help.

 Thanks!

 Ben

        [[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] aggregating specific parts in zoo index column to perform sliding average

2012-02-28 Thread knavero
Thanks Gabor. Answering all my noob questions haha. Interesting strategy to
adjust the input raw data as opposed to Excel where one offsets the output
data instead. I'll remember that.

--
View this message in context: 
http://r.789695.n4.nabble.com/aggregating-specific-parts-in-zoo-index-column-to-perform-sliding-average-tp4426798p4429257.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] Error: could not find function hier.part

2012-02-28 Thread haiyan
Error: could not find function hier.part
things I have tried:

1. reinstall R (lastest version,  on windows XP)
2. install package gtools
3. include:
library(gtools)
require(gtools)
4. how I call this function:
hier.part(c$Y, xdata, fam = gaussian, gof = Rsqu)

5.when I try to check what's in the package gtools, I get (hier.part is
not included): 

 gtools:: TAB
gtools::addLast gtools::ask gtools::assert  

gtools::binsearch   gtools::capture
gtools::checkRVersion   
gtools::combinationsgtools::ddirichlet  gtools::defmacro

gtools::evengtools::foldchange 
gtools::foldchange2logratio 
gtools::inv.logit   gtools::invalid gtools::keywords

gtools::logit   gtools::logratio2foldchange gtools::mixedorder  

gtools::mixedsort   gtools::odd gtools::permutations

gtools::permute gtools::quantcutgtools::rdirichlet  

gtools::running gtools::scat   
gtools::setTCPNoDelay   
gtools::smartbind   gtools::sprint  gtools::strmacro  

I am new to R, and I googled everything about the error message. I don't
really understand what is requires the gtools package in the gregmisc
bundle. tried to install packagegregmisc, did not help.

Could someone please help?
Thank you very much,

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-could-not-find-function-hier-part-tp4429644p4429644.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] Installing package QRMlib

2012-02-28 Thread DT54321
Yes, I did. But my Windows did not know what program to open it with...

--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4429275.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] Installing the package Rcplex

2012-02-28 Thread zheng wei
Hello,

I have posted this question earlier and got a lot of helps. Appreciate all 
those helps. After intensive learning and researching, this is to summurize 
what I have now.

Target: Install the package Rcplex
OS: windows 7 64bit
The Story:
Installed the Rtool, and setted the path to all relevant directories. 
Downloaded the tar.gz file to directory of c:/temp and rename it to be 
Rcplex.tar.gz and then used tar command to unzip it under the same directory. 
Also installed the software of cplex from IBM with license under the directory 
of c:/IBM, and edited the file of makevars.win in the R package folder as the 
following

PKG_CPPFLAGS=-I C:/IBM/ILOG/CPLEX_Studio_Academic124/cplex/include
PKG_LIBS=-L 
C:/IBM/ILOG/CPLEX_Studio_Academic124/cplex/lib/x64_windows_vs2010/stat_mda -l 
cplex124 -lm

Then I go to directory of {installation path for R}\bin\x64 under cmd and 
typed 

R CMD INSTALL -l {the path to my personal library} c:/temp/Rcplex

I got the error message with a bunch of lines similar to 
 
Rcplex_QCP.o:Rcplex_QCP.c:.text+0x217 undefined reference to 
'_imp_CPXcreateprob@12'
Rcplex_QCP.o:Rcplex_QCP.c:.text+0x217 undefined reference to 
'_imp_CPXcopylp@60'
.
.

Some suspects: 
Not sure the following information would be relevant
Originally, I used the command of 
R CMD INSTALL c:/temp/Rcplex
directly and was told I have no permission to install to the main library. So I 
used the personal library which was automatically created while I installed 
other packages. I googled about this error message of undefined reference 
to and some people said The problem may occur when the library (a file with 
the .h extension) in which the function is defined is missing or mislocated. I 
checked the include folder for software cplex and it has files cplex.h and 
ilocplex.h which I thought to be needed.

Any ideas? 
[[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] indexing??

2012-02-28 Thread helin_susam
Dear Petr Savicky,

Actually, this is based on jackknife after bootstrap algorithm. In summary,

I have a data set, and I want to compute some values by using this
algorithm.

Firstly, using bootstrap, I create some bootstrap re-samples. This step O.K.
Then, for each data point within these re-samples, I want to get a subset
which do not contain that data point ( this point would be any point of the
original data set), in general, if B is the number of bootstrap-resamples,
there are B/e resamples obtained for each data point.  And finally, I want
to calculate some values for each of this re samples.

Explanation of my algorithm;

#My data set: (x and y)
y - c(1,2,3,4,5,6,7,8,9,10)
x - c(1,0,0,1,1,0,0,1,1,0)

n - length(x)

t - matrix(cbind(y,x), ncol=2)

z = x+y

for(j in 1:length(x)) {
out - vector(list, )

for(i in 1:10) {

t.s - t[sample(n,n,replace=T),] # Here is the bootstrap step

y.s - t.s[,1]
x.s - t.s[,2]

z.s - y.s+x.s
nn - sum (z.s)  # For example, I want to calculate this value

out[[i]] - list(ff - (nn), finding=any (y.s==y[j])) # I get the mentioned
subset in here
kk - sapply(out, function(x) {x$finding})
ff - out[! kk]
}
}

I obtained the following results of an experiment;

 kk
 [1] FALSE  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
 ff
[[1]]
[[1]][[1]]
[1] 47

[[1]]$finding
[1] FALSE


[[2]]
[[2]][[1]]
[1] 46

[[2]]$finding
[1] FALSE


[[3]]
[[3]][[1]]
[1] 52

[[3]]$finding
[1] FALSE

It is easy to do when y contains different elements.  out[[i]] - list(ff
- (nn), finding=any (y.s==y[j]))

But, when y contains the same element, doing this process can be confusing
confusing..
Because, (y - c(1,1,1,0,0,1,0,1,0,0)) for y[j] when j= 1 there are some
other 1 in the y.  Is there something special about the y to an j ? 
Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/indexing-tp4428210p4429280.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] igraph find the path with the smallest weights

2012-02-28 Thread Wendy
Hi all, 

I am trying to analyze some graphs in R. Given a weighted directed network
with 7 nodes. I want to find a path from node 1 to node 7, so the sum of all
the edges on the path is the smallest comparing to all the other paths. I am
wondering if I can do this in igraph. After I identify the path, can I
colour code the path?

Thank you in advance.

Wendy


--
View this message in context: 
http://r.789695.n4.nabble.com/igraph-find-the-path-with-the-smallest-weights-tp4429343p4429343.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] Quantile scores as dependent variables.. an R and general method question

2012-02-28 Thread Rob James
I have a dataset that does not include native scores, but only serial
quantile rankings for a set of units.

Clearly these observations are dependent (in that you can't alter one
observation without also altering others).

Are there methods for dealing with quantile dependent variables. My atempt
to find such methods has not bee successful.

Any leads to theory, texts or R code would be most appeciated.

[[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] ts.plot and x axes customization

2012-02-28 Thread Jochem Schuster

   Dear List,
   I would be pleased if someone can help me with the following issue:
   I'm about to plot two time series in one plot via ts.plot which looks like:
   ts.plot(series1, series2, main=main, xlab=xlab, ylab=ylab, col=c(green,
   red, blue), lwd=2)
   The  problem  is,  that  R  automatically  sets  the  x axes labels in
   5-year-intervalls. Every 5 years there's one tick and one label with the
   respective year. Now I would like to customize the axes in a way that there
   is a label every year and a tick every quarter.
   In the previous code I've determined the time series with
   series1 = ts(x, start=c(2000,1), frequency=4)
   series2 = ts(y, start=c(2000,1), frequency=4)
   What I've tried before is deleting the X axes via gpars=list(xaxt=n) in
   the ts.plot-code. But after that I was not aible to add the customized axes
   via axis()...
   In advance, thank you very much for your help and hints!
   Regards,
   Jochem


   Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App für iPhone
   und Android.
   [1]https://produkte.web.de/freemail_mobile_startseite/

References

   1. https://produkte.web.de/freemail_mobile_startseite/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Database

2012-02-28 Thread Trying To learn again
Hi all,

I´m new using Access. I see that many things that you can do on Access you
can do on CRAN R but not on contrary.

My question is: Is there any manual with examples comparing how to do data
base analysis on access and making the same on CRAN R?

Imagine I want to compare two columns Name of two different data bases. I
want to see if there are identical names on both files.

It is better to use Access? Or it is better to use cran r (importing data
and work on CRAN R)?

This is only an example.

I know CRAN R is more specialized on statistics and data analysis but I ´m
trying not to learn Access and SQL so on.

I cannot explain better I hope you comprehed 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] Error: could not find function hier.part

2012-02-28 Thread R. Michael Weylandt
It would seem that hier.part is not in the gtools packagedo you
have some reference that suggests otherwise? I don't know the
function, but I might suggest you check the hier.part package (also on
CRAN).

Michael

On Tue, Feb 28, 2012 at 4:27 PM, haiyan tucsonaug...@gmail.com wrote:
 Error: could not find function hier.part
 things I have tried:

 1. reinstall R (lastest version,  on windows XP)
 2. install package gtools
 3. include:
 library(gtools)
 require(gtools)
 4. how I call this function:
 hier.part(c$Y, xdata, fam = gaussian, gof = Rsqu)

 5.when I try to check what's in the package gtools, I get (hier.part is
 not included):

 gtools:: TAB
 gtools::addLast             gtools::ask                 gtools::assert
 gtools::binsearch           gtools::capture
 gtools::checkRVersion
 gtools::combinations        gtools::ddirichlet          gtools::defmacro
 gtools::even                gtools::foldchange
 gtools::foldchange2logratio
 gtools::inv.logit           gtools::invalid             gtools::keywords
 gtools::logit               gtools::logratio2foldchange gtools::mixedorder
 gtools::mixedsort           gtools::odd                 gtools::permutations
 gtools::permute             gtools::quantcut            gtools::rdirichlet
 gtools::running             gtools::scat
 gtools::setTCPNoDelay
 gtools::smartbind           gtools::sprint              gtools::strmacro

 I am new to R, and I googled everything about the error message. I don't
 really understand what is requires the gtools package in the gregmisc
 bundle. tried to install packagegregmisc, did not help.

 Could someone please help?
 Thank you very much,

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Error-could-not-find-function-hier-part-tp4429644p4429644.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] Installing package QRMlib

2012-02-28 Thread R. Michael Weylandt
Please quote context.

You can open it with any plain text editor. (i.e., notepad)

Michael

On Tue, Feb 28, 2012 at 2:42 PM, DT54321 deepan.tailo...@gmail.com wrote:
 Yes, I did. But my Windows did not know what program to open it with...

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4429275.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] Siegel-Tukey test for equal variability (code)

2012-02-28 Thread Daniel Malter
The previously posted code contains bugs. The code below should work:


x: a vector of data

y: Group indicator (if id.col=TRUE); data of the second group (if
id.col=FALSE). If y is the group indicator it MUST take 0 or 1 to indicate
the groups, and x must contain the data for both groups.

id.col: If TRUE (default), then x is the data column and y is the ID column,
indicating the groups. If FALSE, x and y are both data columns. id.col must
be FALSE only if both data columns are of the same length.

adjust.median: Should between-group differences in medians be leveled before
performing the test? In certain cases, the Siegel-Tukey test is susceptible
to median differences and may indicate significant differences in
variability that, in reality, stem from differences in medians.

rnd: Should the data be rounded and, if so, to which decimal? The default
(-1) uses the data as is. Otherwise, rnd must be a non-negative integer.
Typically, this option is not needed. However, occasionally, differences in
the precision with which certain functions return values cause the merging
of two data frames to fail within the siegel.tukey function. Only then 
rounding is necessary. This operation should not be performed if it affects
the ranks of observations.

… arguments passed on to the Wilcoxon test. See ?wilcox.test

Value: Among other output, the function returns the data, the Siegel-Tukey
ranks, the associated Wilcoxon’s W and the p-value for a Wilcoxon test on
tie-adjusted Siegel-Tukey ranks (i.e., it performs and returns a
Siegel-Tukey test). If significant, the group with the smaller rank sum has
greater variability.

References: Sidney Siegel and John Wilder Tukey (1960) “A nonparametric sum
of ranks procedure for relative spread in unpaired samples.” Journal of the
American Statistical Association. See also, David J. Sheskin (2004)
”Handbook of parametric and nonparametric statistical procedures.” 3rd
edition. Chapman and Hall/CRC. Boca Raton, FL.

Notes: The Siegel-Tukey test has relatively low power and may, under certain
conditions, indicate significance due to differences in medians rather than
differences in variabilities (consider using the argument adjust.median).

Output (in this order)

1. Group medians (after median adjustment if specified)
2. Wilcoxon-test for between-group differences in medians (after the median
adjustment if specified)
3. Data, group membership, and the Siegel-Tukey ranks
4. Mean Siegel-Tukey rank by group (smaller values indicate greater
variability)
5. Siegel-Tukey test (Wilcoxon test on tie-adjusted Siegel-Tukey ranks)



siegel.tukey=function(x,y,id.col=TRUE,adjust.median=F,rnd=-1,alternative=two.sided,mu=0,paired=FALSE,exact=FALSE,correct=TRUE,conf.int=FALSE,conf.level=0.95){
if(id.col==FALSE){
   data=data.frame(c(x,y),rep(c(0,1),c(length(x),length(y
   } else {
data=data.frame(x,y)
   }
 names(data)=c(x,y)
 data=data[order(data$x),]
 if(rnd-1){data$x=round(data$x,rnd)}

 if(adjust.median==T){
cat(\n,Adjusting medians...,\n,sep=)
data$x[data$y==0]=data$x[data$y==0]-(median(data$x[data$y==0]))
data$x[data$y==1]=data$x[data$y==1]-(median(data$x[data$y==1]))
 }
 cat(\n,Median of group 1 = ,median(data$x[data$y==0]),\n,sep=)
 cat(Median of group 2 = ,median(data$x[data$y==1]),\n,\n,sep=)
 cat(Testing median differences...,\n)
 print(wilcox.test(data$x[data$y==0],data$x[data$y==1]))
 

 cat(Performing Siegel-Tukey rank transformation...,\n,\n)

sort.x-sort(data$x)
sort.id-data$y[order(data$x)]

data.matrix-data.frame(sort.x,sort.id)

base1-c(1,4)
iterator1-matrix(seq(from=1,to=length(x),by=4))-1
rank1-apply(iterator1,1,function(x) x+base)

iterator2-matrix(seq(from=2,to=length(x),by=4))
base2-c(0,1)
rank2-apply(iterator2,1,function(x) x+base2)

#print(rank1)
#print(rank2)

if(length(rank1)==length(rank2)){
rank-c(rank1[1:floor(length(x)/2)],rev(rank2[1:ceiling(length(x)/2)]))
} else{
rank-c(rank1[1:ceiling(length(x)/2)],rev(rank2[1:floor(length(x)/2)]))
}


unique.ranks-tapply(rank,sort.x,mean)
unique.x-as.numeric(as.character(names(unique.ranks)))

rank.matrix-data.frame(unique.x,unique.ranks)

ST.matrix-merge(data.matrix,rank.matrix,by.x=sort.x,by.y=unique.x)

print(ST.matrix)

cat(\n,Performing Siegel-Tukey test...,\n,sep=)

ranks0-ST.matrix$unique.ranks[ST.matrix$sort.id==0]
ranks1-ST.matrix$unique.ranks[ST.matrix$sort.id==1]

cat(\n,Mean rank of group 0: ,mean(ranks0),\n,sep=)
cat(Mean rank of group 1: ,mean(ranks1),\n,sep=)

print(wilcox.test(ranks0,ranks1,alternative=alternative,mu=mu,paired=paired,exact=exact,correct=correct,conf.int=conf.int,conf.level=conf.level))
}

Examples:

x - c(33, 62, 84, 85, 88, 93, 97, 4, 16, 48, 51, 66, 98)
id - c(0,0,0,0,0,0,0,1,1,1,1,1,1)

siegel.tukey(x,id,adjust.median=F,exact=T)

x-c(0,0,1,4,4,5,5,6,6,9,10,10)
id-c(0,0,0,1,1,1,1,1,1,0,0,0)

siegel.tukey(x,id)

x - c(85,106,96, 105, 104, 108, 86)
id-c(0,0,1,1,1,1,1)

siegel.tukey(x,id)


Re: [R] Error message: object of type 'closure' is not subsettable

2012-02-28 Thread Aparna Sampath
Hi Josh, Petr

I checked that testStatistics is a function but it is not defined in the
code anywhere else. But if I am able to remove it and give the input by my
own to the function which calls testStatistics, it might work.

The hurdle here for me is that the input is a set* of values and each value
has 2 attributes. Each variable is generated per iteration and has the
numerator, denominator as its attributes and a value. But when I read it in
a loop,  i face two problems: 1. only the last i value is stored and the
rest are NULL. 2. the one stored does not contain the attribute values.
 Each value looks like this:
t
[1] 3.897434
attr(,numerator)
[1] 0.0002134457
attr(,denominator)
[1] 5.47657e-05

Eg:
for (i in 1:5)
{
t- test.functional.t(res.em1,res.em2,mint,maxt,se.m=0,points=300) ###
function calling
}

t
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL

[1] 3.897434

Any suggestions. Thanks for all the help. :)

Regards
Aparna






On Tue, Feb 28, 2012 at 11:01 PM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi

 Difficult to without knowing what objects you are operating your
 functions.

 I get

  test.functional.t(1:10,1:10,3,4)
 Error in res.em1$eta : $ operator is invalid for atomic vectors
  moderated.functional.t(1:10)
 Error in testStatistics[numerator, ] : incorrect number of dimensions

 And without suitable objects for those functions to operate it is
 impossible to come with reasonable suggestion.

 Anyway there is a function on your system which is called testStatistics
 and you can not subset functions, hence your error. I did not find this
 function in R pacages but I can not say that it is really not there.

 You can get rid of this function by

 rm(testStatistics)

 Regards
 Petr


 
  Kindly find below the code as it is executed:
 
  test.functional.t -
 function(res.em1,res.em2,mint,maxt,se.m=0,points=300)
  {
at - seq(mint,maxt,length.out=points)
by - at[2] - at[1]
 
mu1 - spline(x=res.em1$tau,y=res.em1$eta,xout=at,method=natural)$y
  l2 - functional.norm(mu1,mu2,by=by)
 
s1 - mean(sapply(1:res.em1$n,
  function(i)
  {
v -
  spline(x=res.em1$tau,y=res.em1$vi[[i]],xout=at,method=natural)$y
functional.norm(v,by=by)^2
  }))
  denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n) ### formula for se
returnValue - l2 / (denominator + se.m)
 
attr(returnValue,numerator) - l2
attr(returnValue,denominator) - denominator
 
returnValue
  }
 
  moderated.functional.t -
  function(testStatistics,alpha.step=0.05,quantile.step=0.01)
  {
numerators - unlist(testStatistics[numerator,])
denominators - unlist(testStatistics[denominator,])
  }
 
  I get my error in the function above moderated.functional.t.
 testStatistics
  is shown to be a function(x) when I type it in R console. But there is
 no
  function definition for testStatistics in the code. My R understanding
 is
  still elementary.
 
  Thanks
  Aparna
 
 
 
 
  On Tue, Feb 28, 2012 at 5:25 PM, Joshua Wiley
 jwiley.ps...@gmail.comwrote:
 
   Hi Aparna,
  
   Can you please post a reproducible example?  It is difficult to
   provide much concrete help without having testStatistics.  One thing
   you might try is looking at:
  
   str(testStatistics[numerator,])
  
   is it actually a list?  If it is not (most likely given the error) and
   it is supposed to be, you need to figure out what aspect of the
   generation of it is going awry.
  
   Cheers,
  
   Josh
  
   On Tue, Feb 28, 2012 at 12:23 AM, Aparna Sampath
   aparna.sampat...@gmail.com wrote:
Hi All
   
I am trying to use the unlist() in R to a list variable.  The
 following
statements are within a function.
{
denominator - sqrt(s1 / res.em1$n + s2 / res.em2$n)
 returnValue - l2 / (denominator + 11)
 attr(returnValue,numerator) - l2
 attr(returnValue,denominator) - denominator
 returnValue
}
   
And when I try to unlist the variable returnValue
   
 numerators - unlist(testStatistics[numerator,])
 denominators - unlist(testStatistics[denominator,])
   
I get the following error:
   
   Error in testStatistics[numerator, ] :
 object of type 'closure' is not subsettable
   
I read some threads in R help on this error and they had asked to
 check
   if
we are using the right datatype to the right function. But in my
 case it
   is
pretty straightforward since I just list it in one function and try
 to
unlist it later. Any suggestions?
Thanks for the help :)
   
--
View this message in context:
   http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-
  not-subsettable-tp3752886p4427399.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, 

[R] How to replace the values in a column

2012-02-28 Thread hannahmaohuang
Dear All,
I've been searching relevant topics about replacing values, none seemed to
be applicable to me...

I have a file with many many varieties, and want to replace some of them
into different names. 
I tried various of ways, still don't know how to do that most efficiently..
Here is part of the example data:


GenRep
A_1  1
A_1   2 
A_2 1
A_2 2
B_1   1
B_1   2
B_3   1
B_3   2
OP1_1   1
OP1_1   2
OP1_5   1
OP1_5   2

For example, I want to replace  A_1,  B_3,  OP1_1 into different name
Wynda

So that the expected file should become:

Gen  Rep
Wynda  1
Wynda2
A_2   1 
A_2   2
B_1  1
B_1 2
Wynda1
Wynda2
Wynda1
Wynda2
OP1_5  1
OP1_5 2


I have created a link file, which contains two rows, translating which Gen
correlating to which Name. Not sure if this file helps or not, example as
below:

Column1(Gen)Column2(Name)
A_1   Wynda
A_2 A_2
B_1 B_1
B_3 Wynda
OP1_1   Wynda
OP1_5OP1_5


Though I can replace one by one in excel, since there are too many files and
too many reps, it'll be very time-consuming also easy to make mistakes.

Please give me any guidance or help in terms of finish this with R.

Thanks so much !

Sincerely
Hannah



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-replace-the-values-in-a-column-tp4430448p4430448.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Using a FOR LOOP to name objects

2012-02-28 Thread michaelyb
Hello,

I am trying to use a for loop to name objects in each iteraction. As in the
following example (which doesn't work quite well)

my_list-c(A,B,C,D,E,F)
for(i in c(1:length(my_list))){
  url- http://finance.yahoo.com;
  doc = htmlTreeParse(url, useInternalNodes = T)
  tab_nodes = xpathApply(doc, //table[@cellpadding = '3'])
  *my_list[i]*=lapply(tab_nodes, readHTMLTable) #problem is in this line
  names(*my_list[i]*)=c(Ins,outs)
  }

The problem is that in iteraction #1, I need the info to be stored at an
object called A; At iteraction #2 at object called B... and so on

Any idea/help?

thank you in advance!

--
View this message in context: 
http://r.789695.n4.nabble.com/Using-a-FOR-LOOP-to-name-objects-tp4430454p4430454.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] Bayesian Hidden Markov Models

2012-02-28 Thread monkeylan
Dear Oscar,
 
I am extremely grateful to your help and detailed explanation of the use of 
RJaCGH package.
But, when runing the sample codes you listed, another issue I am a little 
confused is as following:
After runing summary(res), I have got the estimation of the random matrix Beta:

Parameters of the transition functions:
       Normal  Gain
Normal  0.000 4.258
Gain    2.001 0.000
 
But, the transition probabilty matrix Q based on the aboving Beta is more 
concerned in my modeling. 
Here, I am not sure how can I get the  matrix Q. I did try the Q.NH 
functions.However, Shoud I set the distance parameter x be 1 or 0? I am not 
sure.
 
 If 1( according to my own understanding), the following result seems not 
reseanable.
 
tran-matrix(c(0,2.001,4.528,0),2,2)
Q.NH(beta=tran, x=1)
     [,1] [,2]
[1,]  0.5  0.5
[2,]  0.5  0.5
 
Many thanks for your further help and time.
 
James Allan

--- 12年2月28日,周二, Oscar Rueda [via R] 
ml-node+s789695n4427760...@n4.nabble.com 写道:


发件人: Oscar Rueda [via R] ml-node+s789695n4427760...@n4.nabble.com
主题: Re: Bayesian Hidden Markov Models
收件人: monkeylan lanjin...@yahoo.com.cn
日期: 2012年2月28日,周二,下午7:02


Dear James, 

Basically you just need the values (y) and the positions (in your case it 
would be the index of the times series). The chromosome argument does not 
apply to your case so it can be a vector of ones. 
If the positions are at the same distance between (equally spaced) then the 
model will be homogeneous. 

So for example something like this would be enough: 
 library(RJaCGH) 
 y - c(rnorm(100,0,1), rnorm(20, 2, 1), rnorm(50, 0, 1)) 
 Pos - 1:length(y) 
 Chrom - rep(1, length(y)) 
 res - RJaCGH(y=y, Pos=Pos, Chrom=Chrom) 
 summary(res) 

However, it uses a Reversible Jump algorithm and therefore jumps between 
models with different hidden states. I would suggest you take a look at the 
vignette that comes with the package or the paper that is referenced there 
for specific details of the model it fits. 


Hope it helps, 
Oscar 
  


On 28/2/12 04:52, monkeylan [hidden email] wrote: 


 Dear Doctor Oscar, 
   
 Sorry for not noticing that you are the author of the RJaCGH package. 
 
 But I noticed that hidden Markov model in your package is with 
 non-homogeneous 
 transition probabilities. Here in my work, the HMM is just a first-order 
 homogeneous Markov chain, i.e. the  transition  matrix is constant. 
   
 So, Could you please tell me how can I adjust the R functions in your package 
 to implement my analysis? 
   
 Best Regards, 
   
 James Allan 
 
 
 --- 12年2月27日,周一, Oscar Rueda [via R] 
 [hidden email] 写道: 
 
 
 发件人: Oscar Rueda [via R] [hidden email] 
 主题: Re: Bayesian Hidden Markov Models 
 收件人: monkeylan [hidden email] 
 日期: 2012年2月27日,周一,下午6:05 
 
 
 Dear James, 
 Although designed for the analysis of copy number CGH microarrays, RJaCGH 
 uses a Bayesian HMM model. 
 
 Cheers, 
 Oscar 
 
 
 On 27/2/12 08:32, monkeylan [hidden email] wrote: 
 
 
 Dear R buddies, 
 
 Recently, I attempt to model the US/RMB Exchange rate log-return time series 
 with a *Hidden Markov model (first order Markov Chain  mixed Normal 
 distributions). * 
 
 I have applied the RHmm package to accomplish this task, but the results are 
 not so satisfying. 
 So, I would like to try a *Bayesian method *for the parameter estimation of 
 the Hidden Markov model. 
 
 Could anyone kindly tell me which R package can perform Bayesian estimation 
 of the model? 
 
 Many thanks for your help and time. 
 
 Best Regards, 
 James Allan 
 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946
  
. 

 html 
 Sent from the R help mailing list archive at Nabble.com. 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 Oscar M. Rueda, PhD. 
 Postdoctoral Research Fellow, Breast Cancer Functional Genomics. 
 Cancer Research UK Cambridge Research Institute. 
 Li Ka Shing Centre, Robinson Way. 
 Cambridge CB2 0RE 
 England 
 
 
 
 
 NOTICE AND DISCLAIMER 
 This e-mail (including any attachments) is intended for ...{{dropped:16}} 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 
 
 
 
 
 
 If you reply to this email, your message will be added to the discussion 
 below:http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p44
 24152.html 
 To unsubscribe from Bayesian Hidden Markov Models, click here. 
 NAML 
 
 -- 
 View this message in 

Re: [R] colour by z value, persp in raster package

2012-02-28 Thread Omphalodes Verna
David thanks!
 
Maybe is better ''orginal'' example from raster package:
 
r - raster(system.file(external/test.grd, package=raster))
persp(r)
class(r)
 
It is not a problem to colour plot by z value in perspective plot (persp) in 
package graphic - there is an example in help files:
 
par(bg = white)
x - seq(-1.95, 1.95, length = 30)
y - seq(-1.95, 1.95, length = 35)
z - outer(x, y, function(a,b) a*b^2)
nrz - nrow(z)
ncz - ncol(z)
# Create a function interpolating colors in the range of specified colors
jet.colors - colorRampPalette( c(blue, green) ) 
# Generate the desired number of colors from this palette
nbcol - 100
color - jet.colors(nbcol)
# Compute the z-value at the facet centres
zfacet - z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
# Recode facet z-values into color indices
facetcol - cut(zfacet, nbcol)
persp(x, y, z, col=color[facetcol], phi=30, theta=-30)
par(op)

But question is how specify right sequences of colours (e.g. terrain.colors) 
for RasterLayer object. The idea of code is persp(r, col = terrain.color(n)), 
where r is class raster.
 
Thanks all!
 
OV

 



From: David Winsemius dwinsem...@comcast.net

Cc: r-help@r-project.org r-help@r-project.org 
Sent: Tuesday, February 28, 2012 8:47 PM
Subject: Re: [R] colour by z value, persp in raster package


On Feb 28, 2012, at 4:34 AM, Omphalodes Verna wrote:

 Hi all!
 
 My question is how to colour pixels by z value in persp plot in raster 
 package. Here is an example:
 
 
 x - seq(-1.95, 1.95, length = 30)
 y - seq(-1.95, 1.95, length = 35)
 z - outer(x, y, function(a,b) a*b^2)
 r1 - raster(nrows=35, ncols=30, xmn=0, xmx=30, ymn = 0, ymx = 35)
 r1[] - c(z)
 persp(r1)
 
 There already exist some function to produce persp plot for anothe classes, 
 but I have no idea how deal with RasterLayer object.

Is that really an example? After going to the trouble of correcting the error 
in this code from failing to load the raster package, I now see that there is 
no connection between the values of x, y, or x with the raster-call.

 r1[] - as.matrix(z)
Error in .local(x, values) : cannot use a matrix with these dimensions
Error in .local(x, i, j, ..., value) :
cannot replace values on this raster (it is too large
 persp(r1)
Error: hasValues(x) is not TRUE

#  Post some useful code.

--David Winsemius, MD
Heritage Laboratories
West Hartford, CT
[[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 replace the values in a column

2012-02-28 Thread ilai
Hannah,
If Gen is a factor you can simply build the new factor on top of it:

dataframe$Gen- factor( c('Wynda' , 'A_2' , 'B_1' , 'Wynda' , 'Wynda'
, 'OP1_5')[Gen] )

Just make sure the replacement labels are in the same order as levels(Gen).

Cheers

On Tue, Feb 28, 2012 at 8:39 PM, hannahmaohuang
hannahmaohu...@gmail.com wrote:
 Dear All,
 I've been searching relevant topics about replacing values, none seemed to
 be applicable to me...

 I have a file with many many varieties, and want to replace some of them
 into different names.
 I tried various of ways, still don't know how to do that most efficiently..
 Here is part of the example data:


 Gen    Rep
 A_1      1
 A_1       2
 A_2     1
 A_2     2
 B_1       1
 B_1       2
 B_3       1
 B_3       2
 OP1_1   1
 OP1_1   2
 OP1_5   1
 OP1_5   2

 For example, I want to replace  A_1,  B_3,  OP1_1 into different name
 Wynda

 So that the expected file should become:

 Gen          Rep
 Wynda      1
 Wynda        2
 A_2           1
 A_2           2
 B_1              1
 B_1             2
 Wynda        1
 Wynda        2
 Wynda        1
 Wynda        2
 OP1_5          1
 OP1_5         2


 I have created a link file, which contains two rows, translating which Gen
 correlating to which Name. Not sure if this file helps or not, example as
 below:

 Column1(Gen)        Column2(Name)
 A_1                               Wynda
 A_2                                 A_2
 B_1                                 B_1
 B_3                             Wynda
 OP1_1                       Wynda
 OP1_5                        OP1_5


 Though I can replace one by one in excel, since there are too many files and
 too many reps, it'll be very time-consuming also easy to make mistakes.

 Please give me any guidance or help in terms of finish this with R.

 Thanks so much !

 Sincerely
 Hannah



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-replace-the-values-in-a-column-tp4430448p4430448.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] ts.plot and x axes customization

2012-02-28 Thread ilai
On Tue, Feb 28, 2012 at 12:57 PM, Jochem Schuster
jochem.schus...@web.de wrote:

   ts.plot(series1, series2, main=main, xlab=xlab, ylab=ylab, col=c(green,
   red, blue), lwd=2)

   What I've tried before is deleting the X axes via gpars=list(xaxt=n) in
   the ts.plot-code. But after that I was not aible to add the customized axes
   via axis()...

So what was the problem? A reproducible example with your attempt at
annotating the ?axis would help.


   In advance, thank you very much for your help and hints!
   Regards,
   Jochem


   Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App für iPhone
   und Android.
   [1]https://produkte.web.de/freemail_mobile_startseite/

 References

   1. https://produkte.web.de/freemail_mobile_startseite/
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] How to replace the values in a column

2012-02-28 Thread andrija djurovic
Hi.

You can do something like this:

df - read.table(textConnection(
GenRep
A_1  1
A_1   2
A_2 1
A_2 2
B_1   1
B_1   2
B_3   1
B_3   2
OP1_1   1
OP1_1   2
OP1_5   1
OP1_5   2),header=TRUE,stringsAsFactors=FALSE)

str(df)

#adding a new column
cbind(df,ncol =
ifelse(df$Gen==A_1,Wynda,ifelse(df$Gen==B_3,Wynda,df$Gen)))

#replacing exisiting values
df$Gen[df$Gen==A_1 | df$Gen==B_3] - Wynda
df


Andrija




On Wed, Feb 29, 2012 at 7:06 AM, ilai ke...@math.montana.edu wrote:
 Hannah,
 If Gen is a factor you can simply build the new factor on top of it:

 dataframe$Gen- factor( c('Wynda' , 'A_2' , 'B_1' , 'Wynda' , 'Wynda'
 , 'OP1_5')[Gen] )

 Just make sure the replacement labels are in the same order as levels(Gen).

 Cheers

 On Tue, Feb 28, 2012 at 8:39 PM, hannahmaohuang
 hannahmaohu...@gmail.com wrote:
 Dear All,
 I've been searching relevant topics about replacing values, none seemed to
 be applicable to me...

 I have a file with many many varieties, and want to replace some of them
 into different names.
 I tried various of ways, still don't know how to do that most efficiently..
 Here is part of the example data:


 Gen    Rep
 A_1      1
 A_1       2
 A_2     1
 A_2     2
 B_1       1
 B_1       2
 B_3       1
 B_3       2
 OP1_1   1
 OP1_1   2
 OP1_5   1
 OP1_5   2

 For example, I want to replace  A_1,  B_3,  OP1_1 into different name
 Wynda

 So that the expected file should become:

 Gen          Rep
 Wynda      1
 Wynda        2
 A_2           1
 A_2           2
 B_1              1
 B_1             2
 Wynda        1
 Wynda        2
 Wynda        1
 Wynda        2
 OP1_5          1
 OP1_5         2


 I have created a link file, which contains two rows, translating which Gen
 correlating to which Name. Not sure if this file helps or not, example as
 below:

 Column1(Gen)        Column2(Name)
 A_1                               Wynda
 A_2                                 A_2
 B_1                                 B_1
 B_3                             Wynda
 OP1_1                       Wynda
 OP1_5                        OP1_5


 Though I can replace one by one in excel, since there are too many files and
 too many reps, it'll be very time-consuming also easy to make mistakes.

 Please give me any guidance or help in terms of finish this with R.

 Thanks so much !

 Sincerely
 Hannah



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-replace-the-values-in-a-column-tp4430448p4430448.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] SOUTH ACTRESS PHOTOS VIDEOS

2012-02-28 Thread devi


 HOT LINKS FOR YOUTH ONLY

 FOR FAST UPDATES IN FILM INDUSTRY

KATRINA KAIF RARE PHOTOS
http://allyouwants.blogspot.com/2011/12/katrina-kaif.html
KAJAL AGARWAL LATEST STILLS
http://allyouwants.blogspot.com/2011/03/kajal-latest-stills.html
PRIYANKA CHOPRA LATEST HOT PHOTOSHOOT
http://allyouwants.blogspot.com/2011/08/priyanka-chopra.html
TAMIL ACTRESS HOT PHOTOSVIDEOS
http://allyouwants.blogspot.com/2011/08/tamil-actress.html

SARANYA MOHAN LATEST HOT STILLS
http://actressgallery-kalyani.blogspot.in/2012/02/saranya-mohan-stills.html
  ANU SMRUTHI LATEST HOT STILLS
http://actressimages-9.blogspot.in/2012/02/anu-smirthi-stills.html
 EK THA TIGER MOVIE STILLS
http://actressgallery-kalyani.blogspot.in/2012/02/ek-tha-tiger-movie-stills.html
ACTREESS SUPRIYA SHAILJA LATEST  STILLS
http://actressgallery-kalyani.blogspot.in/2012/02/supriya-shailja-stills.html
   BOLLYWOOD ACTRESS APSARA AWARDS 2012
http://actressgallery-kalyani.blogspot.in/2012/01/apsara-awards-2012.html
  AISHWARYA RAI LATEST HOT PICS
http://actressimages-9.blogspot.in/2012/01/aishwarya-rai.html
KATRINA KAIF HOT MAGAZINES PHOTOS
http://actressimages-9.blogspot.in/2012/01/katrina-kaif-magazine-photos.html
   TRISHA HOT BEAUTIFUL IMAGES
http://actressimages-9.blogspot.in/2012/01/trisha-krishnan.html
   HOT MALLIKA SHERAWAT PHOTOS
http://actressimages-9.blogspot.in/2012/01/mallika-sherawat.html
  SHEELA LATEST HOT STILLS
http://actressgallery-kalyani.blogspot.in/2012/01/sheela-latest-stills.html
KATRINA KAIF ITEM SONG STILLS
http://actressgallery-kalyani.blogspot.in/2012/01/katrina-kaif-item-song-stills.html

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


[R] Cannot use negative argument in function

2012-02-28 Thread lidaky
Hi,

today i wrote a function in R of the type:

index.refraction - function(Temp,Press, RH, CO2)

When i try to plug a negative number in Temp, i got this type of error:


n - index.refraction(Temp= -40,100,80,CO2)
Messages d'avis :
1: In Ops.ordered(left, right) : '-' is not meaningful for ordered factors
2: In Ops.factor(left, right) : - not meaningful for factors
3: In Ops.factor(left, right) : - not meaningful for factors
4: In Ops.ordered(left, right) : '-' is not meaningful for ordered factors
5: In Ops.factor(left, right) : - not meaningful for factors
6: In Ops.factor(left, right) : - not meaningful for factors


Do you have any idea what can be the reason?
Thanks
Simon

--
View this message in context: 
http://r.789695.n4.nabble.com/Cannot-use-negative-argument-in-function-tp4430667p4430667.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] Coverage probability for the normal distribution in plot.spec.coherency function.

2012-02-28 Thread Pascal Oettli

Hello to the members of the list,

I am using the 'spectrum' function from 'stats' package, to calculate 
the squared coherency between two time series. The function 
'plot.spec.coherency' provides information for the coverage probability 
for the normal distribution.


It seems that the calculation is based on Enochson and Goodman, 1965, 
Gaussian approximations to the distribution of sample coherence. 
AFFDL-TR-65-57, Whright-Patterson Air Force base.


Could someone tell me if this reference was really used or another one?

In advance, thank you.

Pascal

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