[R] install raster package on ubuntu

2009-04-18 Thread milton ruser
Dear all,

I am running R 2.8.1. under ubuntu, and I need to install
the package raster but I get the following error:

 install.packages(raster)
Warning in install.packages(raster) :
  argument 'lib' is missing: using '/usr/local/lib/R/site-library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
Warning message:
In install.packages(raster) : package ‘raster’ is not available

I had installed other packages without problem (like sp, maptools, spatstat
and adehabitat).
I tryed the install.packages as root.

Any hint are welcome.

Bests,

milton
brazil-toronto

 sessionInfo()
R version 2.8.1 (2008-12-22)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_CA.UTF-8;LC_NUMERIC=C;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_CA.UTF-8;LC_PAPER=en_CA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=C

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

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

[[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] install raster package on ubuntu

2009-04-18 Thread milton ruser
Oops.

I found and are working fine
#install.packages(raster,
repos=http://R-Forge.R-project.orghttp://r-forge.r-project.org/
)

Thanks a lot,

milton

On Sat, Apr 18, 2009 at 2:00 AM, milton ruser milton.ru...@gmail.comwrote:

 Dear all,

 I am running R 2.8.1. under ubuntu, and I need to install
 the package raster but I get the following error:

  install.packages(raster)
 Warning in install.packages(raster) :
   argument 'lib' is missing: using '/usr/local/lib/R/site-library'
 --- Please select a CRAN mirror for use in this session ---
 Loading Tcl/Tk interface ... done
 Warning message:
 In install.packages(raster) : package ‘raster’ is not available

 I had installed other packages without problem (like sp, maptools, spatstat
 and adehabitat).
 I tryed the install.packages as root.

 Any hint are welcome.

 Bests,

 milton
 brazil-toronto

  sessionInfo()
 R version 2.8.1 (2008-12-22)
 x86_64-pc-linux-gnu

 locale:

 LC_CTYPE=en_CA.UTF-8;LC_NUMERIC=C;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_CA.UTF-8;LC_PAPER=en_CA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=C

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

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



[[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] Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well

2009-04-18 Thread Ken-JP

Hi,

I used Tinn-R for a long time, but had real headaches on Vista (commands not
being sent, etc...) that were not resolved since R 2.8 or so.

Since then, I have switched to Eclipse/StatET.  The setup requires more
effort, but it is much easier to manage your own packages.  With the Eclipse
IDE and StatET functionality, it also becomes much easier to refactor your
code, if you are playing around with more than one or two .R files. 

I have also found that with some tinkering, Eclipse/StatET also works on XP
Pro 32, Vista 32, and Ubuntu amd64.  Read this thread for more details and
google for the StatET website to download.  Having gotten used to StatET, it
would be extremely painful to go without it...

Good luck.

http://www.nabble.com/Eclipse-and-StatET-Howto-(also-added-Subversion,-Rtools)-td22764049.html#a22764049




LI Qi-2 wrote:
 
 Hi£¬
 
 I found that Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well.
 Maybe, somebody who have solved this problem can help me.
 
 Thanks for your attention!
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Tinn-R-%28Version-2.2.0.2%29-dose-not-support-R-2.9.0-very-well-tp23109020p23109862.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] Need Help with R.oo and multiple inheritance

2009-04-18 Thread Ken-JP

This is what I'm trying to do:

HasPersistence - an Interface class which implements things like
WriteToDisk(), ReadFromDisk()
B isA A
C isA A, but also implements HasPersistence

My solution in R.oo is to have a root class called A which implements
IsPersistent() by returning FALSE, but is overrideable by C to return TRUE. 
C will also implement WriteToDisk() and ReadFromDisk().  This solution will
work, but is kludgy, because it is not directly obvious that IsPersistent(),
WriteToDisk(), and ReadFromDisk() go together in a conceptual
HasPersistence.

Is there a more R.oo-clean-way of multiply inheriting like this, so if
someone else reads my code, the concept of HasPersistence is more obvious? 
In other words, could I actually have a HasPersistence class and have C
inherit from A and implement HasPersistence also?

- Ken



-- 
View this message in context: 
http://www.nabble.com/Need-Help-with-R.oo-and-%22multiple-inheritance%22-tp23109913p23109913.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] Binomial simulation

2009-04-18 Thread beetle2


Not being entirely sure what you mean, I think 

rbinom(1000, 10, .25) 

may be what you want. 

Hi,
Thanks for your reply.
It is close to that but I need to know the probabilty of how many judges
pick a certain brand.
Just say x= 6 judges pick brand A which has P=0.25.

Using R it would be:
 dbinom(6,10,.25)
[1] 0.016222

Probability of six judges choosing  brand A. Hence not very likely.

I have been asked to do this for all values of x = 1 to 10.
But the question says to simulate 1000 trials for each x value.
I'm not sure how to construct the simulation.
regards
Brendan


-- 
View this message in context: 
http://www.nabble.com/Binomial-simulation-tp23106347p23109522.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] Dummy (factor) based on a pair of variables

2009-04-18 Thread Serguei Kaniovski


Dear All!

my data is on pairs of countries, i and j, e.g.:

y,i,j
1,AUT,BEL
2,AUT,GER
3,BEL,GER

I would like to create a dummy (indicator) variable for use in regression
(using factor?), such that it takes the value of 1 if the country is in the
pair (i.e. EITHER an i-country OR an j-country).

Thank you for your help,
Serguei

Austrian Institute of Economic Research (WIFO)

P.O.Box 91  Tel.: +43-1-7982601-231
1103 Vienna, AustriaFax: +43-1-7989386

Mail: serguei.kaniov...@wifo.ac.at
http://www.wifo.ac.at/Serguei.Kaniovski
[[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] Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well

2009-04-18 Thread Erich Neuwirth
I also had some problems with tinn-R and switched to Notepad++ with
NppToR. It works with R 2.9.0, though I have to admit
that I have not extensively tested yet.
Since I am not using Vista, I cannot tell
anything about its Vista performance.

The relevant links are
http://www.stat.tamu.edu/~aredd/site/
http://notepad-plus.sourceforge.net


Ken-JP wrote:
 Hi,
 
 I used Tinn-R for a long time, but had real headaches on Vista (commands not
 being sent, etc...) that were not resolved since R 2.8 or so.
 
 Since then, I have switched to Eclipse/StatET.  The setup requires more
 effort, but it is much easier to manage your own packages.  With the Eclipse
 IDE and StatET functionality, it also becomes much easier to refactor your
 code, if you are playing around with more than one or two .R files. 
 
 I have also found that with some tinkering, Eclipse/StatET also works on XP
 Pro 32, Vista 32, and Ubuntu amd64.  Read this thread for more details and
 google for the StatET website to download.  Having gotten used to StatET, it
 would be extremely painful to go without it...
 
 Good luck.
 
 http://www.nabble.com/Eclipse-and-StatET-Howto-(also-added-Subversion,-Rtools)-td22764049.html#a22764049
 
 
 
 
 LI Qi-2 wrote:
 Hi£¬

 I found that Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well.
 Maybe, somebody who have solved this problem can help me.

 Thanks for your attention!
  [[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.


 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dummy (factor) based on a pair of variables

2009-04-18 Thread Bernardo Rangel Tura
On Sat, 2009-04-18 at 08:55 +0200, Serguei Kaniovski wrote:
 
 Dear All!
 
 my data is on pairs of countries, i and j, e.g.:
 
 y,i,j
 1,AUT,BEL
 2,AUT,GER
 3,BEL,GER
 
 I would like to create a dummy (indicator) variable for use in regression
 (using factor?), such that it takes the value of 1 if the country is in the
 pair (i.e. EITHER an i-country OR an j-country).
 
 Thank you for your help,
 Serguei

Hi Serguei,

If I understand your doubt, the solution is something like this for pair
i-country is AUT or j-country is BEL


output ~ I(i-country==AUT|j-country==BEL)
-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

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

2009-04-18 Thread Ali Faisal

Hello all,
I am new to R and therefore this question is sort of very basic. Could you
kindly let me know how can I call a function or script from R GUI(Windows),
my directory where these functions/scripts are located is suppose xyz and I
have tried setwd(xyz) but still it gives me the Error: object abc not
found where abc is the script/function name...

Would appreciate any guidance,
Thanks,
Ali

-- 
View this message in context: 
http://www.nabble.com/Dummies%3A-Call-function-or-script-tp23110931p23110931.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] Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well

2009-04-18 Thread Stefan Grosse
LI Qi schrieb:
 I found that Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well. 
 Maybe, somebody who have solved this problem can help me.

   

What do you mean with doeas not support very well. I have no problems
with Vista + R 2.9.0 + Tinn-R 2.2.0.2

Try to start Rterm instead of Rgui. This opens the R terminal inside
Tinn-R, causes less problems and has the advantage of a little syntac
highlightning in the terminal. However you have to get used to the error
messages being sent to another window.

Have a look at the Tinn-R sourceforge page. There is an rsite of jose:
http://sourceforge.net/forum/forum.php?forum_id=886959
manipulate it to for your convienience. there is also a line that
resolves the .trPath problem which is maybe what you stumbled upon.

Cheers
Stefan


PS Notepad++ installs for me but the installation on npptor does not
work for me. Syntax highlightning does not work and commands are not
passed to Rgui neither in sdi mode nor in normal mode.

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

2009-04-18 Thread David Winsemius
xyz does not look to me like a valid directory for Windows. Try a  
complete directory string:


setwd(C://username/My Documents/r-work/) # might be something more  
likely


Note the forward slashes. Backslashes are special characters in R. The  
interpreter would need to see each backslash doubled in ourder to  
succeed.


(You might reconsider whether you want to address the group as  
Dummies.)



On Apr 18, 2009, at 5:28 AM, Ali Faisal wrote:



Hello all,
I am new to R and therefore this question is sort of very basic.  
Could you
kindly let me know how can I call a function or script from R  
GUI(Windows),
my directory where these functions/scripts are located is suppose  
xyz and I
have tried setwd(xyz) but still it gives me the Error: object abc  
not

found where abc is the script/function name...

Would appreciate any guidance,
Thanks,
Ali


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] how can i program this???

2009-04-18 Thread A.B
Hi all;
i want to programm the no-parametric regression estimator with R, any help for 
this ???




  
[[alternative HTML version deleted]]

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


[R] Rd: how to put a prime in a code fragment?

2009-04-18 Thread Dan Kelley

I have written a function for my 'oce' package that creates a data.frame
containing a variable name with a prime in it.  (I use prime to indicate
coordinate rotation, a reasonably standard convention that motivates the odd
variable name.)

How can I name that in an Rd file?  I tried \code{u'} but R-2.9.0 doesn't
like to build my package then, since it thinks I'm opening a string.  So I
tried \code{u\'} but then the backslash appears in the documentation.


-- 
View this message in context: 
http://www.nabble.com/Rd%3A-how-to-put-a-prime-in-a-code-fragment--tp23112610p23112610.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] Rd: how to put a prime in a code fragment?

2009-04-18 Thread Duncan Murdoch

On 18/04/2009 8:49 AM, Dan Kelley wrote:

I have written a function for my 'oce' package that creates a data.frame
containing a variable name with a prime in it.  (I use prime to indicate
coordinate rotation, a reasonably standard convention that motivates the odd
variable name.)

How can I name that in an Rd file?  I tried \code{u'} but R-2.9.0 doesn't
like to build my package then, since it thinks I'm opening a string.  So I
tried \code{u\'} but then the backslash appears in the documentation.


The new convention is that \code{} contains legal R code (with a few 
exceptions for markup).  You can use \preformatted{} or \samp{} for 
verbatim text.  So \preformatted{u'} should display the way you like.


If you are using u' as a variable in R, you'd have to enter it as `u'`, 
and that should also be accepted in \code{}.


This stuff is in transition in 2.9.x; 2.10.x should make it all a bit 
cleaner, when the old somewhat inconsistent rules are no longer the default.


Duncan Murdoch

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


Re: [R] how can i program this???

2009-04-18 Thread Sarah Goslee
This list is very good with _specific_ questions, but yours is rather
vague. Perhaps you should read the posting guide, then ask us
about what you are specifically having a problem with.

Sarah

On Sat, Apr 18, 2009 at 8:41 AM, A.B dahma...@yahoo.fr wrote:
 Hi all;
 i want to programm the no-parametric regression estimator with R, any help 
 for this ???



-- 
Sarah Goslee
http://www.functionaldiversity.org

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

2009-04-18 Thread Lars Bishop
Dear R users,

I'd like to ask your guidance regarding the following two questions: (i) I
just finished reading Chris Bishop's book Neural Networks for Pattern
Recognition. Although the book gave me good theoretical foundation about
NN, I'm now looking for something more practical regarding architecture
selection strategies. Is there any good reference about best practices for
architecure selection? (ii) Which R package provides a good implementation
of NN?

Many thanks in advance for your help!

Lars.

[[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] Neural Networks in R - Query

2009-04-18 Thread Tobias Verbeke

Hi Lars,


I'd like to ask your guidance regarding the following two questions: (i) I
just finished reading Chris Bishop's book Neural Networks for Pattern
Recognition. Although the book gave me good theoretical foundation about
NN, I'm now looking for something more practical regarding architecture
selection strategies. Is there any good reference about best practices for
architecure selection? (ii) Which R package provides a good implementation
of NN?


The CRAN Task View on Machine Learning

http://cran.r-project.org/web/views/MachineLearning.html

opens with the following topical item:

o Neural Networks : Single-hidden-layer neural network are implemented
in package nnet as part of the VR  bundle (shipped with base R).

HTH,
Tobias

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

2009-04-18 Thread Albert Vilella
that works very well. how do I store the results into a variable instead of
doing a print?

On Fri, Apr 17, 2009 at 5:51 PM, jim holtman jholt...@gmail.com wrote:

 How about this:

  x - A00096:A00096:A00096:A00096:A02178:A02178:A07776
  x.s - unlist(strsplit(x, :))
  for (i in 2:length(x.s)){
 + x.seq - embed(length(x.s):1, i)
 + print(table(apply(x.seq, 1, function(z){
 + paste(x.s[z], collapse=:)
 + })))
 + }

 A00096:A00096 A00096:A02178 A02178:A02178 A02178:A07776
3 1 1 1

 A00096:A00096:A00096 A00096:A00096:A02178 A00096:A02178:A02178
 A02178:A02178:A07776
   211
   1

 A00096:A00096:A00096:A00096 A00096:A00096:A00096:A02178
 A00096:A00096:A02178:A02178 A00096:A02178:A02178:A07776
  1   1
   1   1

 A00096:A00096:A00096:A00096:A02178 A00096:A00096:A00096:A02178:A02178
 A00096:A00096:A02178:A02178:A07776
  1  1
 1

 A00096:A00096:A00096:A00096:A02178:A02178
 A00096:A00096:A00096:A02178:A02178:A07776
1
   1

 A00096:A00096:A00096:A00096:A02178:A02178:A07776
   1


 On Fri, Apr 17, 2009 at 9:33 AM, Albert Vilella avile...@gmail.com
 wrote:
  Starting by the first entry:
  A00096:A00096:A00096:A00096:A02178:A02178:A07776
 
  and supposing there aren't any other subvectors identical in the set, the
  algorithm will slide through the vector, first in pairs, then in trios,
 then
  in sets of four, etc, and count the occurrences:
 
  A00096:A00096
  3
  A00096:A02178
  1
  A02178:A02178
  1
  A02178:A07776
  1
  A00096:A00096:A00096
  2
  A00096:A00096:A02178
  1
  A00096:A02178:A02178
  1
  A02178:A02178:A07776
  1
  A00096:A00096:A00096:A00096
  1
  A00096:A00096:A00096:A02178
  1
  A00096:A00096:A02178:A02178
  1
  A00096:A02178:A02178:A07776
  1
  A00096:A00096:A00096:A00096:A02178
  1
  A00096:A00096:A00096:A02178:A02178
  1
  A00096:A00096:A02178:A02178:A07776
  1
  A00096:A00096:A00096:A00096:A02178:A02178
  1
  A00096:A00096:A00096:A02178:A02178:A07776
  1
  A00096:A00096:A00096:A00096:A02178:A02178:A07776
  1
 
 
 
 
  On Fri, Apr 17, 2009 at 1:04 PM, jim holtman jholt...@gmail.com wrote:
 
  Can you provide the output that you would expect from the data you
  gave.  I am not sure what you mean by a 'subvector'.
 
  On Fri, Apr 17, 2009 at 5:25 AM, Albert Vilella avile...@gmail.com
  wrote:
   Hi,
  
   I've got a list of ~2 elements that look like this:
  
   [1]
   A00096:A00096:A00096:A00096:A02178:A02178:A07776
  
   [2]
   A00046:A00076:A01101:A04146:A05671:A07169
  
   [3]
  
  
 A00038:A00932:A02185:A02370:A02818:A02818:A02818:A02818:A04732:A07142:A07142
  
   [4]
   A00096:A01352:A01352:A02023:A05001:A05001:A07776
  
   [5]
  
  
 A00036:A00047:A00059:A00503:A00904:A00904:A00904:A01023:A01023:A01399:A02029:A03941:A07679
   [6]
  
  
 A00041:A00533:A00855:A02178:A02178:A02178:A05671:A05671:A05671:A05671:A05671:A05671:A05671
   ...
  
   And I would like to have a table with the frequency of occurrences for
   matching subvectors in all elements, i.e., not
   only the number of times a vector is found but also how many times a
   subvector (of at least 2 ids) is found.
  
   How can I do that?
   Thanks in advance,
   Albert.
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 
 
  --
  Jim Holtman
  Cincinnati, OH
  +1 513 646 9390
 
  What is the problem that you are trying to solve?
 
 



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

 What is the problem that you are trying to solve?


[[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] Create histogram from data matrix

2009-04-18 Thread hadley wickham
On Fri, Apr 17, 2009 at 2:07 PM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:
 Thank you all for your advice.
  I have received some good tips, but it was suggested I write back with a
 small simulated data set to better illustrate my needs. So, currently my
 data frame looks something like:

 ID (date)  Temperature  Number of fish
 200706183       5       456
 200706183       5       765
 200706183       4       567
 200706183       3       876
 200706183       3       888
 200706183       2       111
 200706184       8       2345
 200706184       8       654
 200706184       8       7786
 200706184       7       345
 200706184       6       234
 200706184       6       123


 I need to create a plots for each ID (date) of the number of fish observed
 at each temperature. Obviously my data frame is much larger. These plots do
 not have to be in a specific histogram format, but it seems this may be
 appropriate.
 Thanks for any additional advice as to how this may be done, either using
 plot commands or reformatting my data.

 It seemed the ggplot2 options may be good but so far I have tried qplot with
 no success:

 my most recent code looks like:

 qplot(temp,number of fish, geom=histogram,binwidth=1)

 I have tried various tweaks of this, but no success.

The problem is number of fish is not a valid R variable name because
it has spaces in it (and you didn't specify the data frame to look for
those variable in).

Hadley

-- 
http://had.co.nz/

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


Re: [R] Binomial simulation

2009-04-18 Thread Ranjan Maitra
This sounds like a potential homework problem. You don't quite need to
simulate anything if your question is all you have been asked to do.

dbinom(x = 1:10, size = 10, prob = 0.25)

Perhaps you have been asked to simulate 1000 realizations and compare
the relative frequencies with these probabilities: use 

rbinom(n = 1000, size = 10, prob = 0.25)

in that case and compare the relative frequencies.

Btw, there is a small chance of getting a 0. Are you sure the
instructor (or whoever has issued the orders) wants only from 1:10?

HTH!
Ranjan

On Fri, 17 Apr 2009 22:23:11 -0700 (PDT) beetle2
samandbren...@aapt.net.au wrote:

 
 
 Not being entirely sure what you mean, I think 
 
 rbinom(1000, 10, .25) 
 
 may be what you want. 
 
 Hi,
 Thanks for your reply.
 It is close to that but I need to know the probabilty of how many judges
 pick a certain brand.
 Just say x= 6 judges pick brand A which has P=0.25.
 
 Using R it would be:
  dbinom(6,10,.25)
 [1] 0.016222
 
 Probability of six judges choosing  brand A. Hence not very likely.
 
 I have been asked to do this for all values of x = 1 to 10.
 But the question says to simulate 1000 trials for each x value.
 I'm not sure how to construct the simulation.
 regards
 Brendan
 
 
 -- 
 View this message in context: 
 http://www.nabble.com/Binomial-simulation-tp23106347p23109522.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] matching subvectors in vector sets

2009-04-18 Thread David Winsemius

xlist -list()
 for (i in 2:length(x.s)){
  x.seq - embed(length(x.s):1, i)
  xlist[[i]] - table(apply(x.seq, 1, function(z){
  paste(x.s[z], collapse=:)
  }))
  }
 xlist

--  
David Winsemius

On Apr 18, 2009, at 11:46 AM, Albert Vilella wrote:

that works very well. how do I store the results into a variable  
instead of

doing a print?

On Fri, Apr 17, 2009 at 5:51 PM, jim holtman jholt...@gmail.com  
wrote:



How about this:


x - A00096:A00096:A00096:A00096:A02178:A02178:A07776
x.s - unlist(strsplit(x, :))
for (i in 2:length(x.s)){

+ x.seq - embed(length(x.s):1, i)
+ print(table(apply(x.seq, 1, function(z){
+ paste(x.s[z], collapse=:)
+ })))
+ }

A00096:A00096 A00096:A02178 A02178:A02178 A02178:A07776
  3 1 1 1

A00096:A00096:A00096 A00096:A00096:A02178 A00096:A02178:A02178
A02178:A02178:A07776
 211
 1

A00096:A00096:A00096:A00096 A00096:A00096:A00096:A02178
A00096:A00096:A02178:A02178 A00096:A02178:A02178:A07776
1   1
 1   1

A00096:A00096:A00096:A00096:A02178 A00096:A00096:A00096:A02178:A02178
A00096:A00096:A02178:A02178:A07776
1  1
   1

A00096:A00096:A00096:A00096:A02178:A02178
A00096:A00096:A00096:A02178:A02178:A07776
  1
 1

A00096:A00096:A00096:A00096:A02178:A02178:A07776
 1


On Fri, Apr 17, 2009 at 9:33 AM, Albert Vilella avile...@gmail.com
wrote:

Starting by the first entry:
A00096:A00096:A00096:A00096:A02178:A02178:A07776

and supposing there aren't any other subvectors identical in the  
set, the
algorithm will slide through the vector, first in pairs, then in  
trios,

then

in sets of four, etc, and count the occurrences:

A00096:A00096
3
A00096:A02178
1
A02178:A02178
1
A02178:A07776
1
A00096:A00096:A00096
2
A00096:A00096:A02178
1
A00096:A02178:A02178
1
A02178:A02178:A07776
1
A00096:A00096:A00096:A00096
1
A00096:A00096:A00096:A02178
1
A00096:A00096:A02178:A02178
1
A00096:A02178:A02178:A07776
1
A00096:A00096:A00096:A00096:A02178
1
A00096:A00096:A00096:A02178:A02178
1
A00096:A00096:A02178:A02178:A07776
1
A00096:A00096:A00096:A00096:A02178:A02178
1
A00096:A00096:A00096:A02178:A02178:A07776
1
A00096:A00096:A00096:A00096:A02178:A02178:A07776
1




On Fri, Apr 17, 2009 at 1:04 PM, jim holtman jholt...@gmail.com  
wrote:


Can you provide the output that you would expect from the data you
gave.  I am not sure what you mean by a 'subvector'.

On Fri, Apr 17, 2009 at 5:25 AM, Albert Vilella  
avile...@gmail.com

wrote:

Hi,

I've got a list of ~2 elements that look like this:

[1]
A00096:A00096:A00096:A00096:A02178:A02178:A07776

[2]
A00046:A00076:A01101:A04146:A05671:A07169

[3]


A00038 
:A00932 
:A02185:A02370:A02818:A02818:A02818:A02818:A04732:A07142:A07142


[4]
A00096:A01352:A01352:A02023:A05001:A05001:A07776

[5]


A00036 
:A00047 
:A00059 
:A00503 
:A00904:A00904:A00904:A01023:A01023:A01399:A02029:A03941:A07679

[6]


A00041 
:A00533 
:A00855 
:A02178 
:A02178:A02178:A05671:A05671:A05671:A05671:A05671:A05671:A05671

...

And I would like to have a table with the frequency of  
occurrences for

matching subvectors in all elements, i.e., not
only the number of times a vector is found but also how many  
times a

subvector (of at least 2 ids) is found.

How can I do that?
Thanks in advance,
Albert.

  [[alternative HTML version deleted]]

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





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

What is the problem that you are trying to solve?







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

What is the problem that you are trying to solve?



[[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
Heritage Laboratories
West Hartford, CT

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


Re: [R] Neural Networks in R - Query

2009-04-18 Thread ronggui
More specifically, it is nnet package.

Best

2009/4/18 Tobias Verbeke tobias.verb...@telenet.be:
 Hi Lars,

 I'd like to ask your guidance regarding the following two questions: (i) I
 just finished reading Chris Bishop's book Neural Networks for Pattern
 Recognition. Although the book gave me good theoretical foundation about
 NN, I'm now looking for something more practical regarding architecture
 selection strategies. Is there any good reference about best practices
 for
 architecure selection? (ii) Which R package provides a good implementation
 of NN?

 The CRAN Task View on Machine Learning

 http://cran.r-project.org/web/views/MachineLearning.html

 opens with the following topical item:

 o Neural Networks : Single-hidden-layer neural network are implemented
 in package nnet as part of the VR  bundle (shipped with base R).

 HTH,
 Tobias

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




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

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


Re: [R] Monotone Transformation

2009-04-18 Thread Martin Maechler
 FJ == Feng Jingyu feng...@battelle.org
 on Fri, 17 Apr 2009 11:22:01 -0700 (PDT) writes:

FJ Hi, I am trying to use R to mimic what I did in SAS.

FJ proc transreg data=x ;
FJ   model identity(GSI)=monotone(group1);
FJ   output out=d2 pprefix=M;
FJ run; 

FJ Accroding to SAS documentation, the MONOTONE transfomation algorithm 
comes
FJ from (Kruskal 1964, secondary approach to ties). I have tried ace. it 
does
FJ provide some kind of monotone transformation, but it is not what I 
expected.

FJ Here is how sas output look like:

FJ Obs  GSITGSI group1Tgroup1

FJ 1 0.813010.81301   1  1.55594
FJ 2 0.793590.79359   2  1.55594
FJ 3 1.269001.26900   3  2.59702
FJ 4 2.026802.02680   4  4.29111

FJ group1 is the inital value. Tgroup1 is the monotone transformed value.

FJ Here is how Transformed value output from ace:

FJ $tx
FJ [,1]
FJ [1,] -0.5698602
FJ [2,] -0.1899534
FJ [3,]  0.1899534
FJ [4,]  0.5698602

FJ Does anybody have any idea whether I could do the similar thing in R? 
If I
FJ can do it, which function I should use?

I don't know what exactly you want,
and I'd never want to read SAS code to understand your question, 
but it could be that  isoreg()  can solve your problem,
notably 
rr - isoreg(x,y)
rr $yf  ## your transformed y

Regards,
Martin Maechler, ETH Zurich

FJ Thanks,
FJ Jingyu

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

2009-04-18 Thread spencerg
An alternative to isoreg is smooth.monotone in the fda package, 
though it would doubtless require more work to use smooth.monotone. 

Hope this helps. 
Spencer


Martin Maechler wrote:

FJ == Feng Jingyu feng...@battelle.org
on Fri, 17 Apr 2009 11:22:01 -0700 (PDT) writes:



FJ Hi, I am trying to use R to mimic what I did in SAS.

FJ proc transreg data=x ;
FJ   model identity(GSI)=monotone(group1);
FJ   output out=d2 pprefix=M;
FJ run; 


FJ Accroding to SAS documentation, the MONOTONE transfomation algorithm 
comes
FJ from (Kruskal 1964, secondary approach to ties). I have tried ace. it 
does
FJ provide some kind of monotone transformation, but it is not what I 
expected.

FJ Here is how sas output look like:

FJ Obs  GSITGSI group1Tgroup1

FJ 1 0.813010.81301   1  1.55594
FJ 2 0.793590.79359   2  1.55594
FJ 3 1.269001.26900   3  2.59702
FJ 4 2.026802.02680   4  4.29111

FJ group1 is the inital value. Tgroup1 is the monotone transformed value.

FJ Here is how Transformed value output from ace:

FJ $tx
FJ [,1]
FJ [1,] -0.5698602
FJ [2,] -0.1899534
FJ [3,]  0.1899534
FJ [4,]  0.5698602

FJ Does anybody have any idea whether I could do the similar thing in R? 
If I
FJ can do it, which function I should use?

I don't know what exactly you want,
and I'd never want to read SAS code to understand your question, 
but it could be that  isoreg()  can solve your problem,
notably 
	rr - isoreg(x,y)

rr $yf  ## your transformed y

Regards,
Martin Maechler, ETH Zurich

FJ Thanks,
FJ Jingyu

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

2009-04-18 Thread Qifei Zhu
Hi all,

I'm a newbie R developer, am trying to dotplot a few graphs using a for
loop.

The following code works fine but once I wanna plot inside a loop, nothing
happens.
 for(i in 1:1){dotplot(y~x)}
 y - c(1,2,3)
 x - c('a','b','c')
 dotplot(y~x)

 for (i in 1:3) {dotplot(y~x)} (y and x depends on I in actual case)
Nothing happens.

I appreciate your advice on what is going wrong? Thanks.

Best,
Tony

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

2009-04-18 Thread Jun Shen
Brendan,

Matrix is atomic. Once you define t1 in matrix, t1[1]=0  rather than the
whole column. I would just convert t1 to a data frame, which is a special
list, by adding t1- data.frame(t1).  Now t1[1] represents the whole column.
Then you can use your loop to add more columns.

Jun

On Fri, Apr 17, 2009 at 9:12 PM, Brendan Morse morse.bren...@gmail.comwrote:

 Hi everyone, I am trying to accomplish a small task that is giving me quite
 a headache. I would like to automatically generate a series of matrices and
 give them successive names. Here is what I thought at first:

 t1-matrix(0, nrow=250, ncol=1)

 for(i in 1:10){
t1[i]-rnorm(250)
 }

 What I intended was that the loop would create 10 different matrices with a
 single column of 250 values randomly selected from a normal distribution,
 and that they would be labeled t11, t12, t13, t14 etc.

 Can anyone steer me in the right direction with this one?

 Thanks!
 Brendan

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




-- 
Jun Shen PhD
PK/PD Scientist
BioPharma Services
Millipore Corporation
15 Research Park Dr.
St Charles, MO 63304
Direct: 636-720-1589

[[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] Modelling an incomplete Poisson distribution ?

2009-04-18 Thread Emmanuel Charpentier
Dear list,

I have the following problem : I want to model a series of observations
of a given hospital activity on various days under various conditions.
among my outcomes (dependent variables) is the number of patients for
which a certain procedure is done. The problem is that, when no relevant
patient is hospitalized on said day, there is no observation (for which
the number of patients item would be 0). 

My goal is to model this number of patients as a function of the
various conditions described by my independant variables, mosty of
them observed but uncontrolled, some of them unobservable (random
effects). I am tempted to model them along the lines of :

glm(NoP~X+Y+..., data=MyData, family=poisson(link=log))

or (accounting for some random effects) :

lmer(NoP~X+Y+(X|Center)), data=Mydata, family=poisson(link=log))

While the preliminary analysis suggest that (the right part of) a
Poisson distribution might be reasonable for all real observations, the
lack of observations with count==0 bothers me.

Is there a way to cajole glm (and lmer, by the way) into modelling these
data to an incomplete Poisson model, i. e. with unobserved 0
values ?

Sincerely,

Emmanuel Charpentier

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

2009-04-18 Thread Mike Lawrence
When plotting in loops, you need to wrap your plot call in print().

On Sat, Apr 18, 2009 at 2:14 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi all,

 I'm a newbie R developer, am trying to dotplot a few graphs using a for
 loop.

 The following code works fine but once I wanna plot inside a loop, nothing
 happens.
 for(i in 1:1){dotplot(y~x)}
 y - c(1,2,3)
 x - c('a','b','c')
 dotplot(y~x)

 for (i in 1:3) {dotplot(y~x)} (y and x depends on I in actual case)
 Nothing happens.

 I appreciate your advice on what is going wrong? Thanks.

 Best,
 Tony

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




-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

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

2009-04-18 Thread Qifei Zhu
It works. Thanks!

-Original Message-
From: mike.lw...@gmail.com [mailto:mike.lw...@gmail.com] On Behalf Of Mike
Lawrence
Sent: Saturday, April 18, 2009 1:30 PM
To: Qifei Zhu
Cc: r-help@r-project.org
Subject: Re: [R] Welcome to the R-help mailing list

When plotting in loops, you need to wrap your plot call in print().

On Sat, Apr 18, 2009 at 2:14 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi all,

 I'm a newbie R developer, am trying to dotplot a few graphs using a for
 loop.

 The following code works fine but once I wanna plot inside a loop, nothing
 happens.
 for(i in 1:1){dotplot(y~x)}
 y - c(1,2,3)
 x - c('a','b','c')
 dotplot(y~x)

 for (i in 1:3) {dotplot(y~x)} (y and x depends on I in actual case)
 Nothing happens.

 I appreciate your advice on what is going wrong? Thanks.

 Best,
 Tony

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




-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

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

2009-04-18 Thread Uwe Ligges



Qifei Zhu wrote:

Hi all,

I'm a newbie R developer, am trying to dotplot a few graphs using a for
loop.

The following code works fine but once I wanna plot inside a loop, nothing
happens.

for(i in 1:1){dotplot(y~x)}
y - c(1,2,3)
x - c('a','b','c')
dotplot(y~x)



for (i in 1:3) {dotplot(y~x)} (y and x depends on I in actual case)

Nothing happens.



dotplot is a lattice function that need to be print()-ed which happened 
before automatically (as you'd type x in it is printed).



Uwe Ligges



I appreciate your advice on what is going wrong? Thanks.

Best,
Tony

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] From daily series to monthly and viceversa

2009-04-18 Thread manta

Well Gabor, this is actually a really good help, thanks so much.
There is only one problem, I'm getting what you say, but in the code there
are a couple of errors

time(z2) - as.Date(time(zz)) #probably z2
z3 - na.locf(
cbind(zz,
zoo(, dd), #dd object not found
day.of.month = as.numeric(format(time(zz), %d))
))
z3$day.of.month - as.numeric(format(time(zz2), %d)) #z2?

And why did you call partial this solution?
Thanks again for you great help
Take care


Gabor Grothendieck wrote:
 
 Here is a partial solution:
 
 library(zoo)
 # z is CPI.  Just use 1, 2, 3, ... for example.
 z - zooreg(1:12, as.yearmon(2008-01), freq = 12)
 days.in.month - as.numeric(as.Date(time(z), frac = 1) - as.Date(time(z))
 + 1)
 z2 - cbind(z, z1 = lag(z, -1), z2 = lag(z, -2), z3 = lag(z, -3),
 days.in.month)
 time(z2) - as.Date(time(zz))
 z3 - na.locf(
   cbind(zz,
   zoo(, dd),
   day.of.month = as.numeric(format(time(zz), %d))
 ))
 z3$day.of.month - as.numeric(format(time(zz2), %d))
 # now each row of z3 has all the data you need so apply(z3, 1,
 your.function)
 
 
 On Fri, Apr 17, 2009 at 2:13 PM, manta mantin...@libero.it wrote:

 any update anybody? I'm really stucked!
 --
 View this message in context:
 http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23103052.html
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23115847.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] Modelling an incomplete Poisson distribution ?

2009-04-18 Thread Emmanuel Charpentier
I forgot to add that yes, I've done my homework, and that it seems to me
that answers pointing to zero-inflated Poisson (and negative binomial)
are irrelevant ; I do not have a mixture of distributions but only part
of one distribution, or, if you'll have it, a zero-deflated Poisson.

An answer by Brian Ripley
(http://finzi.psych.upenn.edu/R/Rhelp02/archive/11029.html) to a similar
question leaves me a bit dismayed : if it is easy to compute the
probability function of this zero-deflated RV (off the top of my head,
Pr(X=x)=e^-lambda.lambda^x/(x!.(1-e^-lambda))), and if I think that I'm
(still) able to use optim to ML-estimate lambda, using this to
(correctly) model my problem set and test it amounts to re-writing some
(large) part of glm. Furthermore, I'd be a bit embarrassed to test it
cleanly (i. e. justifiably) : out of the top of my head, only the
likelihood ration test seems readily applicable to my problem. Testing
contrasts in my covariates ... hum !

So if someone has written something to that effect, I'd be awfully glad
to use it. A not-so-cursory look at the existing packages did not ring
any bells to my (admittedly untrained) ears...

Of course, I could also bootstrap the damn thing and study the
distribution of my contrasts. I'd still been hard pressed to formally
test hypotheses on factors...

Any ideas ?

Emmanuel Charpentier

Le samedi 18 avril 2009 à 19:28 +0200, Emmanuel Charpentier a écrit :
 Dear list,
 
 I have the following problem : I want to model a series of observations
 of a given hospital activity on various days under various conditions.
 among my outcomes (dependent variables) is the number of patients for
 which a certain procedure is done. The problem is that, when no relevant
 patient is hospitalized on said day, there is no observation (for which
 the number of patients item would be 0). 
 
 My goal is to model this number of patients as a function of the
 various conditions described by my independant variables, mosty of
 them observed but uncontrolled, some of them unobservable (random
 effects). I am tempted to model them along the lines of :
 
 glm(NoP~X+Y+..., data=MyData, family=poisson(link=log))
 
 or (accounting for some random effects) :
 
 lmer(NoP~X+Y+(X|Center)), data=Mydata, family=poisson(link=log))
 
 While the preliminary analysis suggest that (the right part of) a
 Poisson distribution might be reasonable for all real observations, the
 lack of observations with count==0 bothers me.
 
 Is there a way to cajole glm (and lmer, by the way) into modelling these
 data to an incomplete Poisson model, i. e. with unobserved 0
 values ?
 
 Sincerely,
 
   Emmanuel Charpentier
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] From daily series to monthly and viceversa

2009-04-18 Thread Gabor Grothendieck
Try this:

library(zoo)

# z is CPI.  Just use 1, 2, 3, ... for example.

z - zooreg(1:12, as.yearmon(2008-01), freq = 12)

# z2 contains z and lags of z and days.in.month
# It has a Date class time index, rather than yearmon.

days.in.month - as.numeric(as.Date(time(z), frac = 1) - as.Date(time(z)) + 1)
z2 - cbind(z, z1 = lag(z, -1), z2 = lag(z, -2), z3 = lag(z, -3), days.in.month)
time(z2) - as.Date(time(z2))

# z3 is z2 expanded to include each day of each month and
# day of the month that each row represents

dd - seq(time(z2)[1], as.Date(as.yearmon(tail(time(z2), 1)), frac = 1), day)
z3 - na.locf(cbind(z2, zoo(, dd)))
z3$day.of.month - as.numeric(format(time(z3), %d))

# now each row of z3 has all the data you need so apply(z3, 1, your.function)


On Sat, Apr 18, 2009 at 2:28 PM, manta mantin...@libero.it wrote:

 Well Gabor, this is actually a really good help, thanks so much.
 There is only one problem, I'm getting what you say, but in the code there
 are a couple of errors

 time(z2) - as.Date(time(zz)) #probably z2
 z3 - na.locf(
                cbind(zz,
                        zoo(, dd), #dd object not found
                        day.of.month = as.numeric(format(time(zz), %d))
 ))
 z3$day.of.month - as.numeric(format(time(zz2), %d)) #z2?

 And why did you call partial this solution?
 Thanks again for you great help
 Take care


 Gabor Grothendieck wrote:

 Here is a partial solution:

 library(zoo)
 # z is CPI.  Just use 1, 2, 3, ... for example.
 z - zooreg(1:12, as.yearmon(2008-01), freq = 12)
 days.in.month - as.numeric(as.Date(time(z), frac = 1) - as.Date(time(z))
 + 1)
 z2 - cbind(z, z1 = lag(z, -1), z2 = lag(z, -2), z3 = lag(z, -3),
 days.in.month)
 time(z2) - as.Date(time(zz))
 z3 - na.locf(
               cbind(zz,
                       zoo(, dd),
                       day.of.month = as.numeric(format(time(zz), %d))
 ))
 z3$day.of.month - as.numeric(format(time(zz2), %d))
 # now each row of z3 has all the data you need so apply(z3, 1,
 your.function)


 On Fri, Apr 17, 2009 at 2:13 PM, manta mantin...@libero.it wrote:

 any update anybody? I'm really stucked!
 --
 View this message in context:
 http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23103052.html
 Sent from the R help mailing list archive at Nabble.com.

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


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



 --
 View this message in context: 
 http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23115847.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] Dummy (factor) based on a pair of variables

2009-04-18 Thread Serguei Kaniovski

Bernardo: this is not quite what I am looking for,

Let the data be:
y,i,j
1,AUT,BEL
2,AUT,GER
3,BEL,GER

then the dummies sould look like:

y,i,j,d_AUT,d_BEL,d_GER
1,AUT,BEL,1,1,0
2,AUT,GER,1,0,1
3,BEL,GER,0,1,1

I can generate the above dummies but can this design be imputed in a 
reg. model directly?


Serguei

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

2009-04-18 Thread Dan Cary

Hi, as a newcomer to R i have what probably is a very simple issue but i have 
been to solve it for hours:
all i want to know is how to arrange a set of numbers in size order without 
putting them in a table. just arranging them from for e.g. 2,1,3,5,4 into 
1,2,3,4,5 - it must be simple but i cant find how to do it anywhere
thanksdan
_
[[elided Hotmail spam]]

[[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] Can't read table encoded in Unicode (R-2.8.1)

2009-04-18 Thread Hilmar Berger

Hi all,

I have problems reading Unicode (UTF-16) coded tables in R 2.8.1 under 
Windows Vista.


Imagine the following table:

abcd
X1,21,31,4
Y2,22,32,4
Z3,23,33,4

Usually I would use the following code to read the table:

t = read.table(test.txt, header=T, sep=\t,dec=,)

This works well if I create the table using Notepad (the text will be in 
UTF-8 or ASCII, then).


However, If I use e.g. OpenOffice scalc to create a spreadsheet holding 
the same data and save this data as text (using tabs as separators, no 
quotes and using Unicode encoding)  the command above gives this:


 t = read.table(test.csv, header=T, sep=\t,dec=,)
 t
 ÿþa
1  NA
2  NA
3  NA

I tried to play with the encoding parameter but that would not change 
anything.


The file from OpenOffice is in UTF-16, as shown by hexdump:
$ hexdump test.csv
000 feff 0061 0009 0062 0009 0063 0009 0064
010 000d 000a 0058 0009 0031 002c 0032 0009
020 0031 002c 0033 0009 0031 002c 0034 000d
030 000a 0059 0009 0032 002c 0032 0009 0032
040 002c 0033 0009 0032 002c 0034 000d 000a
050 005a 0009 0033 002c 0032 0009 0033 002c
060 0033 0009 0033 002c 0034 000d 000a
06e

I tried to read the file using file/readLines, which seemed to work 
after specifying the encoding:


 a = file(test.csv,open=r, encoding=UTF-16)
 b = readLines(a)
 b
[1] a\tb\tc\td   X\t1,2\t1,3\t1,4 Y\t2,2\t2,3\t2,4 
Z\t3,2\t3,3\t3,4


Looking at the code of readtable.R in R-2.8.1. and R-2.9.0 it seems that 
the encoding does not get passed through in the second call to scan() 
appearing in the code.


I'm not sure if this is a bug or if I'm doing something wrong here.

Regards,
Hilmar

--
My system  and R settings are:

 sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

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


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

 Sys.info()
sysname  
release  version nodename
  Windows  Vista build 6001, 
Service Pack 1  PC
machine
login user
  x86  


 options(encoding)
$encoding
[1] native.enc

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

2009-04-18 Thread Ranjan Maitra
Welcome to R!

I don't quite know what you mean by size order. But if you have five
numbers:

a - c(2, 1, 3, 5, 4)

then sort(a)

will do what you want?

HTH!
Ranjan


On Sat, 18 Apr 2009 14:46:04 + Dan Cary daniel_c...@hotmail.co.uk
wrote:

 
 Hi, as a newcomer to R i have what probably is a very simple issue but i have 
 been to solve it for hours:
 all i want to know is how to arrange a set of numbers in size order without 
 putting them in a table. just arranging them from for e.g. 2,1,3,5,4 into 
 1,2,3,4,5 - it must be simple but i cant find how to do it anywhere
 thanksdan
 _
 [[elided Hotmail spam]]
 
   [[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] (no subject)

2009-04-18 Thread Stavros Macrakis
 mylist - c( 2,1,3,5,4 ) make a vector of numbers
 sort(mylist)
[1] 1 2 3 4 5in sorted order

 mylist - c( this, is, a, test)
 sort(mylist)
[1] ais   test this   in sorted order
 order(mylist)
[1] 3 2 4 1  original positions, e.g. mylist[3] is a


On Sat, Apr 18, 2009 at 10:46 AM, Dan Cary daniel_c...@hotmail.co.uk wrote:
 ...all i want to know is how to arrange a set of numbers in size order 
 without putting them in a table. just arranging them from for e.g. 2,1,3,5,4 
 into 1,2,3,4,5 - it must be simple but i cant find how to do it anywhere

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

2009-04-18 Thread Stavros Macrakis
On Fri, Apr 17, 2009 at 10:12 PM, Brendan Morse morse.bren...@gmail.com wrote:
 ...I would like to automatically generate a series of matrices and
 give them successive names. Here is what I thought at first:

 t1-matrix(0, nrow=250, ncol=1)

 for(i in 1:10){
        t1[i]-rnorm(250)
 }

 What I intended was that the loop would create 10 different matrices with a
 single column of 250 values randomly selected from a normal distribution,
 and that they would be labeled t11, t12, t13, t14 etc.

Very close.  But since you've started out with a *matrix* t1, your
assignments to t1[i] will assign to parts of the matrix.  To correct
this, all you need to do is initialize t1 as a *list of matrices* or
(even better) as an *empty list*, like this:

   t1 - list()

and then assign to *elements* of the list (using [[ ]] notation), not
to *sublists* of the list (which is what [ ] notation means in R),
like this:

for(i in 1:10){
   t1[[i]] - rnorm(250)
}

Is that what you had in mind?

   -s

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can't read table encoded in Unicode (R-2.8.1)

2009-04-18 Thread Duncan Murdoch

On 18/04/2009 1:18 PM, Hilmar Berger wrote:

Hi all,

I have problems reading Unicode (UTF-16) coded tables in R 2.8.1 under 
Windows Vista.


Imagine the following table:

abcd
X1,21,31,4
Y2,22,32,4
Z3,23,33,4

Usually I would use the following code to read the table:

t = read.table(test.txt, header=T, sep=\t,dec=,)

This works well if I create the table using Notepad (the text will be in 
UTF-8 or ASCII, then).


I haven't tried 2.8.1 (which is obsolete, since yesterday :-), but in 
2.9.0 it works fine if I use the fileEncoding argument to read.table.


Duncan Murdoch


However, If I use e.g. OpenOffice scalc to create a spreadsheet holding 
the same data and save this data as text (using tabs as separators, no 
quotes and using Unicode encoding)  the command above gives this:


  t = read.table(test.csv, header=T, sep=\t,dec=,)
  t
  ÿþa
1  NA
2  NA
3  NA

I tried to play with the encoding parameter but that would not change 
anything.


The file from OpenOffice is in UTF-16, as shown by hexdump:
$ hexdump test.csv
000 feff 0061 0009 0062 0009 0063 0009 0064
010 000d 000a 0058 0009 0031 002c 0032 0009
020 0031 002c 0033 0009 0031 002c 0034 000d
030 000a 0059 0009 0032 002c 0032 0009 0032
040 002c 0033 0009 0032 002c 0034 000d 000a
050 005a 0009 0033 002c 0032 0009 0033 002c
060 0033 0009 0033 002c 0034 000d 000a
06e

I tried to read the file using file/readLines, which seemed to work 
after specifying the encoding:


  a = file(test.csv,open=r, encoding=UTF-16)
  b = readLines(a)
  b
[1] a\tb\tc\td   X\t1,2\t1,3\t1,4 Y\t2,2\t2,3\t2,4 
Z\t3,2\t3,3\t3,4


Looking at the code of readtable.R in R-2.8.1. and R-2.9.0 it seems that 
the encoding does not get passed through in the second call to scan() 
appearing in the code.


I'm not sure if this is a bug or if I'm doing something wrong here.

Regards,
Hilmar

--
My system  and R settings are:

  sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

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


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

  Sys.info()
 sysname  
release  version nodename
   Windows  Vista build 6001, 
Service Pack 1  PC
 machine
login user
   x86  


  options(encoding)
$encoding
[1] native.enc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dummy (factor) based on a pair of variables

2009-04-18 Thread Jason Morgan
On 2009.04.18 13:52:35, Serguei Kaniovski wrote:
 Bernardo: this is not quite what I am looking for,
 
 Let the data be:
 y,i,j
 1,AUT,BEL
 2,AUT,GER
 3,BEL,GER
 
 then the dummies sould look like:
 
 y,i,j,d_AUT,d_BEL,d_GER
 1,AUT,BEL,1,1,0
 2,AUT,GER,1,0,1
 3,BEL,GER,0,1,1
 
 I can generate the above dummies but can this design be imputed in a 
 reg. model directly?
 
 Serguei

Hello Serguei,

I am sure there is a better way to do this, but the following seems to
work:

# Create sample data.frame()
i  - c(AUT, AUT, BEL)
j  - c(BEL, GER, GER)
df - data.frame(i=i, j=j)

# Create dummy vectors
df$d.aut - ifelse(df$i==AUT|df$j==AUT, 1, 0)
df$d.bel - ifelse(df$i==BEL|df$j==BEL, 1, 0)
df$d.ger - ifelse(df$i==GER|df$j==GER, 1, 0)

# Print results
df

HTH,

~Jason


--
Jason W. Morgan
Graduate Student, Political Science
*The Ohio State University*

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


Re: [R] Dummy (factor) based on a pair of variables

2009-04-18 Thread Jason Morgan
On 2009.04.18 15:58:30, Jason Morgan wrote:
 On 2009.04.18 13:52:35, Serguei Kaniovski wrote:
  I can generate the above dummies but can this design be imputed in a 
  reg. model directly?

Oops, I apologize for not reading the whole question. Can you do the
following:

lm(y ~ I(ifelse(df$i==AUT|df$j==AUT, 1, 0)) +
   I(ifelse(df$i==BEL|df$j==BEL, 1, 0)) +
   I(ifelse(df$i==GER|df$j==GER, 1, 0)), data=df)

If you exclude the ifelse(), you will get a vector of TRUE/FALSE,
which may or may not work.

~Jason

 Hello Serguei,
 
 I am sure there is a better way to do this, but the following seems to
 work:
 
 # Create sample data.frame()
 i  - c(AUT, AUT, BEL)
 j  - c(BEL, GER, GER)
 df - data.frame(i=i, j=j)
 
 # Create dummy vectors
 df$d.aut - ifelse(df$i==AUT|df$j==AUT, 1, 0)
 df$d.bel - ifelse(df$i==BEL|df$j==BEL, 1, 0)
 df$d.ger - ifelse(df$i==GER|df$j==GER, 1, 0)
 
 # Print results
 df
 
 HTH,
 
 ~Jason
 
 

--
Jason W. Morgan
Graduate Student, Political Science
*The Ohio State University*

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


Re: [R] From daily series to monthly and viceversa

2009-04-18 Thread manta

Thanks so much

-- 
View this message in context: 
http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23116875.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] Dummy (factor) based on a pair of variables

2009-04-18 Thread David Winsemius

 df - read.table(textConnection(y,i,j
+ 1,AUT,BEL
+ 2,AUT,GER
+ 3,BEL,GER), header=T,sep=,, as.is=T)
 df
  y   i   j
1 1 AUT BEL
2 2 AUT GER
3 3 BEL GER
 countries - unique(c(df$i,df$j))
 countries
[1] AUT BEL GER

 df[countries] - sapply(countries, function(x) df[x] - df$i == x  
| df$j == x)

 df
  y   i   j   AUT   BEL   GER
1 1 AUT BEL  TRUE  TRUE FALSE
2 2 AUT GER  TRUE FALSE  TRUE
3 3 BEL GER FALSE  TRUE  TRUE

Obviously it would not be possible to test this arrangement with lm.

So I tried scaling it up and testing on:
 dft - data.frame(y=rnorm(100), i = sample(countries, 100,  
replace=T), j= sample(countries, 100, replace=T))

#Removed all the duplicates with:
dft - dft(dft$i != dft$j, ]
#and it did not give proper answers.

This seems to give correct answers
 dft[countries] - sapply(countries, function(y) apply(dft, 1,  
function(x)   x[2] == y | x[3] == y))


And application of those variables is handles in a reasonable manner  
by the R formula parser:

 lm(y ~ AUT + BEL + GER, data=dft)

Call:
lm(formula = y ~ AUT + BEL + GER, data = dft)

Coefficients:
(Intercept)  AUTTRUE  BELTRUE  GERTRUE
0.09192  0.15130 -0.29274   NA

-
David Winsemius


On Apr 18, 2009, at 4:09 PM, Jason Morgan wrote:


On 2009.04.18 15:58:30, Jason Morgan wrote:

On 2009.04.18 13:52:35, Serguei Kaniovski wrote:

I can generate the above dummies but can this design be imputed in a
reg. model directly?


Oops, I apologize for not reading the whole question. Can you do the
following:

lm(y ~ I(ifelse(df$i==AUT|df$j==AUT, 1, 0)) +
  I(ifelse(df$i==BEL|df$j==BEL, 1, 0)) +
  I(ifelse(df$i==GER|df$j==GER, 1, 0)), data=df)

If you exclude the ifelse(), you will get a vector of TRUE/FALSE,
which may or may not work.

~Jason


Hello Serguei,

I am sure there is a better way to do this, but the following seems  
to

work:

# Create sample data.frame()
i  - c(AUT, AUT, BEL)
j  - c(BEL, GER, GER)
df - data.frame(i=i, j=j)

# Create dummy vectors
df$d.aut - ifelse(df$i==AUT|df$j==AUT, 1, 0)
df$d.bel - ifelse(df$i==BEL|df$j==BEL, 1, 0)
df$d.ger - ifelse(df$i==GER|df$j==GER, 1, 0)

# Print results
df

HTH,

~Jason




--
Jason W. Morgan
Graduate Student, Political Science
*The Ohio State University*

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] [R-pkgs] igraph 0.5.2

2009-04-18 Thread Gábor Csárdi
igraph is a package for graphs/networks. It has a C core and
uses a simple and fast graph representation allowing millions
of vertices and edges.

LINKS

Release notes for the 0.5.2 version:
http://igraph.sourceforge.net/relnotes-0.5.2.html

Release notes for the 0.5.1 version:
http://igraph.sourceforge.net/relnotes-0.5.1.html

Complete list of changes:
http://igraph.sourceforge.net/news.html

The igraph homepage: http://igraph.sf.net

Since there was no announcement about igraph version 0.5.1
on R-pkgs, here is a list of the more important new things of both
version 0.5.2 and 0.5.1.

NEW FEATURES IN THE 0.5.2 VERSION

- We have some support for bipartite (two-mode) graphs now.
  See ?graph.incidence, ?get.incidence for dealing with
  incidence matrices, ?graph.bipartite for a way to
  create bipartite graphs, ?bipartite.projection for
  creating one-mode projections. See ?is.bipartite for
  deciding whether a graph has a bipartite structure.
- A new simple and fast community finding algorithm called 'label
  propagation' was added, see ?label.propagation.community
  for details.
- The DrL layout generator now supports 3d layouts.
- A limited Tcl/Tk igraph GUI was added, please note that it supports
  only a small fraction of the igraph functions. You can start it with
  the tkigraph() function.
- Johnson's algorithm is now supported by the shortest path finder.
  It allows negative edge weight, but not negative cycles.
  See ?shortest.paths.
- The graph.knn function was added to calculate the average
  nearest neighbor degree. It supports edge weights as well.
- Curved edges are now supported by plot() and tkplot(), see
  ?igraph.plotting for the details.
- Many bugs and memory leaks were fixed, see the News section on the
  igraph homepage for details.

NEW FEATURES IN THE 0.5.1 VERSION

- DrL layout generator was added, see ?layout.drl.
- Uniform sampling of graphs with a given degree sequence,
  see ?degree.sequence.game.
- Conversion functions to/from graphNEL objects (graph package),
  see ?igraph.to.graphNEL and ?igraph.from.graphNEL.
- Conversion functions to/from sparse matrices (Matrix package),
  see ?graph.adjacency and the 'sparse' argument of
  ?get.adjacency.
- Creating graphs from adjacency lists, see ?graph.adjlist.
- The function graph.data.frame has an argument called
  'vertices' and this makes it very easy to create graphs
  with a lot of vertex and edge metadata.
- The Dijkstra and Bellman-Ford shortest path algorithms
  were added, see ?shortest.paths.
- The function is.mutual() was added, this tests edge reciprocity.
- The plot() function now supports plottings different vertex
  shapes. See ?igraph.plotting and ?igraph.vertex.shapes for
  detaills.
- Many bugs were fixed, see the News section on the igraph
  homepage for details.

PACKAGE DESCRIPTION:

igraph is originally a C library for graphs, but has interfaces
to high level languages like R, Python and Ruby. The R package
contains BOTH the C library and its R interface.

igraph supports:

- graph generators, creating both regular structures like trees,
  lattices, etc. and various random graphs.
- a rich set of functions calculating structural properties of
  graphs, like vertex centrality (degree, betweenness, closeness,
  page rank, eigenvector centrality, Burt's constraints, etc.),
  shortest paths, dyad and triad census, network motifs, girth,
  K-core decomposition, etc.
- attributes can be associated with the vertices/edges of the graph,
  or the graph itself. The attributes can be arbitrary R objects.
- graph visualization using regular R devices, interactive visualization
  using Tcl/Tk, 3D visualization using RGL.
- graph layout generators, the standard Kamada-Kawai and
  Fruchterman-Reingold algorithms are included, plus many more.
- Functions for graph and subgraph isomorphism, the BLISS and the VF2
  algorithms are included.
- Functions for maximal network flows, minimal cuts, vertex and
  edge connectivity.
- igraph can read and write many popular file formats used for
  storing graph data: GraphML, Pajek, GML and others.
- igraph contains implementations of many community structure
  detection algorithms proposed recently.

-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Modelling an incomplete Poisson distribution ?

2009-04-18 Thread Ben Bolker
Emmanuel Charpentier charpent at bacbuc.dyndns.org writes:

 
 I forgot to add that yes, I've done my homework, and that it seems to me
 that answers pointing to zero-inflated Poisson (and negative binomial)
 are irrelevant ; I do not have a mixture of distributions but only part
 of one distribution, or, if you'll have it, a zero-deflated Poisson.
 
 An answer by Brian Ripley
 (http://finzi.psych.upenn.edu/R/Rhelp02/archive/11029.html) to a similar
 question leaves me a bit dismayed : if it is easy to compute the
 probability function of this zero-deflated RV (off the top of my head,
 Pr(X=x)=e^-lambda.lambda^x/(x!.(1-e^-lambda))), and if I think that I'm
 (still) able to use optim to ML-estimate lambda, using this to
 (correctly) model my problem set and test it amounts to re-writing some
 (large) part of glm. Furthermore, I'd be a bit embarrassed to test it
 cleanly (i. e. justifiably) : out of the top of my head, only the
 likelihood ration test seems readily applicable to my problem. Testing
 contrasts in my covariates ... hum !
 
 So if someone has written something to that effect, I'd be awfully glad
 to use it. A not-so-cursory look at the existing packages did not ring
 any bells to my (admittedly untrained) ears...
 
 Of course, I could also bootstrap the damn thing and study the
 distribution of my contrasts. I'd still been hard pressed to formally
 test hypotheses on factors...
 

  I would call this a truncated Poisson distribution, related
to hurdle models.  You could probably use the hurdle function
in the pscl package to do this, by ignoring the fitting to
the zero part of the model.  On the other hand, it might break
if there are no zeros at all (adding some zeros would be a
pretty awful hack/workaround).

  If you defined a dtpoisson() for the distribution of the
truncated Poisson model, you could probably also use bbmle
with the formula interface and the parameters argument.

  The likelihood ratio test seems absolutely appropriate for
this case.  Why not?

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tow to perform diallel analysis in R?

2009-04-18 Thread Eli Meyer
I want to use a diallel analysis in R, for some of my own data.  I've been
through the primary literature and textbooks, and remain stumped as to how
to implment this in R.
I can illustrate the problem using a published example dataset: [Cockerham
and Weir (1977) Quadratic Analyses of Reciprocal Crosses. Biometrics, Vol.
33, No. 1 pp. 187-203]

In this study, 8 different individuals were crossed in a diallel design with
reciprocals but without self-crosses.  Two individuals were measured for
each combination of sire and dam.  The goal is to partition the phenotypic
variance based on comparisons among full and half-siblings, and draw
inferences about the additive and dominant components of variation.

The data look like this (complete dataset is at the end of this message)

summary(df)
  val sire dam block Min.   : 9.00 1:14 1:14 1:56 1st Qu.:13.35 2:14 2:14
2:56 Median :15.35 3:14 3:14  Mean   :16.31 4:14 4:14  3rd Qu.:18.05 5:14
5:14  Max.   :31.80 6:14 6:14  (Other):28 (Other):28


The analysis used in that (and other studies) that I want to reproduce in R
identifies general combining ability (GCA, the average performance of a line
in hybrid combinations), and specific combining ability (SCA, cases where
certain hybrid combinations exceed expectations).  The output from this
analysis looks like this:
Df MS Blocks 1 4.32 General 7 175.04 Specific 20 21.2 Reciprocal General
7 53.43 Reciprocal Specific 21 11.66 Error 55 3.62

Specifically, I am interested in using my data to ask what proportion of the
phenotypic variance is additive genetic variance?

The example dataset is pasted below.  I would greatly appreciate any ideas
for how to do this.

-- 
Eli Meyer
Postdoctoral Fellow
Department of Integrative Biology
University of Texas at Austin
Austin, TX 78712
office: (512) 475-6424
cell: (310) 618-4483
--

Cockerham-Weir.tab

val sire dam block 1 14.4 1 2 1 2 16.2 1 2 2 3 27.2 1 3 1 4 30.8 1 3 2 5
17.2 1 4 1 6 27 1 4 2 7 18.3 1 5 1 8 20.2 1 5 2 9 16.2 1 6 1 10 16.8 1 6 2
11 18.6 1 7 1 12 14.4 1 7 2 13 16.4 1 8 1 14 16 1 8 2 15 15.4 2 1 1 16 16.5
2 1 2 17 14.8 2 3 1 18 14.6 2 3 2 19 18.6 2 4 1 20 18.6 2 4 2 21 15.2 2 5 1
22 15.3 2 5 2 23 17 2 6 1 24 15.2 2 6 2 25 14.4 2 7 1 26 14.8 2 7 2 27 10.8
2 8 1 28 13.2 2 8 2 29 31.8 3 1 1 30 30.4 3 1 2 31 21 3 2 1 32 23 3 2 2 33
24.6 3 4 1 34 25.4 3 4 2 35 19.2 3 5 1 36 20 3 5 2 37 29.8 3 6 1 38 28.4 3 6
2 39 12.8 3 7 1 40 14.2 3 7 2 41 13 3 8 1 42 14.4 3 8 2 43 16.2 4 1 1 44
17.8 4 1 2 45 11.4 4 2 1 46 13 4 2 2 47 16.8 4 3 1 48 16.3 4 3 2 49 12.4 4 5
1 50 14.2 4 5 2 51 16.8 4 6 1 52 14.8 4 6 2 53 12.6 4 7 1 54 12.2 4 7 2 55
9.6 4 8 1 56 11.2 4 8 2 57 14.6 5 1 1 58 18.8 5 1 2 59 12.2 5 2 1 60 13.6 5
2 2 61 15.2 5 3 1 62 15.4 5 3 2 63 15.2 5 4 1 64 13.8 5 4 2 65 18 5 6 1 66
16 5 6 2 67 10.4 5 7 1 68 12.2 5 7 2 69 13.4 5 8 1 70 20 5 8 2 71 20.2 6 1 1
72 23.4 6 1 2 73 14.2 6 2 1 74 14 6 2 2 75 18.6 6 3 1 76 14.8 6 3 2 77 22.2
6 4 1 78 17 6 4 2 79 14.3 6 5 1 80 17.3 6 5 2 81 9 6 7 1 82 10.2 6 7 2 83
11.8 6 8 1 84 12.8 6 8 2 85 14 7 1 1 86 16.6 7 1 2 87 12.2 7 2 1 88 9.2 7 2
2 89 13.6 7 3 1 90 16.2 7 3 2 91 13.8 7 4 1 92 14.4 7 4 2 93 15.6 7 5 1 94
15.6 7 5 2 95 15.6 7 6 1 96 11 7 6 2 97 13 7 8 1 98 9.8 7 8 2 99 15.2 8 1 1
100 17.2 8 1 2 101 10 8 2 1 102 11.6 8 2 2 103 17 8 3 1 104 18.2 8 3 2 105
20.8 8 4 1 106 20.8 8 4 2 107 20 8 5 1 108 17.4 8 5 2 109 17 8 6 1 110 12.6
8 6 2 111 13 8 7 1 112 9.8 8 7 2

[[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] nonparametric regression

2009-04-18 Thread A.B
i want just make a program to compute the estimator of nonparametric
 density with Gaussian kernel! i need to compute the function of regression.
any help for this



  
[[alternative HTML version deleted]]

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


Re: [R] get() versus getAnywhere()

2009-04-18 Thread Rolf Turner


On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote:


Benjamin Tyner wrote:

Many thanks Duncan. Perhaps this merits a more explicit note in the
documentation?



The quote I gave is from the documentation.  How could it be more  
explicit?


This is unfortunately typical of the attitude of R-core people toward  
the

documentation.  ``It's clear.'' they say.  ``It's explicit.''  Clear and
explicit once you *know* what it's saying.  Not before, but.

In this case the documentation is quite opaque to me, and I would  
suspect

to a good many like me.  Now that you have made it *genuinely* explicit,
I can understand what the documentation is saying.  Prior to that I  
wouldn't
have had a prayer of guessing that get() would sometimes find things  
that

getAnywhere() would not find.

Moreover, if getAnywhere() does not really mean ``get *anywhere*''  
then its
name is misleading.  Surely it wouldn't be too tough to modify  
getAnywhere()

so that it really got anywhere.  E.g. get it to call get() when it can't
find an object with a given name?

cheers,

Rolf

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2009-04-18 Thread Sunil Suchindran
We can see the plotting options using trellis.par.get(). For example, one
listed parameter is $superpose.line for which we can set col, lty, and lwd.
Load the mlmRev package to obtain the Gcsemv data (used in Lattice book).
One way to set the parameters is

data(Gcsemv, package = mlmRev)

my.fonts  - list(font = 2,cex = 2)

my.theme - list(
superpose.symbol = list(col=c(1,3)),
superpose.line=list(col=c(1,3),lwd=c(1,2)),
par.xlab.text = my.fonts,
par.ylab.text = my.fonts
)

xyplot(written ~ course , data = Gcsemv, groups = gender, type = c(p,r),

   par.settings = my.theme,
   auto.key = list(lines = TRUE, points = FALSE))
On Wed, Apr 15, 2009 at 5:40 AM, Paulo E. Cardoso pecard...@netcabo.ptwrote:

 I'm not being able to control all parameters of a xyplot.

 dataset example:
  tabp[1:10,]
   time  n X id   name
 1 1 95  0.00  1 Coral reef
 2 1 93  0.00  2 Coral reef
 3 1 92  0.00  3 Coral reef
 4 1 90  0.00  4 Coral reef
 5 1 87  8.994321  5 Coral reef
 6 1 86 12.580143  6 Coral reef
 7 1 84 17.004030  7 Coral reef
 8 1 83 18.469500  8 Coral reef
 9 1 82 37.919033  9 Coral reef
 101 81 39.059352 10 Coral reef
 ...

 plot code:
 xyplot(
  X~n,groups=name,data=tabp[tabp$time %in% c(1,4,8),],
  ylab=% of target,
  xlab=PU selection Frequency,
  lty=c(1,3,5), #! not responding
  xlim=c(-10,110),
  scales=list(cex=0.7,at=seq(0,360,by=20),labels=seq(0,360,by=20)), #!
 not responding
  panel=function(x,y,groups,subscripts)
  {
panel.xyplot(x,y,
subscripts=subscripts,
groups=groups,
type=l)
panel.abline(h=30,lty=2,col=grey50)
  },
  key=list(
space=top,
columns=1,
text=list(levels(tabp$name)[c(2,5,11)]),
lines=list(col=c(grey,blue,green))
)
  )

 A few controls are not responding and I don't know how to:
 1) control cex for xlab and ylab
 2) control position of legend
 3) control lty for each group level
 4) control plot groups colors
 5) match legend colors with graph colors
 Any help will be very appreciated.

 
 Paulo E. Cardoso

 __
 R-help@r-project.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] get() versus getAnywhere()

2009-04-18 Thread David Winsemius


I doubt that it will cure all of the R documentation complaints, but  
this R-news article by Ligges answered all on my questions on the  
topic of accessing source (see page 43):


www.r-project.org/doc/Rnews/Rnews_2006-4.pdf

I learned to use methods() and then to use the full function names to  
which calls got dispatched.


--
David Winsemius


On Apr 18, 2009, at 8:47 PM, Rolf Turner wrote:



On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote:


Benjamin Tyner wrote:

Many thanks Duncan. Perhaps this merits a more explicit note in the
documentation?



The quote I gave is from the documentation.  How could it be more  
explicit?


This is unfortunately typical of the attitude of R-core people  
toward the
documentation.  ``It's clear.'' they say.  ``It's explicit.''  Clear  
and

explicit once you *know* what it's saying.  Not before, but.

In this case the documentation is quite opaque to me, and I would  
suspect
to a good many like me.  Now that you have made it *genuinely*  
explicit,
I can understand what the documentation is saying.  Prior to that I  
wouldn't
have had a prayer of guessing that get() would sometimes find things  
that

getAnywhere() would not find.

Moreover, if getAnywhere() does not really mean ``get *anywhere*''  
then its
name is misleading.  Surely it wouldn't be too tough to modify  
getAnywhere()
so that it really got anywhere.  E.g. get it to call get() when it  
can't

find an object with a given name?

cheers,

Rolf

##
Attention:\ This e-mail message is privileged and confid...{{dropped: 
9}}


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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] dynlm question: How to predefine formula for call to dynlm(formula) call

2009-04-18 Thread Ron Burns
I want to set up a model with a formula and then run dynlm(formula) 
because I ultimately want to loop over a set of formulas (see end of post)


R form - gas~price
R dynlm(form)

Time series regression with ts data:
Start = 1959(1), End = 1990(4)
snip

Works OK without a Lag term

R dynlm(gas ~ L(gas,1))

Time series regression with ts data:
Start = 1959(2), End = 1990(4)
snip

Works OK with a Lag with this type of call

R form - gas~L(gas,1)
R dynlm(form)
Error in merge.zoo(gas, L(gas, 1), retclass = list, all = FALSE) :
 could not find function L

Does not work using a predefined formula with a Lag  (This type of call 
works using dyn$lm from library(dyn))


How do I make the call (or how do I setup form) so that this works in dynlm?

Thanks for any help,
   Ron

To be specific the following is an example of what I was attempting to do:
  
m1 - gas ~ L(gas,1)

m2 - gas ~ L(gas,1) + price
m3 - gas ~ L(gas,1) + price + d(gas)
m4 - gas ~ L(gas,1) + price + d(gas) + L(d(gas),1)

M - c(m1,m2,m3,m4)
A - array(0,c(4,2))

for(i in 1:4){
  g - dynlm(M[[i]])   ## works if use dyn$lm from library(dyn) and use 
appropriate m's

  A[i,1] - AIC(g,k=2)
  A[i,2] - AIC(g,k=log(length(fitted(g
}
colnames(A) - c(AIC,BIC)
rownames(A) - c(m1,m2,m3,m4)
A

--

R. R. Burns
Retired in Oceanside, CA

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