[R] Michaelson-Morley Speed of Light Data

2012-04-11 Thread Křištof Želechovski
URL: http://finzi.psych.upenn.edu/R/library/datasets/html/morley.html 

The classical data of Michaelson and Morley on the speed of light

Can you provide more information about the data?  How were they obtained, 
etc.?  I do not have the book Genstat Primer and the nearest location where 
it is available is University of York which is rather far from my location.

Note that the data for the Michelson-Morley experiments [1] consist of 6 
experiments of 17 runs each, not of 5 series of 20 runs each.

Best regards,
Christopher Yeleighton

___
[1] URL: 
http://en.wikisource.org/wiki/On_the_Relative_Motion_of_the_Earth_and_the_Luminiferous_Ether
 


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

2012-04-11 Thread Jim Lemon

On 04/10/2012 11:50 PM, anaraster wrote:

Is there a way to access the numeric results (standard deviation and
correlation) obtained with the taylor.diagram ?


Hi anaraster,
That wouldn't be too difficult, just alter the code to return a list 
like this:


return(list(oldpar,R,sd.r,sd.f))

instead of:

return(oldpar)

Jim

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


Re: [R] clock24.plot

2012-04-11 Thread Jim Lemon

On 04/11/2012 12:59 AM, Nick Fankhauser wrote:

I've got the strange problem with clock24.plot that only the first data
point (phase = 23.38, size = 0.44) from the phases/sizes numeric vectors
is plotted.
Does anyone have an idea why this could be?

library(plotrix)
phases- c(23.38, 22.29, 22.71)
sizes- c(0.44, 0.30, 0.30)
clock24.plot(sizes,phases)


Hi Nick,
Try this:

clock24.plot(sizes,phases,radial.lim=c(0,max(sizes))

By default, clock24.plot only plots the range of values in lengths.

Jim

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


Re: [R] What is a better way to deal with lag/difference and loops in time series using R?

2012-04-11 Thread jpm miao
Hello,

   Thank you very much.

   How can I create an empty time series with the same dates as existing
time series?

   If x is a ts object, then it would be easy:
   y-ts(NA, start=start(x), end=end(x),frequency=frequency(x))

   What can I do if x is a zoo or xts object?
   I come up with a cumbersome way of doing this:
   xts-as.ts(x)
   y1-ts(NA, start=start(y), end=end(y),frequency=frequency(y))
   y-as.xts(y1)

   Is there any easier way to do it?

   Thanks

miao


2012/4/11 R. Michael Weylandt michael.weyla...@gmail.com

 Two ways around this:

 I = Easy) Just use zoo/xts objects. ts objects a real pain in the
 proverbial donkey because of things like this.

 Something like:

 library(xts)
 PI1.yq - as.xts(PI1) # Specialty class for quarterly data (or regular
 zoo works)
 lag(PI1.yq)

 II = Hard) lag on a ts actually changes the time indices while keeping
 all the data, [so the fourth data point is the same value -- just a
 different time point] what you may want to do is cbind() the objects
 to see how they line up now.

 cbind(PI1, lag(PI1,4))

 Hope this helps,
 Michael

 On Tue, Apr 10, 2012 at 11:21 PM, jpm miao miao...@gmail.com wrote:
  Hello,
 
I am writing codes for time series computation but encountering some
  problems
 
Given the quarterly data from 1983Q1 to 1984Q2
 
  PI1-ts(c(2.747365190,2.791594762, -0.009953715, -0.015059485,
  -1.190061246, -0.553031799,  0.686874720,  0.953911035),
  start=c(1983,1), frequency=4)
 
  PI1
  Qtr1 Qtr2 Qtr3 Qtr4
  1983  2.747365190  2.791594762 -0.009953715 -0.015059485
  1984 -1.190061246 -0.553031799  0.686874720  0.953911035
 
 
 If I would like to create a time series vector containing the data in
 4
  quarters ahead
 
  PI4-lag(PI1,4) PI4 Qtr1 Qtr2 Qtr3
 Qtr4
  1982  2.747365190  2.791594762 -0.009953715 -0.015059485
  1983 -1.190061246 -0.553031799  0.686874720  0.953911035
 
 
 Confusingly, PI1[1] and PI4[1] are exactly the same! I usually would
  like to calculate the difference between the vector of interest and  the
  corresponding values 4 quarters ahead, but it is zero!
 
  PI1[1][1] 2.747365 PI4[1][1] 2.747365
 
 
  One remedy that comes into my mind is to use window,but a warning message
  emerges
 
  PI4w-window(PI4, start=start(PI1), end=end(PI1))Warning message:In
 window.default(x, ...) : 'end' value not changed PI4w   Qtr1
 Qtr2   Qtr3   Qtr4
  1983 -1.1900612 -0.5530318  0.6868747  0.9539110
 
 
 Similar problems happen with the usage of the function diff, which
  calculate the difference. I wonder if it is better to work with the dates
  (1983Q1, 1983Q2,.) directly?
 
 If I want to write a loop, say, to conduct some computation from
 1983Q1
  to 2011Q4, the only way I know is to convert the dates to the ordinal
  indices, 1, 2, 3.. Can we work with the dates? Is there any built-in
  equality that provides the computation like
 1983Q1 +1 equals 1983Q2?
 In EViews, it is easy to do that. We can let %s run from 1983Q1 to
  2011Q4, and he knows that 1983Q1+1 is exactly 1983Q2.
 
  Thanks very much for your reply!
 
  miao
 
 [[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] how to save multiple work space

2012-04-11 Thread ya

Hi Petr and Michael,

Thank you very much for the response.

It worked! Now I can use multiple R sessions simultaneously, I just need 
to save their workspace separately. And If I want those objects in the 
single session, I just load them all in this session, and save the 
workspace again together:)


Thank you very much. This save me lots of time!

Best regards,

ya



On 2012-4-10 15:14, Petr PIKAL wrote:

Hi


You'll need to save them manually to avoid name conflicts --

save.image()

is the function to do so but you need to give a file name.

Or it is necessary have separate folder for each R session.

Regards
Petr


Michael

On Apr 10, 2012, at 7:41 AM, yaxinxi...@163.com  wrote:


Hi guys,

I have a question. I am running 3 R sessions simultaneously for

different analysis. I found out that when R quit, only objects in one of
these sessions was saved in the work space. How can I save objects of

all

3 R sessions?

Thank you very much.

YA

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

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.

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

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] how to save multiple work space

2012-04-11 Thread ya

Hi Petr and Michael,

Thank you very much for the response.

It worked! Now I can use multiple R sessions simultaneously, I just need 
to save their workspace separately. And If I want those objects in the 
single session, I just load them all in this session, and save the 
workspace again together:)


Thank you very much. This save me lots of time!

Best regards,

ya



On 2012-4-10 15:14, Petr PIKAL wrote:

Hi


You'll need to save them manually to avoid name conflicts --

save.image()

is the function to do so but you need to give a file name.

Or it is necessary have separate folder for each R session.

Regards
Petr


Michael

On Apr 10, 2012, at 7:41 AM, yaxinxi...@163.com  wrote:


Hi guys,

I have a question. I am running 3 R sessions simultaneously for

different analysis. I found out that when R quit, only objects in one of
these sessions was saved in the work space. How can I save objects of

all

3 R sessions?

Thank you very much.

YA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Read .idat Illumina files in R

2012-04-11 Thread Ekta Jain
Dear Bioc and R List Users,
I am having trouble analysing illumine data generated from BeadScan. I have 
.idat files and JPEG images. I realise that i need bead-level summary data to 
be able to begin quality control followed by normalization. Is there a way i 
can read .idat files for expression analysis or do i need to go back to 
BeadScan and generate .txt files/tiff files ?

Appreciate any help here.

Many Thanks,
Ekta Jain
The information contained in this electronic message and in any attachments to 
this message is confidential, legally privileged and intended only for use by 
the person or entity to which this electronic message is addressed. If you are 
not the intended recipient, and have received this message in error, please 
notify the sender and system manager by return email and delete the message and 
its attachments and also you are hereby notified that any distribution, 
copying, review, retransmission, dissemination or other use of this electronic 
transmission or the information contained in it is strictly prohibited. Please 
note that any views or opinions presented in this email are solely those of the 
author and may not represent those of the Company or bind the Company. Any 
commitments made over e-mail are not financially binding on the company unless 
accompanied or followed by a valid purchase order. This message has been 
scanned for viruses and dangerous content by Mail Scanner, a!
 nd is believed to be clean. The Company accepts no liability for any damage 
caused by any virus transmitted by this email.
www.jubl.com

[[alternative HTML version deleted]]

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


[R] Markov-switching VAR estimation and simulation

2012-04-11 Thread mamush bukana
Dear R users,

I need to fit and then simulate the fitted 2 state Markov-switching VAR
model. My google search shows that there is a package called MSVAR for
problems of this kind. But it seems the package is removed from the CRAN
repository.

May I get a help from someone here please?

Thanks

Mamush.

[[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] Problem with effects package

2012-04-11 Thread Michael Kubovy
 sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid  datasets  splines   utils stats
[6] graphics  grDevices methods   base 

other attached packages:
 [1] effects_2.1-0   colorspace_1.1-1   
 [3] nnet_7.3-1  nlme_3.1-103   
 [5] lattice_0.20-6  reshape_0.8.4  
 [7] plyr_1.7.1  catdata_1.0
 [9] cacheSweave_0.6-1   stashR_0.3-5   
[11] filehash_2.2-1  BiocInstaller_1.4.3
[13] ctv_0.7-4   sos_1.3-1  
[15] brew_1.0-6  Hmisc_3.9-3
[17] survival_2.36-12MASS_7.3-17

loaded via a namespace (and not attached):
[1] cluster_1.14.2 digest_0.5.2   tools_2.15.0  

# copy and paste the following:
library( catdata )
data( unemployment )
unempt - unemployment
unempt$durbin - unempt$durbin - 1
library( reshape )
unempt -  melt( table( unempt ) )
unempw - cast( unempt, age ~ durbin )
names( unempw ) - c( 'age', 'short', 'long' )
modt - glm( durbin ~ age, weights = value, family = binomial, data = unempt )
modw - glm( cbind( short, long ) ~ age, family = binomial, data = unempw )
library( effects )
modt.ef - effect( 'age', modt ) # works!
modw.ef - effect( 'age', modw ) # doesn't work!
# Error in eval(expr, envir, enclos) : object 'age' not found
# end

__
Professor Michael Kubovy
University of Virginia
Department of Psychology
for mail add:   for FedEx or UPS add: 
P.O.Box 400400  Gilmer Hall, Room 102
Charlottesville, VA 22904-4400  485 McCormick Road
USA Charlottesville, VA 
22903
roomphone
Office:B011 +1-434-982-4729
Lab:B019+1-434-982-4751
WWW:http://www.people.virginia.edu/~mk9y/


[[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] What is a better way to deal with lag/difference and loops in time series using R?

2012-04-11 Thread Gabor Grothendieck
On Tue, Apr 10, 2012 at 11:21 PM, jpm miao miao...@gmail.com wrote:
 Hello,

   I am writing codes for time series computation but encountering some
 problems

   Given the quarterly data from 1983Q1 to 1984Q2

 PI1-ts(c(2.747365190,2.791594762, -0.009953715, -0.015059485,
 -1.190061246, -0.553031799,  0.686874720,  0.953911035),
 start=c(1983,1), frequency=4)

    If I would like to create a time series vector containing the data in 4
 quarters ahead


    Similar problems happen with the usage of the function diff, which
 calculate the difference. I wonder if it is better to work with the dates
 (1983Q1, 1983Q2,.) directly?

    If I want to write a loop, say, to conduct some computation from 1983Q1
 to 2011Q4, the only way I know is to convert the dates to the ordinal
 indices, 1, 2, 3.. Can we work with the dates? Is there any built-in
 equality that provides the computation like
    1983Q1 +1 equals 1983Q2?
    In EViews, it is easy to do that. We can let %s run from 1983Q1 to
 2011Q4, and he knows that 1983Q1+1 is exactly 1983Q2.


This takes the difference between each point and the point 4 quarters
back and then lags the result forward.

lag(diff(PI1, 4), 4)

In zoo you can do this:

library(zoo)

z - as.zoo(PI1)
time(z) - as.yearqtr(time(z))

# quarter after '83 Q2
z[as.yearqtr(1983 Q2)+1/4]

You might also want to look at rollapply in the zoo package.

xts which is related to zoo has flexible subscripting.

If your data is regular as in your example then you could also use the
tis package which is related to the fame package but can be used
without it.

zoo has several vignettes which give many examples of processing time series.

The timeSeries package is another alternative.

-- 
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] Problem with effects package

2012-04-11 Thread John Fox
Dear Michael,

From ?effect (under Warnings and Limitations):

Binomial generalized linear models cannot have a matrix of successes and 
failures on the left-hand side of the model formula; instead specify the 
proportion of successes (i.e., successes/(successes + failures)) as the 
response, and give the number of binomial trials (i.e., successes + failures) 
in the weights argument to glm.

Best,
 John


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


On Wed, 11 Apr 2012 07:20:51 -0400
 Michael Kubovy kub...@virginia.edu wrote:
  sessionInfo()
 R version 2.15.0 (2012-03-30)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
 
 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
 attached base packages:
 [1] grid  datasets  splines   utils stats
 [6] graphics  grDevices methods   base 
 
 other attached packages:
  [1] effects_2.1-0   colorspace_1.1-1   
  [3] nnet_7.3-1  nlme_3.1-103   
  [5] lattice_0.20-6  reshape_0.8.4  
  [7] plyr_1.7.1  catdata_1.0
  [9] cacheSweave_0.6-1   stashR_0.3-5   
 [11] filehash_2.2-1  BiocInstaller_1.4.3
 [13] ctv_0.7-4   sos_1.3-1  
 [15] brew_1.0-6  Hmisc_3.9-3
 [17] survival_2.36-12MASS_7.3-17
 
 loaded via a namespace (and not attached):
 [1] cluster_1.14.2 digest_0.5.2   tools_2.15.0  
 
 # copy and paste the following:
 library( catdata )
 data( unemployment )
 unempt - unemployment
 unempt$durbin - unempt$durbin - 1
 library( reshape )
 unempt -  melt( table( unempt ) )
 unempw - cast( unempt, age ~ durbin )
 names( unempw ) - c( 'age', 'short', 'long' )
 modt - glm( durbin ~ age, weights = value, family = binomial, data = unempt )
 modw - glm( cbind( short, long ) ~ age, family = binomial, data = unempw )
 library( effects )
 modt.ef - effect( 'age', modt ) # works!
 modw.ef - effect( 'age', modw ) # doesn't work!
 # Error in eval(expr, envir, enclos) : object 'age' not found
 # end
 
 __
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 for mail add: for FedEx or UPS add: 
 P.O.Box 400400Gilmer Hall, Room 102
 Charlottesville, VA 22904-4400485 McCormick Road
 USA   Charlottesville, VA 
 22903
   roomphone
 Office:B011   +1-434-982-4729
 Lab:B019  +1-434-982-4751
 WWW:http://www.people.virginia.edu/~mk9y/


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Michaelson-Morley Speed of Light Data

2012-04-11 Thread Duncan Murdoch

On 12-04-11 12:43 AM, Křištof Želechovski wrote:

URL: http://finzi.psych.upenn.edu/R/library/datasets/html/morley.html

The classical data of Michaelson and Morley on the speed of light

Can you provide more information about the data?  How were they obtained,
etc.?  I do not have the book Genstat Primer and the nearest location where
it is available is University of York which is rather far from my location.


If you can't find the cited reference, I'd try Google.  For instance, it 
led me to this page


http://en.wikipedia.org/wiki/File:Michelsonmorley-boxplot.svg

which appears to show five series.

Duncan Murdoch



Note that the data for the Michelson-Morley experiments [1] consist of 6
experiments of 17 runs each, not of 5 series of 20 runs each.

Best regards,
Christopher Yeleighton

___
[1]URL:
http://en.wikisource.org/wiki/On_the_Relative_Motion_of_the_Earth_and_the_Luminiferous_Ether




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Michaelson-Morley Speed of Light Data

2012-04-11 Thread Prof Brian Ripley

On 11/04/2012 12:42, Duncan Murdoch wrote:

On 12-04-11 12:43 AM, Křištof Želechovski wrote:

URL: http://finzi.psych.upenn.edu/R/library/datasets/html/morley.html

The classical data of Michaelson and Morley on the speed of light

Can you provide more information about the data? How were they obtained,
etc.? I do not have the book Genstat Primer and the nearest location
where
it is available is University of York which is rather far from my
location.


If you can't find the cited reference, I'd try Google. For instance, it
led me to this page

http://en.wikipedia.org/wiki/File:Michelsonmorley-boxplot.svg

which appears to show five series.


Yes, but that is derived from R.

AFAIR the history, Bill Venables got this from Weekes (1986), a book I 
have only ever seen in Adelaide.  A better reference is


 S. M. Stigler (1977) Do robust estimators work with real data?
 Annals of Statistics 5, 1055–1098. (See Table 6.)


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] how to increase the limit for max.print in R

2012-04-11 Thread Gav

Hi Pooja,

You must use options command, something like this

options(max.print=5.5E5)

For more information type? ?options

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

Thanks Bernardo;
cut and paste above line done..

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-increase-the-limit-for-max-print-in-R-tp886412p4548611.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 compare C-index in Cox model

2012-04-11 Thread frank.chiang
Dear List,

If I calculate the C-index after 10-fold cross-validation based on Cox
model, which statistic test 

should I used to compare two C-statistc values.I means I use
cross-validation to obtain a predictive 

probability for each individual, then combine all the probabilities to
calculate the C-index.If I get 

two C-index values(0.73 vs. 0.80) based on two different model, then how to
test the difference is significant.

For the C-index values got from a single dataset, we may use bootstrap to
get the standard error, and 

use wald test to measure whether they are significant different,but if
c-index got from cross-

validation,whether I can still use this method to compare them.


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-compare-C-index-in-Cox-model-tp4548251p4548251.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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread krtek
Hello, I've just installed R-2.15.0 (I've had R 2.13.2 before it and I've
deleted everything before I started to install new version).

When I've tried to run my script by command source() I received this
message:
Error in source(script.R) : 
  7 arguments passed to .Internal(identical) which requires 6

I know I should delete my $R_HOME but it contain only one string:
[1] C:/PROGRA~1/R/R-215~1.0

I don't know what's happened. 

Thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4548460.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] xyplot lattice fine control of axes limits and thick marks (with log scale)

2012-04-11 Thread maxbre
hi, I just realised I want to go a little further in the control of the chart
appearance and I would like to have the same number of ticks displayed in
both axes of all panels

given this code

xyplot(tv ~ ms | sub_family, data=tm, 
  #as.table=TRUE, 
  aspect=xy, 
  xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')), 
  ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')), 
  scales= list(x=list(relation=free, log=10, cex=0.8), 
   y=list(relation=free, log=10, cex=0.8)), 
  prepanel = function(x, y, subscripts) { 
rr- range(cbind(x,y)) 
list(xlim = rr, ylim= rr) 
  }, 
  panel = function(x, y ,subscripts,...) { 
panel.xyplot(x, y, cex=0.8,...) 
panel.abline(a = 0, b = 1, lty = 2, col =gray) 
panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8, pos=3,
offset=0.5, srt=0, adj=c(1,1)) 
  },  
 subscripts=TRUE, 
  xscale.components = xscale.components.logpower, 
  yscale.components = yscale.components.logpower 
  ) 

...I have been trying to insert in the 'prepanel' and also in the 'panel'
the statement 'tick.number=5' but this does not seem to have any effect

some useful hints for this?

thanks a lot




--
View this message in context: 
http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4548502.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] xyplot lattice fine control of axes limits and thick marks (with log scale)

2012-04-11 Thread David Winsemius


On Apr 11, 2012, at 6:28 AM, maxbre wrote:

hi, I just realised I want to go a little further in the control of  
the chart
appearance and I would like to have the same number of ticks  
displayed in

both axes of all panels

given this code

xyplot(tv ~ ms | sub_family, data=tm,
 #as.table=TRUE,
 aspect=xy,
 xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
 ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
 scales= list(x=list(relation=free, log=10, cex=0.8),
  y=list(relation=free, log=10, cex=0.8)),


I'm wondering if you should be using relation=free when you have  
already set a panel specific range for the x and y limits? I'm  
thinking that the panel function may be reversing your earlier  
prepanel efforts. (No data offered  ... why don't you use one of the  
many test datasets in the examples of the lattice package?)




 prepanel = function(x, y, subscripts) {
   rr- range(cbind(x,y))
   list(xlim = rr, ylim= rr)



 },
 panel = function(x, y ,subscripts,...) {
   panel.xyplot(x, y, cex=0.8,...)
   panel.abline(a = 0, b = 1, lty = 2, col =gray)
   panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8,  
pos=3,

offset=0.5, srt=0, adj=c(1,1))
 },
subscripts=TRUE,
 xscale.components = xscale.components.logpower,
 yscale.components = yscale.components.logpower
 )

...I have been trying to insert in the 'prepanel' and also in the  
'panel'
the statement 'tick.number=5' but this does not seem to have any  
effect


some useful hints for this?

thanks a lot



David Winsemius, MD
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] What is a better way to deal with lag/difference and loops in time series using R?

2012-04-11 Thread R. Michael Weylandt
Here's one:

x - xts(1:5, Sys.Date() + 1:5)
y - xts(rep(NA, length(x)), time(x))

or another, less direct but shorter:

y - cbind(x, NA)[,2]

Michael

On Wed, Apr 11, 2012 at 4:16 AM, jpm miao miao...@gmail.com wrote:
 Hello,

    Thank you very much.

    How can I create an empty time series with the same dates as existing
 time series?

    If x is a ts object, then it would be easy:
    y-ts(NA, start=start(x), end=end(x),frequency=frequency(x))

    What can I do if x is a zoo or xts object?
    I come up with a cumbersome way of doing this:
    xts-as.ts(x)
    y1-ts(NA, start=start(y), end=end(y),frequency=frequency(y))
    y-as.xts(y1)

    Is there any easier way to do it?

    Thanks

 miao


 2012/4/11 R. Michael Weylandt michael.weyla...@gmail.com

 Two ways around this:

 I = Easy) Just use zoo/xts objects. ts objects a real pain in the
 proverbial donkey because of things like this.

 Something like:

 library(xts)
 PI1.yq - as.xts(PI1) # Specialty class for quarterly data (or regular
 zoo works)
 lag(PI1.yq)

 II = Hard) lag on a ts actually changes the time indices while keeping
 all the data, [so the fourth data point is the same value -- just a
 different time point] what you may want to do is cbind() the objects
 to see how they line up now.

 cbind(PI1, lag(PI1,4))

 Hope this helps,
 Michael

 On Tue, Apr 10, 2012 at 11:21 PM, jpm miao miao...@gmail.com wrote:
  Hello,
 
    I am writing codes for time series computation but encountering some
  problems
 
    Given the quarterly data from 1983Q1 to 1984Q2
 
  PI1-ts(c(2.747365190,2.791594762, -0.009953715, -0.015059485,
  -1.190061246, -0.553031799,  0.686874720,  0.953911035),
  start=c(1983,1), frequency=4)
 
  PI1
              Qtr1         Qtr2         Qtr3         Qtr4
  1983  2.747365190  2.791594762 -0.009953715 -0.015059485
  1984 -1.190061246 -0.553031799  0.686874720  0.953911035
 
 
     If I would like to create a time series vector containing the data in
  4
  quarters ahead
 
  PI4-lag(PI1,4) PI4             Qtr1         Qtr2         Qtr3
  Qtr4
  1982  2.747365190  2.791594762 -0.009953715 -0.015059485
  1983 -1.190061246 -0.553031799  0.686874720  0.953911035
 
 
     Confusingly, PI1[1] and PI4[1] are exactly the same! I usually would
  like to calculate the difference between the vector of interest and  the
  corresponding values 4 quarters ahead, but it is zero!
 
  PI1[1][1] 2.747365 PI4[1][1] 2.747365
 
 
  One remedy that comes into my mind is to use window,but a warning
  message
  emerges
 
  PI4w-window(PI4, start=start(PI1), end=end(PI1))Warning message:In
  window.default(x, ...) : 'end' value not changed PI4w           Qtr1
  Qtr2       Qtr3       Qtr4
  1983 -1.1900612 -0.5530318  0.6868747  0.9539110
 
 
     Similar problems happen with the usage of the function diff, which
  calculate the difference. I wonder if it is better to work with the
  dates
  (1983Q1, 1983Q2,.) directly?
 
     If I want to write a loop, say, to conduct some computation from
  1983Q1
  to 2011Q4, the only way I know is to convert the dates to the ordinal
  indices, 1, 2, 3.. Can we work with the dates? Is there any built-in
  equality that provides the computation like
     1983Q1 +1 equals 1983Q2?
     In EViews, it is easy to do that. We can let %s run from 1983Q1 to
  2011Q4, and he knows that 1983Q1+1 is exactly 1983Q2.
 
      Thanks very much for your reply!
 
  miao
 
         [[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] convex nonnegative basis vectors in nullspace of matrix

2012-04-11 Thread capy_bara
Dear all,

I want to explore the nullspace of a matrix S: I currently use the function
Null from the MASS package to get a basis for the null space:
 S  = matrix(nrow=3, ncol=5, c(1,0,0,-1,1,1,1,-1,-1,0,-1,0,0,0,-1)); S
 MASS::Null(t(S))
My problem is that I actually need a nonnegative basis for the null space of
S.
There should be a unique set of convex basis vectors spanning a vector space
in which each vector v satisfies sum (S %*%  v) == 0 and min(v)=0. 
Is there maybe an R function that can calculate that for me?
I would appreciate any help, 
Thanks in advance,

Hannes


--
View this message in context: 
http://r.789695.n4.nabble.com/convex-nonnegative-basis-vectors-in-nullspace-of-matrix-tp4548822p4548822.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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread R. Michael Weylandt
Well, obviously the interface to .Internal(identical) changed between
2.13.x and 2.15 -- as, ?.Internal says: Only true R wizards should
even consider using this function...

Anyways, find where you use it in your script and then we can help --
there's not much we can do without seeing the relevant line of code.

Michael

On Wed, Apr 11, 2012 at 5:58 AM, krtek marshal...@mail.ru wrote:
 Hello, I've just installed R-2.15.0 (I've had R 2.13.2 before it and I've
 deleted everything before I started to install new version).

 When I've tried to run my script by command source() I received this
 message:
 Error in source(script.R) :
  7 arguments passed to .Internal(identical) which requires 6

 I know I should delete my $R_HOME but it contain only one string:
 [1] C:/PROGRA~1/R/R-215~1.0

 I don't know what's happened.

 Thank you!

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4548460.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] Merging multiple .csv files

2012-04-11 Thread R. Michael Weylandt
Simply pass all = FALSE to merge_all

merge_all(list_of_files, by = Name, all = FALSE)

Michael

On Wed, Apr 11, 2012 at 1:09 AM, Chintanu chint...@gmail.com wrote:
 Thanks to David and Michael

 Michael:

 That works, however with a glitch. Each of my 24 files has got two columns:
 Name, and Rank/score.

 file_list - list.files()
 list_of_files - lapply(file_list, read.csv) # Read in each file

 # I can see the 2-columns at this stage. However, the following line:

 merge_all(list_of_files, by = Name)

 # produces some NAs for the 2nd column (except the beginning 1/3rd of the
 columns which have values). Not sure about the reason - the original files
 don't have  any NAs.


 Further, I understand that it gives the union of (rows of) files based on
 Name. Is there a way to look for intersection, i.e., similar to using:
 merge ( ,by=Name, all=FALSE)  ?


 David:  It came up with an error :

 do.call(merge, list_of_files, by=Name)

 Error in do.call(merge, list_of_files, by = Name) :
   unused argument(s) (by = Name)

 Cheers,
 Chintanu



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] xyplot lattice fine control of axes limits and thick marks (with log scale)

2012-04-11 Thread David Winsemius


On Apr 11, 2012, at 9:03 AM, David Winsemius wrote:



On Apr 11, 2012, at 6:28 AM, maxbre wrote:

hi, I just realised I want to go a little further in the control of  
the chart
appearance and I would like to have the same number of ticks  
displayed in

both axes of all panels

given this code

xyplot(tv ~ ms | sub_family, data=tm,
#as.table=TRUE,
aspect=xy,
xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
scales= list(x=list(relation=free, log=10, cex=0.8),
 y=list(relation=free, log=10, cex=0.8)),


I'm wondering if you should be using relation=free when you have  
already set a panel specific range for the x and y limits? I'm  
thinking that the panel function may be reversing your earlier  
prepanel efforts. (No data offered  ... why don't you use one of the  
many test datasets in the examples of the lattice package?)


On further meandering up this thread I see that you omitted the  
context of earlier data offerings, so not I in turn offer what I think  
is a your request. Change relation from free to sliced


scales= list(x=list(relation=sliced, log=10, cex=0.8, tick.number=5),
 y=list(relation=sliced, log=10, cex=0.8, tick.number=5))

--
David.






prepanel = function(x, y, subscripts) {
  rr- range(cbind(x,y))
  list(xlim = rr, ylim= rr)



},
panel = function(x, y ,subscripts,...) {
  panel.xyplot(x, y, cex=0.8,...)
  panel.abline(a = 0, b = 1, lty = 2, col =gray)
  panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8,  
pos=3,

offset=0.5, srt=0, adj=c(1,1))
},
subscripts=TRUE,
xscale.components = xscale.components.logpower,
yscale.components = yscale.components.logpower
)

...I have been trying to insert in the 'prepanel' and also in the  
'panel'
the statement 'tick.number=5' but this does not seem to have any  
effect


some useful hints for this?

thanks a lot



David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
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] Question on Counting Factors

2012-04-11 Thread Daniel Gabrieli
Hi,

I hope this is not too trivial, but I've had this recurring problem
and I think there is super easy solution, just not sure what it is.
Please see short example below.  I would like to get the frequency
(counts) of all the variables in a single column (that is easy), but I
would also like to return the value 0 for the absence of variables
defined in another column.

For example:

animals = 
matrix(c('cat','tiger','cat','tiger','fish','fish','dog','dog'),ncol=2,
byrow=F)

animals = as.data.frame(animals)

table(animals$V1)

# Returns the count for the variables in the first column as
cat tiger
   2     2

# But I would like to have table(animals$V1) return

cat tiger  dog  fish
   2     2    0      0


Any help is much appreciated.

Cheers,

Dan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread Prof Brian Ripley

On 11/04/2012 14:08, R. Michael Weylandt wrote:

Well, obviously the interface to .Internal(identical) changed between
2.13.x and 2.15 -- as, ?.Internal says: Only true R wizards should
even consider using this function...

Anyways, find where you use it in your script and then we can help --
there's not much we can do without seeing the relevant line of code.


It may not be in his code.  What is odd is that R 2.15.0's identical() 
does require 6 arguments, whereas in R = R-patched it accepts 6 or 7.


So it looks like something has been done under a later version of R, and 
the usual culprit here is an S4-using package which has captured the 
definition of identical() from a later version of R.


Updating to R-patched may solve the problem.



Michael

On Wed, Apr 11, 2012 at 5:58 AM, krtekmarshal...@mail.ru  wrote:

Hello, I've just installed R-2.15.0 (I've had R 2.13.2 before it and I've
deleted everything before I started to install new version).

When I've tried to run my script by command source() I received this
message:
Error in source(script.R) :
  7 arguments passed to .Internal(identical) which requires 6

I know I should delete my $R_HOME but it contain only one string:
[1] C:/PROGRA~1/R/R-215~1.0

I don't know what's happened.

Thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4548460.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.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Question on Counting Factors

2012-04-11 Thread David Winsemius


On Apr 11, 2012, at 9:21 AM, Daniel Gabrieli wrote:


Hi,

I hope this is not too trivial, but I've had this recurring problem
and I think there is super easy solution, just not sure what it is.
Please see short example below.  I would like to get the frequency
(counts) of all the variables in a single column (that is easy), but I
would also like to return the value 0 for the absence of variables
defined in another column.

For example:

animals =  
matrix 
(c('cat','tiger','cat','tiger','fish','fish','dog','dog'),ncol=2,

byrow=F)

animals = as.data.frame(animals)

table(animals$V1)

# Returns the count for the variables in the first column as
cat tiger
   2 2

# But I would like to have table(animals$V1) return

cat tiger  dog  fish
   2 20  0


You need to add the missing levels to that factor.

 levels(animals$V1) -  
unique( c('cat','tiger','cat','tiger','fish','fish','dog','dog'))

 table(animals$V1)

  cat tiger  fish   dog
2 2 0 0




Any help is much appreciated.

Cheers,

Dan

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


David Winsemius, MD
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] Question on Counting Factors

2012-04-11 Thread David Barron
This would do it in your example:

 levels(animals$V1) - c(cat,tiger,dog,fish)
 table(animals)

cattigerdog fish
  2 200

HTH
David



cat tiger   dog  fish

2 2 0 0


On 11 April 2012 14:21, Daniel Gabrieli daniel.gabri...@gmail.com wrote:

 animals = as.data.frame(animals)

 table(animals$V1)


[[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] Question on Counting Factors

2012-04-11 Thread S Ellison
 I would like to get the frequency
 (counts) of all the variables in a single column (that is 
 easy), but I would also like to return the value 0 for the 
 absence of variables defined in another column.

If you use factor() on your columns and include all the animals in the factor 
levels, you should get what you want.

For example

animal.names - sort(c(fish, dog, tiger, cat))
V1 - sample(c('cat', 'tiger'), 10, replace=TRUE)
V1 - factor(V1, levels=animal.names)
table(V1)

For your data frame, you can get animal.names from your existing data set 
directly rather than specify in advance. If they are all already factors (as 
they will be if you have used as.data.frame on a character matrix) you can get 
all the levels using rapply. Re-using factor will again get you what you're 
after:

animals - 
matrix(c('cat','tiger','cat','tiger','fish','fish','dog','dog'),ncol=2, byrow=F)
animals - as.data.frame(animals)

animal.names - sort(rapply(animals, levels))
animals2 - as.data.frame( lapply(animals, factor, levels=animal.names))
table(animals2$V1)

For extra safety, you might want to wrap the second factor() round an 
as.character:
animal.names - sort(rapply(animals, levels))
animals2 - as.data.frame( lapply(animals, function(x, l) 
factor(as.character(x), levels=l), l=animal.names))
 table(animals2$V1)

S Ellison
***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question on Counting Factors - PS

2012-04-11 Thread S Ellison
 

 -Original Message-
 This would do it in your example:
 
  levels(animals$V1) - c(cat,tiger,dog,fish)
  table(animals)
 
 cattigerdog fish
   2 200

But be very wary of
levels(animals$V2)- c(cat,tiger,dog,fish)
table(animals$V2)

  cat tiger   dog  fish 
2 2 0 0   # !!

levels overwrites factor levels... factor(x, levels = ...) doesn't.

S***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] inference for customized regression in R?

2012-04-11 Thread Michael
Hi all,

Are there functions in R that could help me do the following?

We have a special type of regression which is called Geometric Mean
Regression.

We have done some search and found the following:

https://stat.ethz.ch/pipermail/r-help/2011-July/285022.html

The question is: how to do the statistical inference on GMR results?

More specifically, we are looking for the prediction interval:

Lets say we regress y1, y2, ..., yn onto x1, x2, ..., xn:

we would like to know what's the prediction interval for a new data point:

x_new=x1+x2+x3

(i.e. the new data point is the sum of the existing first three data points)

In ordinary linear regression, we could derive prediction interval for an
in-sample data point as well as a new data point...

For our x_new=x1+x2+x3, we can derive formulas for the prediction interval.

But for the above customized regression,

how do we obtain the prediction intervals?

--

Are there functions in R that can help us do this?

We are thinking of using bootstrapping, etc. Are there functions in R help
us on this?

Thanks a lot!

[[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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread Uwe Ligges



On 11.04.2012 15:27, Prof Brian Ripley wrote:

On 11/04/2012 14:08, R. Michael Weylandt wrote:

Well, obviously the interface to .Internal(identical) changed between
2.13.x and 2.15 -- as, ?.Internal says: Only true R wizards should
even consider using this function...

Anyways, find where you use it in your script and then we can help --
there's not much we can do without seeing the relevant line of code.


It may not be in his code. What is odd is that R 2.15.0's identical()
does require 6 arguments, whereas in R = R-patched it accepts 6 or 7.


I suspect he uses a mixture of R-patched and R-release and / or R-2.13.2 
so that internal code and R code in the package does not match anymore, 
probably because some (outdated?) base package or so is also in an 
additional library on the search path.


uwe




So it looks like something has been done under a later version of R, and
the usual culprit here is an S4-using package which has captured the
definition of identical() from a later version of R.

Updating to R-patched may solve the problem.



Michael

On Wed, Apr 11, 2012 at 5:58 AM, krtekmarshal...@mail.ru wrote:

Hello, I've just installed R-2.15.0 (I've had R 2.13.2 before it and
I've
deleted everything before I started to install new version).

When I've tried to run my script by command source() I received this
message:
Error in source(script.R) :
7 arguments passed to .Internal(identical) which requires 6

I know I should delete my $R_HOME but it contain only one string:
[1] C:/PROGRA~1/R/R-215~1.0

I don't know what's happened.

Thank you!

--
View this message in context:
http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4548460.html

Sent from the R help mailing list archive at Nabble.com.

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


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





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


Re: [R] X11 display problem

2012-04-11 Thread MacQueen, Don
I use ssh -Y in this situation.

You can test with other X client applications, such as xclock. Try running
xclock after your login. If you get the same unable to open message then
it's not an R problem.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/10/12 6:48 AM, carol white wht_...@yahoo.com wrote:

Hi,
I run R on a unix server and login from a Mac with ssh -X. When I want to
run a graphics function like hist, I get the following x11 message:

Error in X11(d$display, d$width, d$height, d$pointsize, d$gamma,
d$colortype,  : 
  unable to start device X11cairo
In addition: Warning message:
In function (display = , width, height, pointsize, gamma, bg,  :
  unable to open connection to X11 display ''

Do I need any library like cairo installed on my local Mac?

I also set LC_CTYPE=en_US.UTF-8 in my profile

Cheers,

Carol
   [[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] inference for customized regression in R?

2012-04-11 Thread R. Michael Weylandt
Given the caveats Ted describes here:
http://tolstoy.newcastle.edu.au/R/help/05/06/5992.html it seems that
bootstrapping might be the only way to get (somewhat) credible
prediction intervals: the boot package on CRAN can help to facilitate
getting these. Here's some documentation for CI:

http://www.statmethods.net/advstats/bootstrapping.html

but you'll need to adopt it for a prediction interval, which might
entail hacking boot.ci().

You might also see if this question, by someone who most certainly
isn't you because cross-posting is discouraged, gets some answers:
http://stats.stackexchange.com/questions/26277/how-to-bootstrap-prediction-intervals-for-customized-regression-models-in-r

Michael Weylandt

On Wed, Apr 11, 2012 at 10:29 AM, Michael comtech@gmail.com wrote:
 Hi all,

 Are there functions in R that could help me do the following?

 We have a special type of regression which is called Geometric Mean
 Regression.

 We have done some search and found the following:

 https://stat.ethz.ch/pipermail/r-help/2011-July/285022.html

 The question is: how to do the statistical inference on GMR results?

 More specifically, we are looking for the prediction interval:

 Lets say we regress y1, y2, ..., yn onto x1, x2, ..., xn:

 we would like to know what's the prediction interval for a new data point:

 x_new=x1+x2+x3

 (i.e. the new data point is the sum of the existing first three data points)

 In ordinary linear regression, we could derive prediction interval for an
 in-sample data point as well as a new data point...

 For our x_new=x1+x2+x3, we can derive formulas for the prediction interval.

 But for the above customized regression,

 how do we obtain the prediction intervals?

 --

 Are there functions in R that can help us do this?

 We are thinking of using bootstrapping, etc. Are there functions in R help
 us on this?

 Thanks a lot!

        [[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] For loops

2012-04-11 Thread MacQueen, Don
In addition to what Jeff and David have said...

If you really want to create a separate data frame for each subgroup then
you need use the assign function, and also data.split[[i]] instead of
data.split[1].

for (i in 1:3) {
   assign( paste('sub',i,sep='') , data.split[[i]]
}

Jeff showed you how to skip the splitting, by subsetting within the loop.

'class' is also a R built-in function name, and thus not a good choice for
one's on use.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/9/12 2:33 PM, Christopher Desjardins cddesjard...@gmail.com wrote:

Hi,
I am having trouble with syntax for a for loop. Here is what I am trying
to
do.

class=c(rep(1,3),rep(2,3),rep(3,3))
out1=rnorm(length(class))
out2=rnorm(length(class))
out3=rnorm(length(class))
data=data.frame(class,out1,out2,out3)

dat.split=split(data,data$class)
  for(i in 1:3){
  sub[i]=dat.split[i]
  }

However, the for loop doesn't work. I want to assign each split to a
different data object. Better yet, how I could assign each class to a
separate object and skip the splitting?

Thanks,
Chris

   [[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] Need help with scraping Google Insight

2012-04-11 Thread Reza Salimi-Khorshidi
Hi all,
I appreciate that if someone please help me with an R solution/code/library
for scraping Google Insight data. It seems difficult to get hold of the URL
corresponding to the resulting CSV file that is appropriate for
*read.csv*or another similar function.
Best, R

[[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] [R-pkgs] mosaic 0.4 on CRAN

2012-04-11 Thread Randall Pruim
One of the products of Project MOSAIC (funded by an NSF CCLI grant)
has been the development of an R package with the goal of making it
easier to use R, especially in teaching situations.  We're not quite
ready to declare that we've reached version 1.0, but version 0.4 does
represent a fairly large step in that direction.  You can find out
more about the package on CRAN or by installing it, but here are some
of the highlights (some example code appears at the end of this
message):

   * extensions of syntax to promote consistency across functions and
make wider use of the formula interface

   * simplified ways of creating and plotting functions, including
extracting model fits as functions

   * a tally() function that combines features of table() and xtabs()
and more in a common syntax

   * expanded syntax for summary functions like mean(), median(),
max(), sd(), var(), etc. that accepts formulas and data frames

   * a do() function that simplifies resampling-based statistical
analysis

   * numerical integration and differentiation to support using
calculus techniques in R

   * first drafts of vignettes on teaching resampling and calculus in R

   * some functions that add extra features to familiar functions
(e.g., xchisq.test(), xhistogram(), xpnorm(), ...)

   * some data sets

If you are using mosaic and discover bugs, or have suggestions for
future development, consider submitting an issue on our github
development site:

http://github.com/rpruim/mosaic/issues/

You can also look there to see what's already on our to-do list.

---rjp (on behalf of the development team that includes Danny Kaplan
 and Nick Horton)


   Randall Pruimphone:  616.526.7113
   Dept. of Mathematics and Statistics  email:  rpr...@calvin.edu
   Calvin College  office:  NH 284
   1740 Knollcrest Circle SE  URL:  http://www.calvin.edu/~rpruim/
   Grand Rapids, MI 49546-4403FAX:  616.526.6501
-

Here are the promised code examples to give you a feel for what mosaic
makes possible:

 mean(age, data=HELPrct)
[1] 35.65342

 mean(~age, data=HELPrct)
[1] 35.65342

 mean(age ~ sex, data=HELPrct)
   female male
36.25234 35.46821

 mean(age ~ sex  treat, data=HELPrct)
  female.nomale.no female.yes   male.yes
   37.56364   35.90173   34.86538   35.03468

 interval(binom.test( ~ eruptions  3, faithful))
probability of success  lower  upper
  0.6433824  0.5832982  0.7003038

 pval(binom.test( ~ eruptions  3, faithful))
  p.value
2.608528e-06

 xchisq.test(phs) # physicians health study example (data entry  
 omitted)

Pearson's Chi-squared test with Yates' continuity correction

data:  phs
X-squared = 24.4291, df = 1, p-value = 7.71e-07

104.00   10933.00
(  146.52) (10890.48)
[12.34]  [ 0.17]
-3.51   0.41

189.00   10845.00
(  146.48) (10887.52)
[12.34]  [ 0.17]
 3.51  -0.41

key:
observed
(expected)
[contribution to X-squared]
residual

 model - lm(length ~ width + sex, KidsFeet)

 L - makeFun(model)

 L( 9.0, 'B')
1
24.80017

 L( 9.0, 'B', interval='confidence')
fit  lwr  upr
1 24.80017 24.30979 25.29055

 xyplot( length ~ width, groups= sex, KidsFeet )  # scatter plot   
 with different symbols for boys and girls

 plotFun(L(x,'B') ~ x, add=TRUE)  # add model fit (for boys) to plot

 plotFun(L(x,'G') ~ x, add=TRUE, lty=2)  # add model fit (for girls)   
 to plot

 rflip(10)  # flip a coin 10 times

Flipping 10 coins [ Prob(Heads) = 0.5 ] ...

T H T H H H T H H T

Result: 6 heads.

 do(2) * rflip(10) # do that twice; notice that do() extracts   
 interesting info
n heads tails
1 10 4 6
2 10 6 4

 ladyTastingTea - do(5000) * rflip(10)  # simulate 5000 ladies
tasting tea

 tally(~heads, ladyTastingTea)

 0 1 2 3 4 5 6 7 8 910 Total
 552   221   573  1032  1227  1027   606   19852 7  5000

 tally(~heads, ladyTastingTea, format='proportion')

  0  1  2  3  4  5  6  7  8
9 10  Total
0.0010 0.0104 0.0442 0.1146 0.2064 0.2454 0.2054 0.1212 0.0396 0.0104   
0.0014 1.

# do() extracts useful information from lm objects so that  
randomization tests are easy.
 do(2) * lm( length ~ width + shuffle(sex), data=KidsFeet )
   Interceptwidth   sexGsigma r-squared
1  9.646822 1.693137 -0.3057453 1.026824 0.4246224
2 11.416739 1.453416  0.4860068 1.013323 0.4396534

 tally( ~ sex  substance, HELPrct )
 substance
sex  alcohol cocaine heroin Total
   female  36  41 30   107
   male   141 111 94   346
   Total  177 152124   453

 tally( ~ sex | substance, HELPrct )  # auto switch to proportions  
 for 

Re: [R] inference for customized regression in R?

2012-04-11 Thread Michael
Hi Michael,

Thank you for your help!

I did some googling and researching... Reading the following article,
http://www.ecd.bnl.gov/pubs/BNL-79819-2008-JA.pdf
It seems that once we estimate the parameters of the bivariate normal
distribution,
then we can plug into the formula of conditional distribution of
Y|X=x1+x2+x3 ?
http://en.wikipedia.org/wiki/Multivariate_normal_distribution
My question is:
Is it a correct procedure to do the following:
Step 1: estimate the parameters of the bivariate normal distribution;
Step 2: plug the estimated parameters into the Y|X=x1+x2+x3 formula and get
the 95% quantile of it?
Do I need to repeat Step 2 many times following the bootstrapping procedure?
Or one shot of Step 2 is enough?
I got very much confused...
Any thoughts?
Thanks a lot!
On Wed, Apr 11, 2012 at 10:12 AM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 Given the caveats Ted describes here:
 http://tolstoy.newcastle.edu.au/R/help/05/06/5992.html it seems that
 bootstrapping might be the only way to get (somewhat) credible
 prediction intervals: the boot package on CRAN can help to facilitate
 getting these. Here's some documentation for CI:

 http://www.statmethods.net/advstats/bootstrapping.html

 but you'll need to adopt it for a prediction interval, which might
 entail hacking boot.ci().

 You might also see if this question, by someone who most certainly
 isn't you because cross-posting is discouraged, gets some answers:

 http://stats.stackexchange.com/questions/26277/how-to-bootstrap-prediction-intervals-for-customized-regression-models-in-r

 Michael Weylandt

 On Wed, Apr 11, 2012 at 10:29 AM, Michael comtech@gmail.com wrote:
  Hi all,
 
  Are there functions in R that could help me do the following?
 
  We have a special type of regression which is called Geometric Mean
  Regression.
 
  We have done some search and found the following:
 
  https://stat.ethz.ch/pipermail/r-help/2011-July/285022.html
 
  The question is: how to do the statistical inference on GMR results?
 
  More specifically, we are looking for the prediction interval:
 
  Lets say we regress y1, y2, ..., yn onto x1, x2, ..., xn:
 
  we would like to know what's the prediction interval for a new data
 point:
 
  x_new=x1+x2+x3
 
  (i.e. the new data point is the sum of the existing first three data
 points)
 
  In ordinary linear regression, we could derive prediction interval for an
  in-sample data point as well as a new data point...
 
  For our x_new=x1+x2+x3, we can derive formulas for the prediction
 interval.
 
  But for the above customized regression,
 
  how do we obtain the prediction intervals?
 
  --
 
  Are there functions in R that can help us do this?
 
  We are thinking of using bootstrapping, etc. Are there functions in R
 help
  us on this?
 
  Thanks a lot!
 
  [[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.htmlhttp://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] multicore/mcparallel error

2012-04-11 Thread Wyatt McMahon
Michael,

Thanks for your help!

I may not be understanding you. I've upgraded to 2.15.  From your text
below, I thought the parallel package was included with R 2.15, but I
cannot find an mclapply function there.  One exists through the multicore
package, which I've now installed.  I also went looking for a parallel
package, but was unable to find one.

Is there an mclapply included in 2.15?  Is there a parallel package I'm
missing?  Or am I completely misunderstanding your response?

Thanks!

Wyatt

-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
Sent: Tuesday, April 10, 2012 12:07 PM
To: Wyatt McMahon
Cc: R-help@r-project.org
Subject: Re: [R] multicore/mcparallel error

I don't know the multicore package, but if possible, it might be easier to
upgrade to 2.15 and use the new built-in parallel package that was
introduced in R 2.14.

Then your syntax would be something like

mclapply(files, illumqc)

Michael

On Tue, Apr 10, 2012 at 11:33 AM, Wyatt McMahon wmcma...@vbi.vt.edu
wrote:
 Hello everyone,



 I'm trying to parallelize an R script I have written.  To do this, I
 am first trying to use the multicore package, because I've had some
 previous success with that.



 The function I'm trying to parallelize is illumqc.  I'd like to create
 a separate process for each of 8 files, contained in the vector files.



 Below is my code:



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

 mcparallel(illumqc(files[i]))}



 I get the following error:



 Error in sendMaster(serialize(try(eval(expr, env), silent = TRUE),
 NULL,
 :

  ignoring SIGPIPE signal

 Calls: mcparallel - sendMaster - .Call

 In addition: Warning message:

 In min(which(alf != 0)) : no non-missing arguments to min; returning
 Inf





 However, if I try and make a simpler example, everything works
 correctly, so I'm not sure what's going wrong with this function.  Do
 I need to post the contents of the function as well?  I'm hoping
 someone can recognize this error and give me a clue as to what is
 going wrong since the function is fairly long.





 Thanks in advance,



 Wyatt











 sessionInfo()

 R version 2.13.1 (2011-07-08)

 Platform: x86_64-unknown-linux-gnu (64-bit)



 locale:

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C

 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8

 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8

 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C

 [9] LC_ADDRESS=C               LC_TELEPHONE=C

 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C



 attached base packages:

 [1] stats     graphics  grDevices utils     datasets  methods   base



 other attached packages:

 [1] ShortRead_1.10.4    Rsamtools_1.4.3     lattice_0.19-30

 [4] Biostrings_2.20.4   GenomicRanges_1.4.8 IRanges_1.10.6

 [7] multicore_0.1-7



 loaded via a namespace (and not attached):

 [1] Biobase_2.12.2 grid_2.13.1    hwriter_1.3


        [[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] For loops

2012-04-11 Thread Clemontina Alexander
This has nothing to do with your question, but instead of using

class=c(rep(1,3),rep(2,3),rep(3,3))


It's probably easier to use class = rep(1:3, each =3)

[[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] Survreg output - interpretation

2012-04-11 Thread mariaeugeniau
Hello R users,
I am analizing survival data (mostly uncensored) and want to extract the
most out of it.
Since I have more than one factor, I´ve read that the survival regression
can help to test the interactions between factors, and then decide how to do
the comparisons using the Log-rank test (survdiff).
1- if I chose the Weibull distribution, does the output inform the goodness
of fit to it? perhaps in this part of the output...

Weibull distribution
Loglik(model)= -1302.8   Loglik(intercept only)= -1311
Chisq= 16.49 on 11 degrees of freedom, p= 0.12 
Number of Newton-Raphson Iterations: 7 
n= 873 

2- one of my factors is gender (2 levels). With survreg, it appears as
significant, but if I compare them with log-rank it turns not significant.
Are they comparing different things? or is it a test power issue?


thank you very much

Eugenia

Lic. M. E. Utgés
INMeT
Argentina

--
View this message in context: 
http://r.789695.n4.nabble.com/Survreg-output-interpretation-tp4549368p4549368.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] nls function

2012-04-11 Thread John C Nash
nls() often gives this message, which is misleading in that it is the Jacobian 
that is not
of full rank in the solution of  J * delta ~ - residuals  or in more 
conventional
Gauss-Newton J' * J delta = -g = - J' * residuals. My view is that the 
gradient itself
cannot be singular. It's just the slope of the sum of squares w.r.t. the 
parameters.

I'm separately sending you an experimental code that does get an answer. It is 
in the
package nlmrt on R-forge
https://r-forge.r-project.org/R/?group_id=395

which is under development.

Note that the I() function doesn't seem to be defined. I left it out to get an 
answer.

John Nash


On 04/11/2012 06:00 AM, r-help-requ...@r-project.org wrote:
 Message: 83
 Date: Tue, 10 Apr 2012 13:03:58 -0700 (PDT)
 From: nerak13 karen.vandep...@gmail.com
 To: r-help@r-project.org
 Subject: [R] nls function
 Message-ID: 1334088238773-4546791.p...@n4.nabble.com
 Content-Type: text/plain; charset=us-ascii
 
 Hi,
 
 I've got the following data:
 
 x-c(1,3,5,7)
 y-c(37.98,11.68,3.65,3.93)
 penetrationks28-dataframe(x=x,y=y)
 
 now I need to fit a non linear function so I did:
 
 fit - nls(y ~ I(a+b*exp(1)^(-c * x)), data = penetrationks28, start =
 list(a=0,b = 1,c=1), trace = T)
 
 The error message I get is:
 Error in nls(y ~ I(a + b * exp(1)^(-c * x)), data = penetrationks28, start =
 list(a = 0,  : 
   singular gradient
 
 I've tried to change the startervalues but it always gives the same error
 
 I've also tried the following adjustment hoping that the c value would be
 negative:
 
 fit - nls(y ~ I(a+b*exp(1)^(c * x)), data = penetrationks28, start = list(a
 = 1,b = 1,c=1), trace = T)
 
 but then the error message is: 
 Error in nls(y ~ I(a + b * exp(1)^(c * x)), data = penetrationks28, start =
 list(a = 1,  : 
   number of iterations exceeded maximum of 50
 
 What can I do ?
 
 Thanks in advance
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/nls-function-tp4546791p4546791.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] strsplit help

2012-04-11 Thread alison waller

Dear all,

I want to use string split to parse column names, however, I am having 
some errors that I don't understand.

I see a problem when I try to rbind the output from strsplit.

please let me know if I'm missing something obvious,

thanks,
alison

here are my commands:
strsplit-strsplit(as.character(Rumino_Reps_agreeWalign$geneid),\\.)
 
Rumino_Reps_agreeWalignTR-transform(Rumino_Reps_agreeWalign,taxid=do.call(rbind, 
strsplit))

Warning message:
In function (..., deparse.level = 1)  :
  number of columns of result is not a multiple of vector length (arg 1)


here is my data:

 head(Rumino_Reps_agreeWalign)
  geneid count_Conser count_NonCons count_ConsSubst
1 657313.locus_tag:RTO_089407 5   5
2   457412.2518480181 4   3
3 657314.locus_tag:CK5_206302 4   1
4 657323.locus_tag:CK1_330601 0   1
5 657313.locus_tag:RTO_096903 0   3
6   471875.1972971060 2   1
  count_NCSubst
1 1
2 0
3 0
4 0
5 1
6 1

here are the results from strsplit:
 head(strsplit)
[[1]]
[1] 657313  locus_tag:RTO_08940

[[2]]
[1] 457412251848018

[[3]]
[1] 657314  locus_tag:CK5_20630

[[4]]
[1] 657323  locus_tag:CK1_33060

[[5]]
[1] 657313  locus_tag:RTO_09690

[[6]]
[1] 471875197297106

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Date formate “ %y-%d-%m “ or “ %m-%d-%y “ ?

2012-04-11 Thread Rui Barradas
Hello,


 I would like to know for each variable what is date format?
 Is it  “ %y-%d-%m “  or  “ %m-%d-%y “   
 
It's 4 digits, with uppercase 'Y'

Try

Data - data.frame(var1=c(12-15-2011, 12-15-2011, 12-17-2001),
var2=c(2001-15-12, 2001-15-01, 2001-15-01),
stringsAsFactors=FALSE )
str(Data)

yr - sapply(sapply(Data, strsplit, -), function(x) which(nchar(x) == 4))
yr
[1] 3 3 3 1 1 1

To have the result with the same dimensions as your original data.frame
(but with a different class, I don't believe it matters)

matrix(yr, ncol=ncol(Data))

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Date-formate-y-d-m-or-m-d-y-tp4548736p4549342.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] [R-SIG-Mac] plot 2 graphs on the same x-y plane

2012-04-11 Thread Susan Gruber
Hi,
A line can be added to an existing plot using the abline function.  For 
example, if a is the intercept and b is the slope, the command would be
   abline(a=a, b=b)

To overlay a new plot on an existing one, use the command: par(new=TRUE).  
For example:

plot(1:10, 1:10)
par(new=TRUE)
plot(log(1:10), 1:10)

This approach often leads to issues with the scale of the axes, tick marks, and 
labels.  Fortunately, R provides the flexibility to deal with all of them. I 
recommend you carefully read the help pages for plot, par, and axis, and have 
some fun playing around with all the options.

--Susan


On Apr 10, 2012, at 11:55 PM, Tawee Laoitichote wrote:

 
 Dear Michael (and Davis), Your answer is not what I want to know. My question 
 is to find any command to plot the data I got from the field; such as a set 
 of (x,y) data ( I actually have these data) and together withe the derived 
 ones . I brought these data to plot on x-y plane,  getting a graph showing 
 some relation. Then, I wanted to find some linear relation, I would use least 
 square method to solve having a simple function such as; y = ax + b, solving 
 the a and b. So, I could plot a straight line using this function, or perhaps 
 forecast some data of y which I know the value x. My problem is when I did a 
 scatter plot by command plot(x,y), I got a graph. Whilst I plotted another 
 graph using the above function the existing graph disappeared replaced be the 
 latter function. Unfortunately, after searching a while to find the solution 
 command, I can not find the command. I asked the question as to request some 
 help not the example you shown. Any way, thanks for you effort. !
 Ta!
 
 wee Mac OS10.7.3
 From: michael.weyla...@gmail.com
 Date: Tue, 10 Apr 2012 23:31:08 -0400
 Subject: Re: [R] plot 2 graphs on the same x-y plane
 To: ohowow2...@hotmail.com
 CC: r-help@r-project.org
 
 This is the same malformatted message you posted on R-SIG-Mac even
 after David specifically asked for clarification not to reward bad
 behavior, but perhaps this will enlighten:
 
 # Minimal reproducible data!
 x - runif(15, 0, 5)
 y - 3*x - 2 + runif(15)
 
 dat - data.frame(x = x, y = y)
 rm(list = c(x, y))
 
 # Base graphics plot using the formula interface
 plot(y ~ x, data = dat)
 abline(lm(y~x, data = dat), col = red3, lwd = 2)
 
 Alternatively
 
 library(ggplot2)
 ggplot(dat, aes(x = x, y = y)) + geom_point() + stat_smooth(method =
 lm, color = I(red3))
 
 which is perhaps overkill in this situation.
 
 
 Michael
 
 On Tue, Apr 10, 2012 at 11:03 PM, Tawee Laoitichote
 ohowow2...@hotmail.com wrote:
 
 
 
 
 hi,  I'm doing some data on least square curve fitting. What I like to have 
 is to compare the scatter plot whilst having the fitting curve on the same 
 coordinates. Any suggestting command besides plot(x,y).  TaweeMac OSX 10.7.3
   [[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-SIG-Mac mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-mac

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


[R] R-help; generating censored data

2012-04-11 Thread Christopher Kelvin
Hello,
 can i implement this as 10% censored data where t gives me failure and x 
censored.
Thank you

p=2;b=120
n=50

set.seed(132);
r-sample(1:50,45)
t-rweibull(r,shape=p,scale=b)
t
set.seed(123); 
cens - sample(1:50, 5) 
x-runif(cens,shape=p,scale=b) 
x

Chris Guure
Researcher,
Institute for Mathematical Research
UPM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [BioC] Read .idat Illumina files in R

2012-04-11 Thread Moiz Bootwalla
Hi Ekta,

You can use the bioconductor package methylumi to read in .idat files. The 
function methylumIDAT() will read in .idat files and provide you with beta 
values along with the M and U values as a MethyLumiSet object. You can then use 
the functions methylumi.bgcorr() and normalizeMethyLumiSet() to background 
correct and normalize your data. See the vignette for more details.

Best,
Moiz


On Apr 11, 2012, at 1:46 AM, Ekta Jain wrote:

 Dear Bioc and R List Users,
 I am having trouble analysing illumine data generated from BeadScan. I have 
 .idat files and JPEG images. I realise that i need bead-level summary data to 
 be able to begin quality control followed by normalization. Is there a way i 
 can read .idat files for expression analysis or do i need to go back to 
 BeadScan and generate .txt files/tiff files ?
 
 Appreciate any help here.
 
 Many Thanks,
 Ekta Jain
 The information contained in this electronic message and in any attachments 
 to this message is confidential, legally privileged and intended only for use 
 by the person or entity to which this electronic message is addressed. If you 
 are not the intended recipient, and have received this message in error, 
 please notify the sender and system manager by return email and delete the 
 message and its attachments and also you are hereby notified that any 
 distribution, copying, review, retransmission, dissemination or other use of 
 this electronic transmission or the information contained in it is strictly 
 prohibited. Please note that any views or opinions presented in this email 
 are solely those of the author and may not represent those of the Company or 
 bind the Company. Any commitments made over e-mail are not financially 
 binding on the company unless accompanied or followed by a valid purchase 
 order. This message has been scanned for viruses and dangerous content by 
 Mail Scanner,!
  a!
 nd is believed to be clean. The Company accepts no liability for any damage 
 caused by any virus transmitted by this email.
 www.jubl.com
 
   [[alternative HTML version deleted]]
 
 ___
 Bioconductor mailing list
 bioconduc...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/bioconductor
 Search the archives: 
 http://news.gmane.org/gmane.science.biology.informatics.conductor

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [BioC] Read .idat Illumina files in R

2012-04-11 Thread Tim Triche, Jr.
Unfortunately, this won't help for expression arrays.  Last time I checked,
those IDATs appeared to be encrypted.

crlmm, methylumi, and minfi can all read IDAT files... *if* they are
version 3 or later (e.g. genotyping, methylation, etc).

Otherwise you are probably stuck with GenomeStudio if it is expression data
you're dealing with.

On Wed, Apr 11, 2012 at 7:14 AM, Moiz Bootwalla msbootwa...@gmail.comwrote:

 Hi Ekta,

 You can use the bioconductor package methylumi to read in .idat files. The
 function methylumIDAT() will read in .idat files and provide you with beta
 values along with the M and U values as a MethyLumiSet object. You can then
 use the functions methylumi.bgcorr() and normalizeMethyLumiSet() to
 background correct and normalize your data. See the vignette for more
 details.

 Best,
 Moiz


 On Apr 11, 2012, at 1:46 AM, Ekta Jain wrote:

  Dear Bioc and R List Users,
  I am having trouble analysing illumine data generated from BeadScan. I
 have .idat files and JPEG images. I realise that i need bead-level summary
 data to be able to begin quality control followed by normalization. Is
 there a way i can read .idat files for expression analysis or do i need to
 go back to BeadScan and generate .txt files/tiff files ?
 
  Appreciate any help here.
 
  Many Thanks,
  Ekta Jain
  The information contained in this electronic message and in any
 attachments to this message is confidential, legally privileged and
 intended only for use by the person or entity to which this electronic
 message is addressed. If you are not the intended recipient, and have
 received this message in error, please notify the sender and system manager
 by return email and delete the message and its attachments and also you are
 hereby notified that any distribution, copying, review, retransmission,
 dissemination or other use of this electronic transmission or the
 information contained in it is strictly prohibited. Please note that any
 views or opinions presented in this email are solely those of the author
 and may not represent those of the Company or bind the Company. Any
 commitments made over e-mail are not financially binding on the company
 unless accompanied or followed by a valid purchase order. This message has
 been scanned for viruses and dangerous content by Mail Scanner,!
   a!
  nd is believed to be clean. The Company accepts no liability for any
 damage caused by any virus transmitted by this email.
  www.jubl.com
 
[[alternative HTML version deleted]]
 
  ___
  Bioconductor mailing list
  bioconduc...@r-project.org
  https://stat.ethz.ch/mailman/listinfo/bioconductor
  Search the archives:
 http://news.gmane.org/gmane.science.biology.informatics.conductor

 ___
 Bioconductor mailing list
 bioconduc...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/bioconductor
 Search the archives:
 http://news.gmane.org/gmane.science.biology.informatics.conductor




-- 
*A model is a lie that helps you see the truth.*
*
*
Howard Skipperhttp://cancerres.aacrjournals.org/content/31/9/1173.full.pdf

[[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] xyplot lattice fine control of axes limits and thick marks (with log scale)

2012-04-11 Thread maxbre
Oh yes, I see now the problem...
thank you

max

--
View this message in context: 
http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4549180.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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread krtek
Thank you!  Updating to R-patched really helped me. 

My problem were not been into my code. I've tried to run source() and the
error had occurred again. I didn't use a mixture of different versions of R,
version 2.13.2 has been deleted.

--
View this message in context: 
http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4549183.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] bayesian gene network construction

2012-04-11 Thread email mail
Hello:

I have looked at the bnlearn and deal packages for infering bayesian
network. Can anyone suggest any other suitable package for constructing
bayesian gene regulatory network using gene expression data?

Thanks!
John

[[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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread R. Michael Weylandt
Can you give the line of code that gives the error? That'd make it
much easier to see what's there that should/shouldn't be.

Michael

On Wed, Apr 11, 2012 at 11:28 AM, krtek marshal...@mail.ru wrote:
 Thank you!  Updating to R-patched really helped me.

 My problem were not been into my code. I've tried to run source() and the
 error had occurred again. I didn't use a mixture of different versions of R,
 version 2.13.2 has been deleted.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4549183.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] row.names in dunes and dunes.env?

2012-04-11 Thread Chris Butler
Hello,

I've got a small dataset on box turtle shell measurements that I would like to 
perform a detrended correspondence analysis on. I thought that it would be 
interesting to examine the morphometrics for each species in the area of 
overlap and in areas where neither species occurs. 

I've taken a look at the dune and dune.env datasets in vegan. Using the str() 
command gives me 

 str(dune)
'data.frame':   20 obs. of  30 variables:
 $ Belper: num  3 0 2 0 0 0 0 2 0 0 ...
 $ Empnig: num  0 0 0 0 0 0 0 0 0 0 ...
 $ Junbuf: num  0 3 0 0 0 0 0 0 0 0 ...
 $ Junart: num  0 0 0 3 0 0 4 0 0 3 ...
 ...

However, when I try looking directly at the data frame using the edit command I 
see that there is a column called row.names to the left of Belper.

Likewise, when I use the str() command on dune.env I get

 str(dune.env)
'data.frame':   20 obs. of  5 variables:
 $ A1        : num  3.5 6 4.2 5.7 4.3 2.8 4.2 6.3 4 11.5 ...
 $ Moisture  : Ord.factor w/ 4 levels 1245: 1 4 2 4 1 1 4 1 2 4 ...
 $ Management: Factor w/ 4 levels BF,HF,NM,..: 1 4 4 4 2 4 2 2 3 3 ...
 $ Use       : Ord.factor w/ 3 levels HayfieldHaypastu..: 2 2 2 3 2 2 3 1 
1 2 ...
 $ Manure    : Ord.factor w/ 5 levels 0123..: 3 4 5 4 3 5 4 3 1 1 
...

but using the edit() command shows a column named row.names.

I assume that the the row.names column is used to link the two files together.

My turtle data is saved as a *.csv, and I've added a column called row.names, 
so that it looks like this

row.names,CL,CCL,CW,CCW,CH,CCH
1,104.4,131.8,89.887,137.4,43.391,89.7
2,108.79,135.9,87.78,118.1,50.72,71.2
3,114.12,126.1,89.33,132.8,142.39,78.3
4,102.87,128.2,84.2,125,45.42,72.4
5,84.6,104.8,72.61,111.8,41.1,57.3

I've called this file turtles_dca.csv. I've also created a file called 
turtles_dca_env.csv that looks like this

row.names,Species,Sex,Distribution,Concatenated,Species_overlap
1,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap
2,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap
3,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap
4,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap
5,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap

However, when I read the data into R using this command

turtles.env = read.csv(turtles_dca_env.csv, header = TRUE)


and then using the str() command I get 


 str(turtles)
'data.frame':   67 obs. of  7 variables:
 $ row.names: int  1 2 3 4 5 6 7 8 9 10 ...
 $ CL       : num  104.4 108.8 114.1 102.9 84.6 ...
 $ CCL      : num  132 136 126 128 105 ...
 $ CW       : num  89.9 87.8 89.3 84.2 72.6 ...
 $ CCW      : num  137 118 133 125 112 ...
 $ CH       : num  43.4 50.7 142.4 45.4 41.1 ...
 $ CCH      : num  89.7 71.2 78.3 72.4 57.3 73.4 67 57 68.8 68 ...

When I run decorana() on this dataset, it appears that the column row.names 
is included in the analysis, which isn't what I'm looking for. 

If I go ahead and delete the column row.names from my data frames (i.e. 
removing it from turtles and turtles.env), I don't believe that the analysis is 
performed correctly. The two species differ significantly in most of their 
measurements, but the ordihull() and ordispider() commands show them 
overlapping almost completely.

I think that I'm missing something pretty basic about inputting and formatting 
this data for this analysis. Can anyone offer a suggestion on where I'm going 
astray? I can send a copy of the data if anyone wants to look at it.

Best wishes,
Chris
University of Central Oklahoma
[[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] multicore/mcparallel error

2012-04-11 Thread R. Michael Weylandt
Parallel is one of those packages (like tools or grid) that is not
loaded by default, but comes with the standard installation.

Running library(parallel) will make mclapply() available. Then (at
least for me) it's easy to parallelize some code:

system.time(lapply(1:5, function(x) max(rnorm(500 # ~ 8 seconds

system.time(mclapply(1:5, function(x) max(rnorm(500 # ~ 4.4
seconds [I have two processors]

Michael

On Wed, Apr 11, 2012 at 12:34 PM, Wyatt McMahon wmcma...@vbi.vt.edu wrote:
 Michael,

 Thanks for your help!

 I may not be understanding you. I've upgraded to 2.15.  From your text
 below, I thought the parallel package was included with R 2.15, but I
 cannot find an mclapply function there.  One exists through the multicore
 package, which I've now installed.  I also went looking for a parallel
 package, but was unable to find one.

 Is there an mclapply included in 2.15?  Is there a parallel package I'm
 missing?  Or am I completely misunderstanding your response?

 Thanks!

 Wyatt

 -Original Message-
 From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
 Sent: Tuesday, April 10, 2012 12:07 PM
 To: Wyatt McMahon
 Cc: R-help@r-project.org
 Subject: Re: [R] multicore/mcparallel error

 I don't know the multicore package, but if possible, it might be easier to
 upgrade to 2.15 and use the new built-in parallel package that was
 introduced in R 2.14.

 Then your syntax would be something like

 mclapply(files, illumqc)

 Michael

 On Tue, Apr 10, 2012 at 11:33 AM, Wyatt McMahon wmcma...@vbi.vt.edu
 wrote:
 Hello everyone,



 I'm trying to parallelize an R script I have written.  To do this, I
 am first trying to use the multicore package, because I've had some
 previous success with that.



 The function I'm trying to parallelize is illumqc.  I'd like to create
 a separate process for each of 8 files, contained in the vector files.



 Below is my code:



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

 mcparallel(illumqc(files[i]))}



 I get the following error:



 Error in sendMaster(serialize(try(eval(expr, env), silent = TRUE),
 NULL,
 :

  ignoring SIGPIPE signal

 Calls: mcparallel - sendMaster - .Call

 In addition: Warning message:

 In min(which(alf != 0)) : no non-missing arguments to min; returning
 Inf





 However, if I try and make a simpler example, everything works
 correctly, so I'm not sure what's going wrong with this function.  Do
 I need to post the contents of the function as well?  I'm hoping
 someone can recognize this error and give me a clue as to what is
 going wrong since the function is fairly long.





 Thanks in advance,



 Wyatt











 sessionInfo()

 R version 2.13.1 (2011-07-08)

 Platform: x86_64-unknown-linux-gnu (64-bit)



 locale:

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C

 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8

 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8

 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C

 [9] LC_ADDRESS=C               LC_TELEPHONE=C

 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C



 attached base packages:

 [1] stats     graphics  grDevices utils     datasets  methods   base



 other attached packages:

 [1] ShortRead_1.10.4    Rsamtools_1.4.3     lattice_0.19-30

 [4] Biostrings_2.20.4   GenomicRanges_1.4.8 IRanges_1.10.6

 [7] multicore_0.1-7



 loaded via a namespace (and not attached):

 [1] Biobase_2.12.2 grid_2.13.1    hwriter_1.3


        [[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] multicore/mcparallel error

2012-04-11 Thread Wyatt McMahon
Thanks a ton, Michael!  Everything is running much faster now!!

Wyatt

-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
Sent: Wednesday, April 11, 2012 1:41 PM
To: Wyatt McMahon
Cc: R-help@r-project.org
Subject: Re: [R] multicore/mcparallel error

Parallel is one of those packages (like tools or grid) that is not loaded
by default, but comes with the standard installation.

Running library(parallel) will make mclapply() available. Then (at least
for me) it's easy to parallelize some code:

system.time(lapply(1:5, function(x) max(rnorm(500 # ~ 8 seconds

system.time(mclapply(1:5, function(x) max(rnorm(500 # ~ 4.4
seconds [I have two processors]

Michael

On Wed, Apr 11, 2012 at 12:34 PM, Wyatt McMahon wmcma...@vbi.vt.edu
wrote:
 Michael,

 Thanks for your help!

 I may not be understanding you. I've upgraded to 2.15.  From your text
 below, I thought the parallel package was included with R 2.15, but I
 cannot find an mclapply function there.  One exists through the
 multicore package, which I've now installed.  I also went looking for a
parallel
 package, but was unable to find one.

 Is there an mclapply included in 2.15?  Is there a parallel package
 I'm missing?  Or am I completely misunderstanding your response?

 Thanks!

 Wyatt

 -Original Message-
 From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
 Sent: Tuesday, April 10, 2012 12:07 PM
 To: Wyatt McMahon
 Cc: R-help@r-project.org
 Subject: Re: [R] multicore/mcparallel error

 I don't know the multicore package, but if possible, it might be
 easier to upgrade to 2.15 and use the new built-in parallel package
 that was introduced in R 2.14.

 Then your syntax would be something like

 mclapply(files, illumqc)

 Michael

 On Tue, Apr 10, 2012 at 11:33 AM, Wyatt McMahon wmcma...@vbi.vt.edu
 wrote:
 Hello everyone,



 I'm trying to parallelize an R script I have written.  To do this, I
 am first trying to use the multicore package, because I've had some
 previous success with that.



 The function I'm trying to parallelize is illumqc.  I'd like to
 create a separate process for each of 8 files, contained in the vector
files.



 Below is my code:



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

 mcparallel(illumqc(files[i]))}



 I get the following error:



 Error in sendMaster(serialize(try(eval(expr, env), silent = TRUE),
 NULL,
 :

  ignoring SIGPIPE signal

 Calls: mcparallel - sendMaster - .Call

 In addition: Warning message:

 In min(which(alf != 0)) : no non-missing arguments to min; returning
 Inf





 However, if I try and make a simpler example, everything works
 correctly, so I'm not sure what's going wrong with this function.  Do
 I need to post the contents of the function as well?  I'm hoping
 someone can recognize this error and give me a clue as to what is
 going wrong since the function is fairly long.





 Thanks in advance,



 Wyatt











 sessionInfo()

 R version 2.13.1 (2011-07-08)

 Platform: x86_64-unknown-linux-gnu (64-bit)



 locale:

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C

 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8

 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8

 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C

 [9] LC_ADDRESS=C               LC_TELEPHONE=C

 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C



 attached base packages:

 [1] stats     graphics  grDevices utils     datasets  methods   base



 other attached packages:

 [1] ShortRead_1.10.4    Rsamtools_1.4.3     lattice_0.19-30

 [4] Biostrings_2.20.4   GenomicRanges_1.4.8 IRanges_1.10.6

 [7] multicore_0.1-7



 loaded via a namespace (and not attached):

 [1] Biobase_2.12.2 grid_2.13.1    hwriter_1.3


        [[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] strsplit help

2012-04-11 Thread Jean V Adams
Alison,

Your code works fine on the first six lines of the data that you provided.

Rumino_Reps_agreeWalign - data.frame(
geneid = c(657313.locus_tag:RTO_08940, 
457412.251848018, 
657314.locus_tag:CK5_20630, 
657323.locus_tag:CK1_33060, 
657313.locus_tag:RTO_09690, 
471875.197297106), 
count_Conser = c(7, 1, 2, 1, 3, 0),
count_NonCons = c(5, 4, 4, 0, 0, 2), 
count_ConsSubst = c(5, 3, 1, 1, 3, 1), 
count_NCSubst = c(1, 0, 0, 0, 1, 1))
gene.list - strsplit(as.character(Rumino_Reps_agreeWalign$geneid), \\.)
Rumino_Reps_agreeWalignTR - transform(Rumino_Reps_agreeWalign, 
taxid=do.call(rbind, gene.list))

Perhaps in later rows of the data there are cases where there is no . in 
geneid?  If not, can you provide a subset of your data that results in the 
warning?  Use the dput() function.

It's not a good idea to create an object named strsplit.  That will only 
mask the function strsplit() in later runs.

If time is an issue, a slightly faster way to do this, after the 
strsplit() function is:
Rumino_Reps_agreeWalign$geneid.prefix - sapply(gene.list, [, 1)
Rumino_Reps_agreeWalign$geneid.suffix - sapply(gene.list, [, 2)

Jean


alison waller wrote on 04/11/2012 08:23:29 AM:

 Dear all,
 
 I want to use string split to parse column names, however, I am having 
 some errors that I don't understand.
 I see a problem when I try to rbind the output from strsplit.
 
 please let me know if I'm missing something obvious,
 
 thanks,
 alison
 
 here are my commands:
  strsplit-strsplit(as.character(Rumino_Reps_agreeWalign$geneid),\\.)
   
 Rumino_Reps_agreeWalignTR-transform
 (Rumino_Reps_agreeWalign,taxid=do.call(rbind, 
 strsplit))
 Warning message:
 In function (..., deparse.level = 1)  :
number of columns of result is not a multiple of vector length (arg 
1)
 
 
 here is my data:
 
   head(Rumino_Reps_agreeWalign)
geneid count_Conser count_NonCons count_ConsSubst
 1 657313.locus_tag:RTO_089407 5   5
 2   457412.2518480181 4   3
 3 657314.locus_tag:CK5_206302 4   1
 4 657323.locus_tag:CK1_330601 0   1
 5 657313.locus_tag:RTO_096903 0   3
 6   471875.1972971060 2   1
count_NCSubst
 1 1
 2 0
 3 0
 4 0
 5 1
 6 1
 
 here are the results from strsplit:
   head(strsplit)
 [[1]]
 [1] 657313  locus_tag:RTO_08940
 
 [[2]]
 [1] 457412251848018
 
 [[3]]
 [1] 657314  locus_tag:CK5_20630
 
 [[4]]
 [1] 657323  locus_tag:CK1_33060
 
 [[5]]
 [1] 657313  locus_tag:RTO_09690
 
 [[6]]
 [1] 471875197297106

[[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] Lattice densityplot with semitransparent filled regions

2012-04-11 Thread Walmes Zeviani
Hello,

I'm doing some graphics for a paper and a need customize such with filled
region above the density curve. My attempts I get something very near what
I need, but I don't solve the problem of use semitransparent filled. Below
a minimal reproducible code. Someone has any idea?

require(lattice)

# toy data...
dt - expand.grid(A=1:2, B=1:3, y=1:50)
dt$y - rnorm(nrow(dt), dt$B, dt$A)

# regular plot...
densityplot(~y|B, groups=A, data=dt, plot.points=rug)

# the actual panel...
panel.densityplot

# so, I edit this...
my.panel.densityplot -
function (x, darg = list(n = 30), plot.points = jitter, ref = FALSE,
groups = NULL, weights = NULL, jitter.amount = 0.01 *
diff(current.panel.limits()$ylim),
type = p, ..., identifier = density)
{
if (ref) {
reference.line - trellis.par.get(reference.line)
panel.abline(h = 0, col = reference.line$col, lty =
reference.line$lty,
lwd = reference.line$lwd, identifier = paste(identifier,
abline))
}
if (!is.null(groups)) {
panel.superpose(x, darg = darg, plot.points = plot.points,
ref = FALSE, groups = groups, weights = weights,
panel.groups = panel.densityplot, jitter.amount =
jitter.amount, # alterei para my.panel
type = type, ...)
}
else {
switch(as.character(plot.points), `TRUE` = panel.xyplot(x = x,
y = rep(0, length(x)), type = type, ..., identifier =
identifier),
rug = panel.rug(x = x, start = 0, end = 0, x.units = c(npc,
native), type = type, ..., identifier = paste(identifier,
rug)), jitter = panel.xyplot(x = x, y = jitter(rep(0,
length(x)), amount = jitter.amount), type = type,
..., identifier = identifier))
density.fun - function(x, weights, subscripts = TRUE,
darg, ...) {
do.call(density, c(list(x = x, weights =
weights[subscripts]),
darg))
}
if (sum(!is.na(x))  1) {
h - density.fun(x = x, weights = weights, ..., darg = darg)
lim - current.panel.limits()$xlim
id - h$x  min(lim)  h$x  max(lim)
panel.lines(x = h$x[id], y = h$y[id], ..., identifier =
identifier)
## line above was added
panel.polygon(x=h$x[id], y = h$y[id], ..., identifier =
identifier, alpha=0.2)
}
}
}

# my customized plot, I want semitransparent colors
# and use the colors of trellis.par.set(superpose.polygon) to fill
densityplot(~y|B, groups=A, data=dt,
plot.points=rug, col=2:3,
panel=panel.superpose,
panel.groups=my.panel.densityplot)

Thanks!
Walmes.

==
Walmes Marques Zeviani
LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
Departamento de Estatística - Universidade Federal do Paraná
fone: (+55) 41 3361 3573
VoIP: (3361 3600) 1053 1173
e-mail: wal...@ufpr.br
twitter: @walmeszeviani
homepage: http://www.leg.ufpr.br/~walmes
linux user number: 531218
==

[[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] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread Henrik Bengtsson
FYI,

whenever getting an error, run traceback() *immediately after* (i.e.
before any other commands) and include that in your error report.
Also include the output of sessionInfo().  It helps tremendously and
spares lots of second guessing.

/Henrik

On Wed, Apr 11, 2012 at 8:28 AM, krtek marshal...@mail.ru wrote:
 Thank you!  Updating to R-patched really helped me.

 My problem were not been into my code. I've tried to run source() and the
 error had occurred again. I didn't use a mixture of different versions of R,
 version 2.13.2 has been deleted.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/7-arguments-passed-to-Internal-identical-which-requires-6-tp4548460p4549183.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] strsplit help

2012-04-11 Thread David Winsemius


On Apr 11, 2012, at 2:01 PM, Jean V Adams wrote:


Alison,

Your code works fine on the first six lines of the data that you  
provided.


Rumino_Reps_agreeWalign - data.frame(
   geneid = c(657313.locus_tag:RTO_08940,
   457412.251848018,
   657314.locus_tag:CK5_20630,
   657323.locus_tag:CK1_33060,
   657313.locus_tag:RTO_09690,
   471875.197297106),
   count_Conser = c(7, 1, 2, 1, 3, 0),
   count_NonCons = c(5, 4, 4, 0, 0, 2),
   count_ConsSubst = c(5, 3, 1, 1, 3, 1),
   count_NCSubst = c(1, 0, 0, 0, 1, 1))
gene.list - strsplit(as.character(Rumino_Reps_agreeWalign$geneid),  
\\.)

Rumino_Reps_agreeWalignTR - transform(Rumino_Reps_agreeWalign,
   taxid=do.call(rbind, gene.list))

Perhaps in later rows of the data there are cases where there is no  
. in
geneid?  If not, can you provide a subset of your data that results  
in the

warning?  Use the dput() function.

It's not a good idea to create an object named strsplit.  That  
will only

mask the function strsplit() in later runs.


There is not a problem with masking the function unless the new name  
is replaced with a language object (which wasn't the case here). The  
potential confusion is in minds of users. Function names are stored  
separately from non-language object names so you can have a data  
object named 'strsplit' and it will not mask the function 'strsplit'.


--
David.


If time is an issue, a slightly faster way to do this, after the
strsplit() function is:
Rumino_Reps_agreeWalign$geneid.prefix - sapply(gene.list, [, 1)
Rumino_Reps_agreeWalign$geneid.suffix - sapply(gene.list, [, 2)

Jean


alison waller wrote on 04/11/2012 08:23:29 AM:


Dear all,

I want to use string split to parse column names, however, I am  
having

some errors that I don't understand.
I see a problem when I try to rbind the output from strsplit.

please let me know if I'm missing something obvious,

thanks,
alison

here are my commands:
strsplit-strsplit(as.character(Rumino_Reps_agreeWalign$geneid),\ 
\.)



Rumino_Reps_agreeWalignTR-transform
(Rumino_Reps_agreeWalign,taxid=do.call(rbind,
strsplit))
Warning message:
In function (..., deparse.level = 1)  :
  number of columns of result is not a multiple of vector length (arg

1)



here is my data:


head(Rumino_Reps_agreeWalign)
  geneid count_Conser count_NonCons  
count_ConsSubst
1 657313.locus_tag:RTO_089407  
5   5
2   457412.2518480181  
4   3
3 657314.locus_tag:CK5_206302  
4   1
4 657323.locus_tag:CK1_330601  
0   1
5 657313.locus_tag:RTO_096903  
0   3
6   471875.1972971060  
2   1

  count_NCSubst
1 1
2 0
3 0
4 0
5 1
6 1

here are the results from strsplit:

head(strsplit)

[[1]]
[1] 657313  locus_tag:RTO_08940

[[2]]
[1] 457412251848018

[[3]]
[1] 657314  locus_tag:CK5_20630

[[4]]
[1] 657323  locus_tag:CK1_33060

[[5]]
[1] 657313  locus_tag:RTO_09690

[[6]]
[1] 471875197297106


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


David Winsemius, MD
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] strsplit help

2012-04-11 Thread Jean V Adams
David,

Right you are!  Thanks for pointing that out.

strsplit - 1:10
strsplit(With spaces, NULL)
strsplit

Jean


David Winsemius dwinsem...@comcast.net wrote on 04/11/2012 01:17:07 PM:

 [image removed] 
 
 Re: [R] strsplit help
 
 David Winsemius 
 
 to:
 
 Jean V Adams
 
 04/11/2012 01:19 PM
 
 Cc:
 
 alison waller, r-help
 
 
 On Apr 11, 2012, at 2:01 PM, Jean V Adams wrote:
 
  Alison,
 
  Your code works fine on the first six lines of the data that you 
  provided.
 
  Rumino_Reps_agreeWalign - data.frame(
 geneid = c(657313.locus_tag:RTO_08940,
 457412.251848018,
 657314.locus_tag:CK5_20630,
 657323.locus_tag:CK1_33060,
 657313.locus_tag:RTO_09690,
 471875.197297106),
 count_Conser = c(7, 1, 2, 1, 3, 0),
 count_NonCons = c(5, 4, 4, 0, 0, 2),
 count_ConsSubst = c(5, 3, 1, 1, 3, 1),
 count_NCSubst = c(1, 0, 0, 0, 1, 1))
  gene.list - strsplit(as.character(Rumino_Reps_agreeWalign$geneid), 
  \\.)
  Rumino_Reps_agreeWalignTR - transform(Rumino_Reps_agreeWalign,
 taxid=do.call(rbind, gene.list))
 
  Perhaps in later rows of the data there are cases where there is no 
  . in
  geneid?  If not, can you provide a subset of your data that results 
  in the
  warning?  Use the dput() function.
 
  It's not a good idea to create an object named strsplit.  That 
  will only
  mask the function strsplit() in later runs.
 
 There is not a problem with masking the function unless the new name 
 is replaced with a language object (which wasn't the case here). The 
 potential confusion is in minds of users. Function names are stored 
 separately from non-language object names so you can have a data 
 object named 'strsplit' and it will not mask the function 'strsplit'.
 
 -- 
 David.
 
  If time is an issue, a slightly faster way to do this, after the
  strsplit() function is:
  Rumino_Reps_agreeWalign$geneid.prefix - sapply(gene.list, [, 1)
  Rumino_Reps_agreeWalign$geneid.suffix - sapply(gene.list, [, 2)
 
  Jean
 
 
  alison waller wrote on 04/11/2012 08:23:29 AM:
 
  Dear all,
 
  I want to use string split to parse column names, however, I am 
  having
  some errors that I don't understand.
  I see a problem when I try to rbind the output from strsplit.
 
  please let me know if I'm missing something obvious,
 
  thanks,
  alison
 
  here are my commands:
  strsplit-strsplit(as.character(Rumino_Reps_agreeWalign$geneid),\ 
  \.)
 
  Rumino_Reps_agreeWalignTR-transform
  (Rumino_Reps_agreeWalign,taxid=do.call(rbind,
  strsplit))
  Warning message:
  In function (..., deparse.level = 1)  :
number of columns of result is not a multiple of vector length (arg
  1)
 
 
  here is my data:
 
  head(Rumino_Reps_agreeWalign)
geneid count_Conser count_NonCons 
  count_ConsSubst
  1 657313.locus_tag:RTO_089407 
  5   5
  2   457412.2518480181 
  4   3
  3 657314.locus_tag:CK5_206302 
  4   1
  4 657323.locus_tag:CK1_330601 
  0   1
  5 657313.locus_tag:RTO_096903 
  0   3
  6   471875.1972971060 
  2   1
count_NCSubst
  1 1
  2 0
  3 0
  4 0
  5 1
  6 1
 
  here are the results from strsplit:
  head(strsplit)
  [[1]]
  [1] 657313  locus_tag:RTO_08940
 
  [[2]]
  [1] 457412251848018
 
  [[3]]
  [1] 657314  locus_tag:CK5_20630
 
  [[4]]
  [1] 657323  locus_tag:CK1_33060
 
  [[5]]
  [1] 657313  locus_tag:RTO_09690
 
  [[6]]
  [1] 471875197297106
 
 [[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.
 
 David Winsemius, MD
 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] nls function

2012-04-11 Thread peter dalgaard

On Apr 11, 2012, at 16:51 , John C Nash wrote:

 nls() often gives this message, which is misleading in that it is the 
 Jacobian that is not
 of full rank in the solution of  J * delta ~ - residuals  or in more 
 conventional
 Gauss-Newton J' * J delta = -g = - J' * residuals. My view is that the 
 gradient itself
 cannot be singular. It's just the slope of the sum of squares w.r.t. the 
 parameters.

That's one view, John, but the more common one is that it is the gradient 
matrix of the fitted values with respect to the parameters that is singular. 
I.e., we are locally approximating the nonlinear relation y=f(theta0+delta) 
with the linear one y-f(theta0)= (Df)delta, in which Df can be singular in the 
usual matrix sense.

That said, I completely agree that it is silly to let this condition be a 
show-stopper when it happens early in the iteration sequence. As long as you 
can move in _any_ direction and improve the sum of squares, why not go there 
and retry?

 I'm separately sending you an experimental code that does get an answer. It 
 is in the
 package nlmrt on R-forge
 https://r-forge.r-project.org/R/?group_id=395
 
 which is under development.
 
 Note that the I() function doesn't seem to be defined. I left it out to get 
 an answer.
 
 John Nash
 
 
 On 04/11/2012 06:00 AM, r-help-requ...@r-project.org wrote:
 Message: 83
 Date: Tue, 10 Apr 2012 13:03:58 -0700 (PDT)
 From: nerak13 karen.vandep...@gmail.com
 To: r-help@r-project.org
 Subject: [R] nls function
 Message-ID: 1334088238773-4546791.p...@n4.nabble.com
 Content-Type: text/plain; charset=us-ascii
 
 Hi,
 
 I've got the following data:
 
 x-c(1,3,5,7)
 y-c(37.98,11.68,3.65,3.93)
 penetrationks28-dataframe(x=x,y=y)
 
 now I need to fit a non linear function so I did:
 
 fit - nls(y ~ I(a+b*exp(1)^(-c * x)), data = penetrationks28, start =
 list(a=0,b = 1,c=1), trace = T)
 
 The error message I get is:
 Error in nls(y ~ I(a + b * exp(1)^(-c * x)), data = penetrationks28, start =
 list(a = 0,  : 
  singular gradient
 
 I've tried to change the startervalues but it always gives the same error
 
 I've also tried the following adjustment hoping that the c value would be
 negative:
 
 fit - nls(y ~ I(a+b*exp(1)^(c * x)), data = penetrationks28, start = list(a
 = 1,b = 1,c=1), trace = T)
 
 but then the error message is: 
 Error in nls(y ~ I(a + b * exp(1)^(c * x)), data = penetrationks28, start =
 list(a = 1,  : 
  number of iterations exceeded maximum of 50
 
 What can I do ?
 
 Thanks in advance
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/nls-function-tp4546791p4546791.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.

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

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


Re: [R] Lattice densityplot with semitransparent filled regions

2012-04-11 Thread ilai
 densityplot(~y|B, groups=A, data=dt,
plot.points=rug,
col=trellis.par.get(superpose.polygon)$col, alpha=.5,
panel=panel.superpose,
panel.groups=my.panel.densityplot)

Worked for me (i.e. semi-transparent superpose.polygon colors). Is
that not what you are seeing ?


On Wed, Apr 11, 2012 at 12:05 PM, Walmes Zeviani
walmeszevi...@gmail.com wrote:
 Hello,

 I'm doing some graphics for a paper and a need customize such with filled
 region above the density curve. My attempts I get something very near what
 I need, but I don't solve the problem of use semitransparent filled. Below
 a minimal reproducible code. Someone has any idea?

 require(lattice)

 # toy data...
 dt - expand.grid(A=1:2, B=1:3, y=1:50)
 dt$y - rnorm(nrow(dt), dt$B, dt$A)

 # regular plot...
 densityplot(~y|B, groups=A, data=dt, plot.points=rug)

 # the actual panel...
 panel.densityplot

 # so, I edit this...
 my.panel.densityplot -
 function (x, darg = list(n = 30), plot.points = jitter, ref = FALSE,
    groups = NULL, weights = NULL, jitter.amount = 0.01 *
 diff(current.panel.limits()$ylim),
    type = p, ..., identifier = density)
 {
    if (ref) {
        reference.line - trellis.par.get(reference.line)
        panel.abline(h = 0, col = reference.line$col, lty =
 reference.line$lty,
            lwd = reference.line$lwd, identifier = paste(identifier,
                abline))
    }
    if (!is.null(groups)) {
        panel.superpose(x, darg = darg, plot.points = plot.points,
            ref = FALSE, groups = groups, weights = weights,
            panel.groups = panel.densityplot, jitter.amount =
 jitter.amount, # alterei para my.panel
            type = type, ...)
    }
    else {
        switch(as.character(plot.points), `TRUE` = panel.xyplot(x = x,
            y = rep(0, length(x)), type = type, ..., identifier =
 identifier),
            rug = panel.rug(x = x, start = 0, end = 0, x.units = c(npc,
                native), type = type, ..., identifier = paste(identifier,
                rug)), jitter = panel.xyplot(x = x, y = jitter(rep(0,
                length(x)), amount = jitter.amount), type = type,
                ..., identifier = identifier))
        density.fun - function(x, weights, subscripts = TRUE,
            darg, ...) {
            do.call(density, c(list(x = x, weights =
 weights[subscripts]),
                darg))
        }
        if (sum(!is.na(x))  1) {
            h - density.fun(x = x, weights = weights, ..., darg = darg)
            lim - current.panel.limits()$xlim
            id - h$x  min(lim)  h$x  max(lim)
            panel.lines(x = h$x[id], y = h$y[id], ..., identifier =
 identifier)
 ## line above was added
            panel.polygon(x=h$x[id], y = h$y[id], ..., identifier =
 identifier, alpha=0.2)
        }
    }
 }

 # my customized plot, I want semitransparent colors
 # and use the colors of trellis.par.set(superpose.polygon) to fill
 densityplot(~y|B, groups=A, data=dt,
            plot.points=rug, col=2:3,
            panel=panel.superpose,
            panel.groups=my.panel.densityplot)

 Thanks!
 Walmes.

 ==
 Walmes Marques Zeviani
 LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
 Departamento de Estatística - Universidade Federal do Paraná
 fone: (+55) 41 3361 3573
 VoIP: (3361 3600) 1053 1173
 e-mail: wal...@ufpr.br
 twitter: @walmeszeviani
 homepage: http://www.leg.ufpr.br/~walmes
 linux user number: 531218
 ==

        [[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] Partial Dependence and RandomForest

2012-04-11 Thread jmc
Hello all~

I am interested in clarifying something more conceptual, so I won't be
providing any data or code here.  

From what I understand, partial dependence plots can help you understand the
relative dependence on a variable, and the subsequent values of that
variable, after averaging out the effects of the other input variables. 
This is great, but what I am interested in knowing is how that relates to
each predictor class, not just the overall prediction.

Is it possible to plot partial dependence per class?  Specifically, I'd like
to know the important threshold values of my most important variables.

Thank you for your time,


--
View this message in context: 
http://r.789695.n4.nabble.com/Partial-Dependence-and-RandomForest-tp4549705p4549705.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] Michaelson-Morley Speed of Light Data

2012-04-11 Thread Křištof Želechovski
Dnia środa, 11 kwietnia 2012 13:26:43 Prof Brian Ripley pisze:
 On 11/04/2012 12:42, Duncan Murdoch wrote:
  On 12-04-11 12:43 AM, Křištof Želechovski wrote:
  URL:
  http://finzi.psych.upenn.edu/R/library/datasets/html/morley.html
  
  The classical data of Michaelson and Morley on the speed of light
  
  Can you provide more information about the data? How were they
  obtained,
  etc.? I do not have the book Genstat Primer and the nearest location
  where
  it is available is University of York which is rather far from my
  location.
  
  If you can't find the cited reference, I'd try Google. For instance, it
  led me to this page
  
  http://en.wikipedia.org/wiki/File:Michelsonmorley-boxplot.svg
  
  which appears to show five series.
 
 Yes, but that is derived from R.
 
 AFAIR the history, Bill Venables got this from Weekes (1986), a book I
 have only ever seen in Adelaide.  A better reference is
 
   S. M. Stigler (1977) Do robust estimators work with real data?
   Annals of Statistics 5, 1055–1098. (See Table 6.)

The data in R are identical with Table 6 but they were not obtained by 
Michaelson and Morley; they were obtained by Michelson.  The description is 
wrong.

It is also a problem in R itself, as evidenced by the following instruction:

data(morley)

Of course, you can name a data set whatever you like, even data(marilyn) would 
be all right, but may I suggest that this data set be renamed to michelson?

Please fix,
Chris

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Lattice densityplot with semitransparent filled regions

2012-04-11 Thread Walmes Zeviani
Thank you Ilai. Problem solved. There is a small detail, alpha affects the
rug and the curve line opacity too. Is possible to specify it just to
polygon?

Bests.

==
Walmes Marques Zeviani
LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
Departamento de Estatística - Universidade Federal do Paraná
fone: (+55) 41 3361 3573
VoIP: (3361 3600) 1053 1173
e-mail: wal...@ufpr.br
twitter: @walmeszeviani
homepage: http://www.leg.ufpr.br/~walmes
linux user number: 531218
==

[[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] Faceted bar plot shows wrong counts (ggplot2)

2012-04-11 Thread Hadley Wickham
And it's now fixed in the dev version.
Hadley

On Tue, Mar 13, 2012 at 11:37 AM, Helios de Rosario
helios.derosa...@ibv.upv.es wrote:
 Michael,

 Thanks for the pointer to the discussion in the ggplot list. It seems
 that the reason of this behaviour of facet_grid() is already known and
 being discussed by the developers of ggplot2.

 facet_grid() reduces the original data frame with unique() before
 applying the stats.  If the data frame has any other column that
 prevents duplicated rows, counts are correctly computed.

 E.g.

 diamonds25 - droplevels(diamonds[1:25,]) # Keep all columns

 # Everything else as before:
 base  -  ggplot(diamonds25,  aes(fill  =  cut))  +
  geom_bar(position  =  dodge)  +
  opts(legend.position  =  none)
  base  +  aes(x  =  cut)  +
  facet_grid(.  ~  color)


 Helios

 El día 12/03/2012 a las 20:59, R. Michael Weylandt
 michael.weyla...@gmail.com escribió:
 You get the good behavior with

 base + aes(x = cut) + facet_wrap(~ color, ncol = 5)

 so this seems buggy to me.

 If someone here doesn't step forward with more insight, I'd forward
 it
 to the ggplot list to see if one of the developers there can give an
 explanation or possibly make the official call that it's a bug.

 There was another report of a possible bug in facet_grid() today
 that
 could be related:

 https://groups.google.com/group/ggplot2/browse_thread/thread/5213ac35da6b36d

 4

 Michael

 On Mon, Mar 12, 2012 at 7:16 AM, Helios de Rosario
 helios.derosa...@ibv.upv.es wrote:
 I have encountered a problem with faceted bar plots. I have tried
 to
 create something like the example explained in the ggplot2 book (see
 pp.
 126-128):

 library(ggplot2)
 mpg4  -  subset(mpg,  manufacturer  %in%
 c(audi,  volkswagen,  jeep))
 mpg4$manufacturer  -  as.character(mpg4$manufacturer)
 mpg4$model  -  as.character(mpg4$model)

 base  -  ggplot(mpg4,  aes(fill  =  model))  +
 geom_bar(position  =  dodge)  +
 opts(legend.position  =  none)
 base  +  aes(x  =  model)  +
 facet_grid(.  ~  manufacturer)

 That example works fine; the bar heights are just the same as the
 counts in the table:

 table(mpg4[,1:2])
          model
 manufacturer a4 a4 quattro a6 quattro grand cherokee 4wd gti jetta
 new
 beetle
  audi        7          8          3                  0   0     0
    0
  jeep        0          0          0                  8   0     0
    0
  volkswagen  0          0          0                  0   5     9
    6
          model
 manufacturer passat
  audi            0
  jeep            0

 But in other cases this does not occur. For instance, take a small
 subset of data(diamonds):

 diamonds25 - droplevels(diamonds[1:25,2:3])
 table(diamonds25)
           color
 cut         E F H I J
  Fair      1 0 0 0 0
  Good      1 0 0 1 4
  Very Good 1 0 3 1 4
  Premium   3 1 0 1 0
  Ideal     1 0 0 1 2

 And change the variables mapped in the previous plot:

 base  -  ggplot(diamonds25,  aes(fill  =  cut))  +
 geom_bar(position  =  dodge)  +
 opts(legend.position  =  none)
 base  +  aes(x  =  cut)  +
 facet_grid(.  ~  color)

 I see all bars with height = 1.
 I have ovserved this problem (wrong bar heights, but not always =
 1),
 in other cases when all counts are very small or zero.
 What's wrong here?

 Regards,
 Helios

 sessionInfo()
 R version 2.14.2 (2012-02-29)
 Platform: i386-pc-mingw32/i386 (32-bit)

 locale:
 [1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252
 [3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
 [5] LC_TIME=Spanish_Spain.1252

 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods
 base

 other attached packages:
 [1] ggplot2_0.9.0

 loaded via a namespace (and not attached):
  [1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.1
 grid_2.14.2
  [5] MASS_7.3-17        memoise_0.1        munsell_0.3
 plyr_1.7.1
  [9] proto_0.3-9.2      RColorBrewer_1.0-5 reshape2_1.2.1
 scales_0.2.0
 [13] stringr_0.6



 INSTITUTO DE BIOMECÁNICA DE VALENCIA
 Universidad Politécnica de Valencia ● Edificio 9C
 Camino de Vera s/n ● 46022 VALENCIA (ESPAÑA)
 Tel. +34 96 387 91 60 ● Fax +34 96 387 91 69
 www.ibv.org

  Antes de imprimir este e-mail piense bien si es necesario hacerlo.
 En cumplimiento de la Ley Orgánica 15/1999 reguladora de la
 Protección
 de Datos de Carácter Personal, le informamos de que el presente
 mensaje
 contiene información confidencial, siendo para uso exclusivo del
 destinatario arriba indicado. En caso de no ser usted el
 destinatario
 del mismo le informamos que su recepción no le autoriza a su
 divulgación
 o reproducción por cualquier medio, debiendo destruirlo de
 inmediato,
 rogándole lo notifique al remitente.

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

 INSTITUTO DE BIOMECÁNICA DE VALENCIA
 Universidad Politécnica 

Re: [R] xyplot lattice fine control of axes limits and thick marks (with log scale)

2012-04-11 Thread ilai
On Wed, Apr 11, 2012 at 7:16 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Apr 11, 2012, at 9:03 AM, David Winsemius wrote:


 On Apr 11, 2012, at 6:28 AM, maxbre wrote:

 hi, I just realised I want to go a little further in the control of the
 chart
 appearance and I would like to have the same number of ticks displayed in
 both axes of all panels

 I'm wondering if you should be using relation=free when you have already
 set a panel specific range for the x and y limits? I'm thinking that the
 panel function may be reversing your earlier prepanel efforts. (No data
 offered  ... why don't you use one of the many test datasets in the examples
 of the lattice package?)


 On further meandering up this thread I see that you omitted the context of
 earlier data offerings, so not I in turn offer what I think is a your
 request. Change relation from free to sliced

David, you make a good point. Seems OP's long and winding road {end
quote} is slowly circling back to the origin (see the first couple of
messages in thread).

slice is better than free, but isn't tick.number just a suggestion
? i.e. a better choice of n in ?pretty will override ? For example
this data (below), barely noticeable, but see panel(2,1) has 7 ticks
compare with 6 for the others.

Any one please correct me (as I find I mess with these myself too
often... :) but I think if OP wants to force equal ticks (and lose the
pretty axis) there is no avoiding changes to x and yscale.components
?

tm - structure(list(name_short = structure(1:29, .Label = c(D4,
D5, D6a, D6b, D6c, D7, D8, F4, F5a, F5b, F6a,
F6b, F6c, F6d, F7a, F7b, F8, P105, P114, P118,
P123, P126, P156, P157, P167, P169, P189, P77,
P81), class = factor), sub_family = structure(c(3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L), .Label = c(pcb mono-ortho subs,
pcb non-ortho subs, pcdd, pcdf), class = factor), tv = c(1.069,
6.461, 5.461, 12.764, 10.86, 117.912, 256.875, 452.204, 124.02,
327.856, 88.469, 61.539, 17.794, 84.117, 121.668, 13.414, 68.409,
3023.333, 428, 19454.667, 151.333, 324, 11478.667, 1220.667,
5335.333, 124.667, 1542.667, 594.667, 193.333), ms = c(1.787,
4.831, 3.456, 14.105, 10.808, 116.02, 296.957, 30.533, 21.821,
32.969, 33.767, 29.799, 12.812, 49.637, 126.522, 17.522, 106.087,
1787.5, 130, 6751.5, 81, 23, 370, 33.5, 147.5, 5.406, 18.5, 415,
69.906)), .Names = c(name_short, sub_family, tv, ms), class =
data.frame, row.names = c(NA, -29L))

# changing to sliced
 xyplot(tv ~ ms | sub_family, data=tm,
 #as.table=TRUE,
 aspect=xy,
 xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
 ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
 scales= list(x=list(relation=sliced, log=10, cex=0.8),
  y=list(relation=sliced, log=10, cex=0.8)),
 prepanel = function(x, y, subscripts) {
   rr- range(cbind(x,y))
   list(xlim = rr, ylim= rr)
 },
 panel = function(x, y ,subscripts,...) {
   panel.xyplot(x, y, cex=0.8,...)
   panel.abline(a = 0, b = 1, lty = 2, col =gray)
   panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8, pos=3,
offset=0.5, srt=0, adj=c(1,1))
 },
 subscripts=TRUE,
 xscale.components = xscale.components.logpower,
 yscale.components = yscale.components.logpower
 )

# Compare with

 xyplot(tv ~ ms | sub_family, data=tm,
 #as.table=TRUE,
 aspect=xy,
 xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
 ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
 scales= list(relation=free, log=10, cex=0.8),
 prepanel = function(x, y, subscripts) {
   rr- range(cbind(x,y))
   list(xlim = rr, ylim= rr)
 },
 panel = function(x, y ,subscripts,...) {
   panel.xyplot(x, y, cex=0.8,...)
   panel.abline(a = 0, b = 1, lty = 2, col =gray)
   panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8, pos=3,
offset=0.5, srt=0, adj=c(1,1))
 },
 subscripts=TRUE,
 xscale.components = function(...)  {
 ans - xscale.components.logpower(...)
 range - ans$num.limit
 newtck - round(seq(range[1],range[2],l=7),1)
 ans$bottom$ticks$at - newtck
 ans$bottom$labels$at - newtck
 ans$bottom$labels$labels -
parse(text=paste('10^',newtck,sep=''))
  ans
 } ,
 yscale.components  = function(...)  {
 ans - yscale.components.logpower(...)
 range - ans$num.limit
 newtck - round(seq(range[1],range[2],l=7),1)
 ans$left$ticks$at - newtck
 ans$left$labels$at - newtck
 ans$left$labels$labels -
parse(text=paste('10^',newtck,sep=''))
 ans
 }
 )

Cheers




 scales= list(x=list(relation=sliced, log=10, cex=0.8, tick.number=5),
             

Re: [R] geom_plot creates Area Instead Of Lines

2012-04-11 Thread Hadley Wickham
 What I would have liked is something like a cloud of lines, similar to what
 I get when I convert the data into a matrix (why do I not just use a matrix?
 I come from MATLAB and this seems natural, however, my data is large and a
 data frame seems to be an advantageous way to handle that).

It's hard to know without a reproducible example
(https://github.com/hadley/devtools/wiki/Reproducibility), but perhaps
you need to set the group aesthetic?

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [R] Michaelson-Morley Speed of Light Data

2012-04-11 Thread Prof Brian Ripley

On 11/04/2012 19:33, Křištof Želechovski wrote:

Dnia środa, 11 kwietnia 2012 13:26:43 Prof Brian Ripley pisze:

On 11/04/2012 12:42, Duncan Murdoch wrote:

On 12-04-11 12:43 AM, Křištof Želechovski wrote:

URL:
http://finzi.psych.upenn.edu/R/library/datasets/html/morley.html

The classical data of Michaelson and Morley on the speed of light

Can you provide more information about the data? How were they
obtained,
etc.? I do not have the book Genstat Primer and the nearest location
where
it is available is University of York which is rather far from my
location.


If you can't find the cited reference, I'd try Google. For instance, it
led me to this page

http://en.wikipedia.org/wiki/File:Michelsonmorley-boxplot.svg

which appears to show five series.


Yes, but that is derived from R.

AFAIR the history, Bill Venables got this from Weekes (1986), a book I
have only ever seen in Adelaide.  A better reference is

   S. M. Stigler (1977) Do robust estimators work with real data?
   Annals of Statistics 5, 1055–1098. (See Table 6.)


The data in R are identical with Table 6 but they were not obtained by
Michaelson and Morley; they were obtained by Michelson.  The description is
wrong.

It is also a problem in R itself, as evidenced by the following instruction:

data(morley)

Of course, you can name a data set whatever you like, even data(marilyn) would
be all right, but may I suggest that this data set be renamed to michelson?


That is what it is called in package MASS 


Please fix,
Chris



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] extend data frame for plotting heat map in ggplot2

2012-04-11 Thread Hadley Wickham
On Sun, Apr 1, 2012 at 9:16 AM, Till Bayer till.ba...@kaust.edu.sa wrote:
 Hi all!

 I want to generate a heat map from an all-vs-all comparison. I have the
 data, already scaled to 0-1. However, I have the values only for the
 comparisons in one way, and not for the comparisons between the same group
 (which are always 1), i.e. I have half the matrix and am missing the other
 half and the diagonal.
 What is a good way to get it into a form that ggplot2 can use for the heat
 map?

 This is an example of the data I have:

 A       B       value
 T1      T2      0.347
 T1      T3      0.669
 T2      T3      0.214

 I assume the following is what I need for ggplot (or maybe I don't, if
 ggplot can somehow generate it?):

 A       B       value
 T1      T2      0.347
 T1      T3      0.669
 T2      T3      0.214
 T2      T1      0.347
 T3      T1      0.669
 T3      T2      0.214
 T1      T1      1
 T2      T2      1
 T3      T3      1

You can usually do something like:

df - data.frame(A = 1:2, B = 3:4, value = runif(2))
all - expand.grid(unique(df[c(A, B)]))

merge(all, df, all = T)

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


[R] r graphing

2012-04-11 Thread John Kim
can anybody tell me how i can draw x- y- axis and draw x^3 graph using
R graph??

i need nice coordinate system with legends and coordinate
numberings..

and nice graph of x^3 on it..  it will be nice if you tell me how i
can center the graph..

i want the origin (0,0) to be right in the middle of the graph.

thank you so much.

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


Re: [R] r graphing

2012-04-11 Thread R. Michael Weylandt
The easiest way is to just use ?curve (type ?curve at the prompt to
get documentation for curve): e.g., curve(x^3, from = -5, to = 5)

You could also build the plot yourself like:

x - seq(-5, 5, length.out = 200)
y - x^3

plot(x,y)

Michael

On Wed, Apr 11, 2012 at 4:41 PM, John Kim ktown4...@gmail.com wrote:
 can anybody tell me how i can draw x- y- axis and draw x^3 graph using
 R graph??

 i need nice coordinate system with legends and coordinate
 numberings..

 and nice graph of x^3 on it..  it will be nice if you tell me how i
 can center the graph..

 i want the origin (0,0) to be right in the middle of the graph.

 thank you so much.

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

2012-04-11 Thread David Winsemius


On Apr 11, 2012, at 4:41 PM, John Kim wrote:


can anybody tell me how i can draw x- y- axis and draw x^3 graph using
R graph??

i need nice coordinate system with legends and coordinate
numberings..


Look at:

?curve




and nice graph of x^3 on it..  it will be nice if you tell me how i
can center the graph..

i want the origin (0,0) to be right in the middle of the graph.

thank you so much.


David Winsemius, MD
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] convex nonnegative basis vectors in nullspace of matrix

2012-04-11 Thread Petr Savicky
On Wed, Apr 11, 2012 at 06:04:28AM -0700, capy_bara wrote:
 Dear all,
 
 I want to explore the nullspace of a matrix S: I currently use the function
 Null from the MASS package to get a basis for the null space:
  S  = matrix(nrow=3, ncol=5, c(1,0,0,-1,1,1,1,-1,-1,0,-1,0,0,0,-1)); S
  MASS::Null(t(S))
 My problem is that I actually need a nonnegative basis for the null space of
 S.
 There should be a unique set of convex basis vectors spanning a vector space
 in which each vector v satisfies sum (S %*%  v) == 0 and min(v)=0. 

Hi.

The null space of the above matrix has dimension 2. Its intersection
with nonnegative vectors in R^5 is an infinite cone. In order to restrict
it to a finite set, we can consider its intersection with the set
of vectors with the sum of coordinates equal to 1. Then, the solution
is a finite convex polytop and we can search for its vertices. The
following code searches for vertices in random directions and finds two
vertices. In this simple case, the polytop is in fact a line segment,
so we get its endpoints. These endpoints form a linear basis of the
original null space consisting of nonnegative vectors.

  library(lpSolve)
  S - matrix(nrow=3, ncol=5, c(1,0,0,-1,1,1,1,-1,-1,0,-1,0,0,0,-1))
  a - MASS::Null(t(S))
  n - nrow(a)
  a1 - rbind(a, colSums(a))
  b - rep(0, times=n+1)
  b[n+1] - 1
  dir - c(rep(=, times=n), ==)
  sol - matrix(nrow=100, ncol=n)
  for (i in seq.int(length=nrow(sol))) {
  crit - rnorm(ncol(a))
  out - lp(objective.in=crit, const.mat=a1, const.dir=dir, const.rhs=b)
  sol[i, ] - a %*% out$solution
  }
  unique(round(sol, digits=10))

[,1]  [,2]  [,3]  [,4]  [,5]
  [1,] 0.250 0.250 0.000 0.250 0.250
  [2,] 0.1642631 0.3357369 0.1714738 0.1642631 0.1642631

Use this with care, since for more complex cases, this method does not
guarantee that all vertices are found. So, it is not guaranteed that
every nonnegative vector in the null space is a nonnegative combination
of the obtained vectors.

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] R-help; generating censored data

2012-04-11 Thread Ted Harding
On 11-Apr-2012 16:28:31 Christopher Kelvin wrote:
 Hello,
 can i implement this as 10% censored data where t gives me
 failure and x censored.
 Thank you
 
 p=2;b=120
 n=50
 
 set.seed(132);
 r-sample(1:50,45)
 t-rweibull(r,shape=p,scale=b)
 t
 set.seed(123);_
 cens - sample(1:50, 5)_
 x-runif(cens,shape=p,scale=b)_
 x
 
 Chris Guure
 Researcher,
 Institute for Mathematical Research
 UPM

This query is obscure!

First, its approach does not seem to conform to the standard
notion of censored data. This refers to a situation where,
for each item observed, either (a) it value falls within a
certain range (which may itself depend on the item), in which
case its value is recorded as a value in the data; or (b) its
value falls outside that range, in which case that fact is
recorded but the value is not recorded (thus being censored).

Eaxmple: Patients who have been admitted to hospital for a
particular disease are subsequently monitored for a period
of time (days/months/years) which may vary from patient to
patient. The reason for the time limitation may be that the
design of the investigation set a limit, or may be haphazard
as a result of the patient moving away and no longer being
accessible. The value recorded (if available) is the time
from admission to death. If not available, then all that can
be recorded is that the event occurred later than the upper
time limit for thaqt patient.

As far as I can see, no element of your code above corresponds
to this notion of censored.

Next, your r-sample(1:50,45) selects 45 different values
from (1:50), and then your t-rweibull(r,shape=p,scale=b)
generates 45 values sampled from the Weibull distribution,
** regardless of the 45 values from (1:50) in r ** -- See
under '?rweibull' where it says:

  n: number of observations. If 'length(n)  1', the length
   is taken to be the number required.

So it would seem that your r-sample(1:50,45) is superfluous,
and you could simply have written t-rweibull(45,shape=p,scale=b).

Similar comments apply to your

  cens - sample(1:50, 5)
  x-runif(cens,shape=p,scale=b)

where you could have equivalently written x-runif(5,shape=p,scale=b).
Also, the parameters shape and scale would not be recognised
by runif(), whose parameters are as in runif(n, min=..., max=...).
Maybe you meant to write x-rweibull(cens,shape=p,scale=b),
but then you would simply be sampling a further 5 values from the
same Weibull distribution, along with your original 45.

So how does censoring come into this?

If you would explain, in plain words, what you are seeking to do,
it would help to remove this obscurity and confusion!

Hoping this helps,
Ted.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 11-Apr-2012  Time: 23:23:36
This message was sent by XFMail

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


Re: [R] convex nonnegative basis vectors in nullspace of matrix

2012-04-11 Thread Petr Savicky
On Wed, Apr 11, 2012 at 06:04:28AM -0700, capy_bara wrote:
 Dear all,
 
 I want to explore the nullspace of a matrix S: I currently use the function
 Null from the MASS package to get a basis for the null space:
  S  = matrix(nrow=3, ncol=5, c(1,0,0,-1,1,1,1,-1,-1,0,-1,0,0,0,-1)); S
  MASS::Null(t(S))
 My problem is that I actually need a nonnegative basis for the null space of
 S.
 There should be a unique set of convex basis vectors spanning a vector space
 in which each vector v satisfies sum (S %*%  v) == 0 and min(v)=0. 

Hi.

In my previous solution, i forgot that lp() assumes all variables
nonnegative. So, the code was searching only a subset of the true
set of solutions. A better alternative is as follows.

  library(lpSolve)
  S - matrix(nrow=3, ncol=5, c(1,0,0,-1,1,1,1,-1,-1,0,-1,0,0,0,-1))
  a - MASS::Null(t(S))
  a1 - cbind(a, -a)
  n - nrow(a1)
  a2 - rbind(a1, colSums(a1))
  b - rep(0, times=n+1)
  b[n+1] - 1
  dir - c(rep(=, times=n), ==)
  sol - matrix(nrow=100, ncol=n)
  for (i in seq.int(length=nrow(sol))) {
  crit - rnorm(ncol(a))
  crit - c(crit, -crit)
  out - lp(objective.in=crit, const.mat=a2, const.dir=dir, const.rhs=b)
  sol[i, ] - a1 %*% out$solution
  }
  unique(round(sol, digits=10))

   [,1] [,2] [,3] [,4] [,5]
  [1,] 0.00 0.50  0.5 0.00 0.00
  [2,] 0.25 0.25  0.0 0.25 0.25

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] r graphing

2012-04-11 Thread R. Michael Weylandt
Please reply all to the list and don't send HTML.

curve(x^3, from = -5, to = 5); grid()

If you only want dotted lines at x = 0  y = 0 use

grid(2,2)

instead.

Michael

On Wed, Apr 11, 2012 at 6:49 PM, John Kim provicon2...@yahoo.com wrote:
 thanks for the reply..

 i tried the code below.. it shows the graph.. but how do i make x and y axis
 show up in the middle??

 i am teaching secondary school math.. and i need to produce graphs for
 learning purpose..

 i need nice x- y-axis.. in the middle.. with arrows at the end of axis..

 can you tell me how i can realize that??

 john


 From: R. Michael Weylandt michael.weyla...@gmail.com
 To: John Kim ktown4...@gmail.com
 Cc: r-help@r-project.org; provicon2...@yahoo.com
 Sent: Wednesday, April 11, 2012 2:37 PM
 Subject: Re: [R] r graphing

 The easiest way is to just use ?curve (type ?curve at the prompt to
 get documentation for curve): e.g., curve(x^3, from = -5, to = 5)

 You could also build the plot yourself like:

 x - seq(-5, 5, length.out = 200)
 y - x^3

 plot(x,y)

 Michael

 On Wed, Apr 11, 2012 at 4:41 PM, John Kim ktown4...@gmail.com wrote:
 can anybody tell me how i can draw x- y- axis and draw x^3 graph using
 R graph??

 i need nice coordinate system with legends and coordinate
 numberings..

 and nice graph of x^3 on it..  it will be nice if you tell me how i
 can center the graph..

 i want the origin (0,0) to be right in the middle of the graph.

 thank you so much.

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

2012-04-11 Thread R. Michael Weylandt
Alternatively, you can use

curve(x^3, from = -5, to = 5); abline(h = 0, v = 0, lty = 2)

which will work even if the axes aren't in the middle of the image.

Michael

On Wed, Apr 11, 2012 at 6:54 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
 Please reply all to the list and don't send HTML.

 curve(x^3, from = -5, to = 5); grid()

 If you only want dotted lines at x = 0  y = 0 use

 grid(2,2)

 instead.

 Michael

 On Wed, Apr 11, 2012 at 6:49 PM, John Kim provicon2...@yahoo.com wrote:
 thanks for the reply..

 i tried the code below.. it shows the graph.. but how do i make x and y axis
 show up in the middle??

 i am teaching secondary school math.. and i need to produce graphs for
 learning purpose..

 i need nice x- y-axis.. in the middle.. with arrows at the end of axis..

 can you tell me how i can realize that??

 john


 From: R. Michael Weylandt michael.weyla...@gmail.com
 To: John Kim ktown4...@gmail.com
 Cc: r-help@r-project.org; provicon2...@yahoo.com
 Sent: Wednesday, April 11, 2012 2:37 PM
 Subject: Re: [R] r graphing

 The easiest way is to just use ?curve (type ?curve at the prompt to
 get documentation for curve): e.g., curve(x^3, from = -5, to = 5)

 You could also build the plot yourself like:

 x - seq(-5, 5, length.out = 200)
 y - x^3

 plot(x,y)

 Michael

 On Wed, Apr 11, 2012 at 4:41 PM, John Kim ktown4...@gmail.com wrote:
 can anybody tell me how i can draw x- y- axis and draw x^3 graph using
 R graph??

 i need nice coordinate system with legends and coordinate
 numberings..

 and nice graph of x^3 on it..  it will be nice if you tell me how i
 can center the graph..

 i want the origin (0,0) to be right in the middle of the graph.

 thank you so much.

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

2012-04-11 Thread R. Michael Weylandt
I repeat myself: Please reply all to the list and don't send HTML.

I'm not aware of facilities to do that automatically (though others
might now them) -- you can draw arrows manually with the arrows()
function.

Michael

On Wed, Apr 11, 2012 at 7:08 PM, John Kim provicon2...@yahoo.com wrote:
 thank you so much..

 is it possible to make arrows show up at the end of axis.. and make
 numberings show up in the middle axis??

 From: R. Michael Weylandt michael.weyla...@gmail.com
 To: John Kim provicon2...@yahoo.com; r-help r-help@r-project.org
 Sent: Wednesday, April 11, 2012 4:06 PM
 Subject: Re: [R] r graphing

 Alternatively, you can use

 curve(x^3, from = -5, to = 5); abline(h = 0, v = 0, lty = 2)

 which will work even if the axes aren't in the middle of the image.

 Michael

 On Wed, Apr 11, 2012 at 6:54 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
 Please reply all to the list and don't send HTML.

 curve(x^3, from = -5, to = 5); grid()

 If you only want dotted lines at x = 0  y = 0 use

 grid(2,2)

 instead.

 Michael

 On Wed, Apr 11, 2012 at 6:49 PM, John Kim provicon2...@yahoo.com wrote:
 thanks for the reply..

 i tried the code below.. it shows the graph.. but how do i make x and y
 axis
 show up in the middle??

 i am teaching secondary school math.. and i need to produce graphs for
 learning purpose..

 i need nice x- y-axis.. in the middle.. with arrows at the end of axis..

 can you tell me how i can realize that??

 john


 From: R. Michael Weylandt michael.weyla...@gmail.com
 To: John Kim ktown4...@gmail.com
 Cc: r-help@r-project.org; provicon2...@yahoo.com
 Sent: Wednesday, April 11, 2012 2:37 PM
 Subject: Re: [R] r graphing

 The easiest way is to just use ?curve (type ?curve at the prompt to
 get documentation for curve): e.g., curve(x^3, from = -5, to = 5)

 You could also build the plot yourself like:

 x - seq(-5, 5, length.out = 200)
 y - x^3

 plot(x,y)

 Michael

 On Wed, Apr 11, 2012 at 4:41 PM, John Kim ktown4...@gmail.com wrote:
 can anybody tell me how i can draw x- y- axis and draw x^3 graph using
 R graph??

 i need nice coordinate system with legends and coordinate
 numberings..

 and nice graph of x^3 on it..  it will be nice if you tell me how i
 can center the graph..

 i want the origin (0,0) to be right in the middle of the graph.

 thank you so much.

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

2012-04-11 Thread Chintanu
Thanks again.

By the way, any idea why I get this error:

merged3 -  merge_all(list_of_files , by = Name)
Error in `[.data.frame`(df, , match(names(dfs[[1]]), names(df))) :
  undefined columns selected


 sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
 LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] reshape_0.8.4 plyr_1.7.1

loaded via a namespace (and not attached):
[1] tools_2.14.2


Cheers,
Chintanu

=


On Wed, Apr 11, 2012 at 11:10 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 Simply pass all = FALSE to merge_all

 merge_all(list_of_files, by = Name, all = FALSE)

 Michael

 On Wed, Apr 11, 2012 at 1:09 AM, Chintanu chint...@gmail.com wrote:
  Thanks to David and Michael
 
  Michael:
 
  That works, however with a glitch. Each of my 24 files has got two
 columns:
  Name, and Rank/score.
 
  file_list - list.files()
  list_of_files - lapply(file_list, read.csv) # Read in each file
 
  # I can see the 2-columns at this stage. However, the following line:
 
  merge_all(list_of_files, by = Name)
 
  # produces some NAs for the 2nd column (except the beginning 1/3rd of the
  columns which have values). Not sure about the reason - the original
 files
  don't have  any NAs.
 
 
  Further, I understand that it gives the union of (rows of) files based on
  Name. Is there a way to look for intersection, i.e., similar to using:
  merge ( ,by=Name, all=FALSE)  ?
 
 
  David:  It came up with an error :
 
  do.call(merge, list_of_files, by=Name)
 
  Error in do.call(merge, list_of_files, by = Name) :
unused argument(s) (by = Name)
 
  Cheers,
  Chintanu
 
 


[[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] Encoding of Sweave file error message

2012-04-11 Thread Duncan Mackay

Hi

I ran the following sweave file in R2.14.1 and upgraded to R2.15 
yesterday with the same setup

I got the following error message when I rand the following Sweave file

 setwd(D:/Cic/Sweave/Parasite/Comb/12)
 Sweave(D:/Cic/Sweave/Parasite/Comb/12/ParasiteComb12.Rnw)
Error: c('ParasiteComb12DS.Rnw', 'ParasiteComb12.Rnw') is not 
ASCII and does not declare an encoding

 version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  15.0
year   2012
month  03
day30
svn rev58871
language   R
version.string R version 2.15.0 (2012-03-30)
nickname

I checked that the files were encoded as ANSI

The file  ParasiteComb12.Rnw is a master file and sets things up and 
calls a number of Sweave files.
ParasiteComb12DS.Rnw which loads packages  processes the data is the 
first file to be called


I can run ParasiteComb12.Rnw by itself without any problems but when 
I add other files then the error message occurs.


There are no references just plain text (no extended character set) 
plain latex and R coding


The first few lines for the Sweave preamble is:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage{courier}
\usepackage[scaled=.92]{helvet}

I can send the files if needed as the resultant pdf that is produced 
is 42 pages.


Any pointers to solve the problem will be greatly appreciated

Regards

Duncan


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

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


Re: [R] Encoding of Sweave file error message

2012-04-11 Thread Walmes Zeviani
I had the same problem! So, as I'm a linux user, I prefer use linux
terminal. On terminal I type this to compile

R CMD Sweave --encoding=utf-8 myfile.Rnw

and the compilation is successful. Try to set the encoding option in
Sweave().

Bests.
Walmes.

==
Walmes Marques Zeviani
LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
Departamento de Estatística - Universidade Federal do Paraná
fone: (+55) 41 3361 3573
VoIP: (3361 3600) 1053 1173
e-mail: wal...@ufpr.br
twitter: @walmeszeviani
homepage: http://www.leg.ufpr.br/~walmes
linux user number: 531218
==

[[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] deferred call

2012-04-11 Thread Whit Armstrong
I must admit I'm a little ashamed to have been using R for so long,
and still lack a sound understanding of deferred calls, eval, deparse,
substitute, and friends.

I'm attempting to make a deferred call to a function which has default
arguments in the following way:

call.foo - function(f) {
x - f()
}

x - 1:10
f - function(x=x) { x^2 }
call.foo(f)

However, I'm getting the error:
Error in x^2 : 'x' is missing

Is there a common R idiom for calling 'formals' on the function, and
then grabbing the named default arguments from the enclosing frame?

I naively thought that since function 'f' was defined w/ a default
argument of 'x' and x is defined in the same envir as the function
itself, that the call would succeed.

-Whit

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Definition of lag is opposite in ts and xts objects!

2012-04-11 Thread jpm miao
 Example:
Will ts objects be obsolete or modified?

 a[,1]
1983 Q1  2.747365190
1983 Q2  2.791594762
1983 Q3 -0.009953715
1983 Q4 -0.015059485
1984 Q1 -1.190061246
1984 Q2 -0.553031799
1984 Q3  0.686874720
1984 Q4  0.953911035 lag(a,4)[,1]
1983 Q1   NA
1983 Q2   NA
1983 Q3   NA
1983 Q4   NA
1984 Q1  2.747365190
1984 Q2  2.791594762
1984 Q3 -0.009953715
1984 Q4 -0.015059485 lag(as.ts(a, start=c(1983,1)),4)
Qtr1 Qtr2 Qtr3 Qtr4
1982  2.747365190  2.791594762 -0.009953715 -0.015059485
1983 -1.190061246 -0.553031799  0.686874720  0.953911035

[[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] deferred call

2012-04-11 Thread Gabor Grothendieck
On Wed, Apr 11, 2012 at 10:17 PM, Whit Armstrong
armstrong.w...@gmail.com wrote:
 I must admit I'm a little ashamed to have been using R for so long,
 and still lack a sound understanding of deferred calls, eval, deparse,
 substitute, and friends.

 I'm attempting to make a deferred call to a function which has default
 arguments in the following way:

 call.foo - function(f) {
    x - f()
 }

 x - 1:10
 f - function(x=x) { x^2 }
 call.foo(f)

 However, I'm getting the error:
 Error in x^2 : 'x' is missing

 Is there a common R idiom for calling 'formals' on the function, and
 then grabbing the named default arguments from the enclosing frame?

 I naively thought that since function 'f' was defined w/ a default
 argument of 'x' and x is defined in the same envir as the function
 itself, that the call would succeed.


f - function(x=x) x^2 is an endless recursion.  Try

 f - function(x.=x) { x^2 }

(note the dot)

-- 
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] Definition of lag is opposite in ts and xts objects!

2012-04-11 Thread jpm miao
BTW, zoo is like ts in the application of lag.
In other words, zoo and xts are opposite in this issue.

2012/4/12 jpm miao miao...@gmail.com

  Example:
 Will ts objects be obsolete or modified?

  a[,1]
 1983 Q1  2.747365190
 1983 Q2  2.791594762
 1983 Q3 -0.009953715
 1983 Q4 -0.015059485
 1984 Q1 -1.190061246
 1984 Q2 -0.553031799
 1984 Q3  0.686874720
 1984 Q4  0.953911035 lag(a,4)[,1]
 1983 Q1   NA
 1983 Q2   NA
 1983 Q3   NA
 1983 Q4   NA
 1984 Q1  2.747365190
 1984 Q2  2.791594762
 1984 Q3 -0.009953715
 1984 Q4 -0.015059485 lag(as.ts(a, start=c(1983,1)),4) Qtr1   
   Qtr2 Qtr3 Qtr4
 1982  2.747365190  2.791594762 -0.009953715 -0.015059485
 1983 -1.190061246 -0.553031799  0.686874720  0.953911035



[[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] Definition of lag is opposite in ts and xts objects!

2012-04-11 Thread R. Michael Weylandt
Yes, this is as documented. See ? lag.xts under details for the
justification and how to change the default if desired.

Michael

On Wed, Apr 11, 2012 at 11:13 PM, jpm miao miao...@gmail.com wrote:
 BTW, zoo is like ts in the application of lag.
 In other words, zoo and xts are opposite in this issue.

 2012/4/12 jpm miao miao...@gmail.com

  Example:
 Will ts objects be obsolete or modified?

  a                [,1]
 1983 Q1  2.747365190
 1983 Q2  2.791594762
 1983 Q3 -0.009953715
 1983 Q4 -0.015059485
 1984 Q1 -1.190061246
 1984 Q2 -0.553031799
 1984 Q3  0.686874720
 1984 Q4  0.953911035 lag(a,4)                [,1]
 1983 Q1           NA
 1983 Q2           NA
 1983 Q3           NA
 1983 Q4           NA
 1984 Q1  2.747365190
 1984 Q2  2.791594762
 1984 Q3 -0.009953715
 1984 Q4 -0.015059485 lag(as.ts(a, start=c(1983,1)),4)             Qtr1      
    Qtr2         Qtr3         Qtr4
 1982  2.747365190  2.791594762 -0.009953715 -0.015059485
 1983 -1.190061246 -0.553031799  0.686874720  0.953911035



        [[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] Definition of lag is opposite in ts and xts objects!

2012-04-11 Thread Jeff Newmiller
What makes you think those are the only two options?

I happen to prefer the xts convention, but there is a lot of code out there 
that successfully uses ts just as it is, and I can't see breaking all of that 
to meet an arbitrary preference of sign convention. (It isn't my decision 
anyway...)
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

jpm miao miao...@gmail.com wrote:

 Example:
Will ts objects be obsolete or modified?

 a[,1]
1983 Q1  2.747365190
1983 Q2  2.791594762
1983 Q3 -0.009953715
1983 Q4 -0.015059485
1984 Q1 -1.190061246
1984 Q2 -0.553031799
1984 Q3  0.686874720
1984 Q4  0.953911035 lag(a,4)[,1]
1983 Q1   NA
1983 Q2   NA
1983 Q3   NA
1983 Q4   NA
1984 Q1  2.747365190
1984 Q2  2.791594762
1984 Q3 -0.009953715
1984 Q4 -0.015059485 lag(as.ts(a, start=c(1983,1)),4)
Qtr1 Qtr2 Qtr3 Qtr4
1982  2.747365190  2.791594762 -0.009953715 -0.015059485
1983 -1.190061246 -0.553031799  0.686874720  0.953911035

   [[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] Schedule R script using cron

2012-04-11 Thread winie
I am trying to schedule my R script using cron, but it is not working. It
seems R can not find packages in cron. Anyone can help me? Thanks.

The following is my bash script

# source  my porfile
. /home/winie/.profile
# script.R will load packages
R CMD BATCH /home/script.R 

--
View this message in context: 
http://r.789695.n4.nabble.com/Schedule-R-script-using-cron-tp4550729p4550729.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] phangorn and calculation of a rate matrix

2012-04-11 Thread Francisco
Hi, I'm trying to calculate a ratematrix for a RNA aligment (U instead of T)
in order to use it as a ratematrix in Profidst (a phylogenetic program which
takes into account both the primary sequence and the secondary structure of
the RNA, in my case rRNA). The sequence-structure aligment has been made in
4SALE (a java app) and saved as one-letter encoded (using a 12 letters
alphabet, a,c,d,e,g,h,i,k,l,n,q,r instead of the
conventional nucleotide codes). My intention is to calculate the ratematrix
(which is a 12x12 matrix) for this special aligment with ape and phangorn,
however I've repeatdly fail to do it. The aligment is in a phyDat object
containing 30 sequences and 12 states (by using user-defined character
states consisting on the 12 letters indicated above). I follow the steps
described in the phangorn-specials vignette but the ratematrix (under a GTR
substitution model) is not calculated. May the problem be that phangorn only
accepts a,g,c and t as valid states for calculating the matrix? And
in case phangorn could calculate the matrix, how could I do it?
I have a very basic knowledge of R so please I would greatly appreciate (if
possible) a step-by-step explanation.
Thanks very much for the help.


--
View this message in context: 
http://r.789695.n4.nabble.com/phangorn-and-calculation-of-a-rate-matrix-tp4550495p4550495.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Converting php arrays to data frame

2012-04-11 Thread beltrand
Hi,

 I am working on an implementation of R within some web application (R is
just a part of a larger project, so R has to be incorporated within an
existing setup) 

Here is the scenario, PHP grabs a csv dataset from some server and turns it
into a 2 dimensional array (with each row being an array, and there are N of
them, N being the number of columns) Now I want the PHP script to trigger
Rscript  to process the data with the exec() command.  The idea is that R
can access the data without actually fetching the csv from the server
(through RMySQL or something like that) 

The question is, how do I turn the PHP array into a data frame or some kind
of object that R can process?

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/Converting-php-arrays-to-data-frame-tp4550656p4550656.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 compare cross-validated C-index in Cox

2012-04-11 Thread frank.chiang

If I calculate the C-index after 10-fold cross-validation based on Cox
model, which statistic test 
should I used to compare two C-statistc values.I means I use
cross-validation to obtain a predictive probability for each individual,
then combine all the probabilities to calculate the C-index.If I get two
C-index values(0.73 vs. 0.80) based on two different model, then how to test
the difference is significant. Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-compare-cross-validated-C-index-in-Cox-tp4550707p4550707.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] Could dynlm function work for xts objects?

2012-04-11 Thread jpm miao
It seems to only works for zoo or ts objects?

I tried to run it for xts objects, and error message occurs. Once I
coerce it to be an zoo object (by as.zoo), it works.

Error message:


Error in model.frame.default(formula = dynformula(PIh - PI ~ L(X, 0:i) +  :
  variable lengths differ (found for 'L(X, 0:i)')
In addition: Warning messages:
1: In zoo(coredata(x), order.by = index(x), ...) :
  some methods for “zoo” objects do not work if the index entries in
‘order.by’ are not unique
2: In zoo(coredata(x), order.by = index(x), ...) :
  some methods for “zoo” objects do not work if the index entries in
‘order.by’ are not unique

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Encoding of Sweave file error message

2012-04-11 Thread Duncan Mackay


At 12:03 12/04/2012, you wrote:
I had the same problem! So, as I'm a linux user, 
I prefer use linux terminal. On terminal I type this to compile

R CMD Sweave --encoding=utf-8 myfile.Rnw

and the compilation is successful. Try to set the encoding option in Sweave().

Bests.
Walmes.

==
Walmes Marques Zeviani
LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
Departamento de Estatística - Universidade Federal do Paraná
fone: (+55) 41 3361 3573
VoIP: (3361 3600) 1053 1173
e-mail: mailto:wal...@ufpr.brwal...@ufpr.br
twitter: @walmeszeviani
homepage: http://www.leg.ufpr.br/%7Ewalmeshttp://www.leg.ufpr.br/~walmes
linux user number: 531218
==

Hi Walmes

Thank you very much. That appears to be the problem.
When I typed from the DOS terminal

R CMD Sweave --encoding=utf-8 ParasiteComb12.Rnw

it compiled the tex file without any error messages.

I have not really got into font encoding and 
reading the Sweave manual I thought that what I had done would be sufficient.

I found an old note which gave a reference to
http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4725.html
http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4889.html
but that appears to be specific.

The ?Sweave and the Sweave manual appear to be 
more specific about the latex side.

After having a look at iconvlist()  and bearing 
in mind Duncan Murdoch's comments about windows I tried

Sweave(D:/Cic/Sweave/Parasite/Comb/12/ParasiteComb12.Rnw, 
encoding = UTF-8)

from the Rgui command window and compiled without any problems
When I had a look at the tex file there were a 
few DOS Alt-248 (degree symbol ) within latex 
comments which were added last running R2.14 before updating

Removing them and re running without the encoding 
argument brought things back to normal.

I tried as a test
\SweaveOpts{encoding=UTF8}
but that appears not to work

All I have to do now is to put the extra argument 
into my text editors clip library for Sweave for 
next time when I cannot solve things.
Its been a long week !

Regards

Duncan


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





[[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] deferred call

2012-04-11 Thread Bert Gunter
On Wed, Apr 11, 2012 at 8:12 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Wed, Apr 11, 2012 at 10:17 PM, Whit Armstrong
 armstrong.w...@gmail.com wrote:
 I must admit I'm a little ashamed to have been using R for so long,
 and still lack a sound understanding of deferred calls, eval, deparse,
 substitute, and friends.

 I'm attempting to make a deferred call to a function which has default
 arguments in the following way:

 call.foo - function(f) {
    x - f()
 }

 x - 1:10
 f - function(x=x) { x^2 }
 call.foo(f)

 However, I'm getting the error:
 Error in x^2 : 'x' is missing

 Is there a common R idiom for calling 'formals' on the function, and
 then grabbing the named default arguments from the enclosing frame?

 I naively thought that since function 'f' was defined w/ a default
 argument of 'x' and x is defined in the same envir as the function
 itself, that the call would succeed.


 f - function(x=x) x^2 is an endless recursion.  Try

To amplify just a bit on Gabor's comment, section 4.3.3 of the R
language definition explicitly states:

One of the most important things to know about the evaluation of
arguments to a function is
that supplied arguments and default arguments are treated differently.
The supplied arguments
to a function are evaluated in the evaluation frame of the calling
function. The default arguments
to a function are evaluated in the evaluation frame of the function.

So foo - function (x = x) {...}
tries to define foo with the default argument x, which is evaluated in
the ** environment of the function ** not in the caller's environment,
where it is 1:10.  So if x ever needs to be evaluated within foo
(i.e., its promise is forced), then it looks for the value of the rhs
of the x=x  assignment within foo, which is (the promise for) x,
again, within foo, which is x again,...

HTH

-- Bert


  f - function(x.=x) { x^2 }

 (note the dot)

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



-- 

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.