[R] : Followup Error in library(gplots) : there is no package called 'gplots' : 64bits

2010-04-20 Thread Martin Valere
Dear James and everybody interested, 

  James'idea was correct : the problem was related to the 64bits version of R. 
Trying on the same computer a 32bits version of R did not produce this 'gplots' 
error (but many other conflicts linked to 64 / 32 bits) when installing RODBC 
package.

I will install a 32 Linux version in parallel ...

Valère



-Ursprüngliche Nachricht-
Von: Martin Valere 
Gesendet: Freitag, 16. April 2010 12:13
An: 'r-help@R-project.org'
Betreff: AW: [SPAM] Re: [R] Error in library(gplots) : there is no
package called 'gplots'


Dear James,

  i have tried to install the package RODBC1-3.1 with R version 2.9.0 and 
2.10.1 (using Opensuse 11.1, 64bits). I have tried install.packages locally 
(package downloaded and stored locally on the computer) or directly from 
Internet (using different mirrors !). Same results each time ...

Same outcome either if I try to install other packages like for instance e1071. 
So it appears this is not linked to the package itself but rather with R-base 
or R-devel (both are installed) ...

Regards,

Valère

-Ursprüngliche Nachricht-
Von: james [mailto:ja...@ipec.co.uk]
Gesendet: Freitag, 16. April 2010 10:47
An: Martin Valere
Cc: R Help List
Betreff: [SPAM] Re: [R] Error in library(gplots) : there is no package
called 'gplots'
Wichtigkeit: Niedrig


Hi Vava,
What version of R are you using? I'm not sure but I think that R will 
refuse to install a package in this way if the version of gplots is 
incompatiable with the version of R you're using. You can check the 
depends of packages on CRAN.

Regards,
James

Vava wrote:
 Thanks for your suggestion Tal. Unfortunately, still no luck with me ...
 still get the usual error message:

  Error in library(gplots) : there is no package called 'gplots' , whatever
 I try to install.

 This is a mystery to me with respect to why /how. I am really stuck with
 that problem.

 Best, 

 Valère
   

 -Ursprüngliche Nachricht-
Von:Martin Valere  
Gesendet:   Donnerstag, 25. März 2010 10:58
An: 'r-help@R-project.org'
Betreff:Error in library(gplots) : there is no package called 'gplots'

Dear all,

   I have an issue trying to install new packages (have tried with RODBC_1.3-1, 
gplots_2.6.1, gtools_2.7.4 packages) and get the same error message :
Error in library(gplots) : there is no package called 'gplots'

Only clue I have found so far on the Web is related to Perl (Perl modules are 
installed on my computer, but which one is related to gplots if any ?); no 
gplots in usr/lib or /usr/lib64 at least ... I am somewhat lost here, having no 
idea about Perl (if Perl is really the issue ?).

I am using OpenSuse 11.1 (64bits); and R version 2.9.0. Installation of package 
 is performed offline as Root.




Valère, Switzerland
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Words appear to be bolded in the PDF output

2010-04-20 Thread chrisli1223

Hi all,

I have written a note near each of my graphs using mtext.
mtext(text,side=1,line=4,cex=0.5,adj=0)

Then I have exported the graphs as a PDF file.
pdf(file=name,paper='a4',width=7.27,height=10.69)

The mtext appears OK in R. But it looks like it is bolded in the PDF file.
http://n4.nabble.com/file/n2016971/graph.png 

I am not sure if this is actually my monitor/computer's problem. But I want
to see if it can be fixed in R.

Many thanks,
Chris

-- 
View this message in context: 
http://n4.nabble.com/Words-appear-to-be-bolded-in-the-PDF-output-tp2016971p2016971.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] Exporting an rgl graph

2010-04-20 Thread Christophe Genolini

Thanks a lot
Both Asymptote and  MeshLab work fine. Thanks for this article, Luke.
On my particular case, I need to export lines (1D object in a 3D space) 
and not surfaces (2D objects). Is it possible to draw lines with misc3d ?


Christophe Genolini

Luke Tierney a écrit :

  The current issue of JCGS (Vol 18 No 1,
http://pubs.amstat.org/toc/jcgs/19/1) has an editorial on including
animations, 3D visualizations, and movies in on-line PDF files
supporting JCGS articles. The online supplements to the editorial
include examples.  The 3D examples related to the misc3d packages are
also available in
http://www.stat.uiowa.edu/~luke/R/misc3d/misc3d-pdf/ 
http://www.stat.uiowa.edu/%7Eluke/R/misc3d/misc3d-pdf/.  At some point

the code there will be added to misc3d.  It should be possible to
adapt these ideas to other objects rendered with rgl.

luke


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


Re: [R] glmer with non integer weights

2010-04-20 Thread Kay Cichini

hello,

it's the Morisita Horn Index, which is an ecological index for similarity
between two multivariate objects (vegetation samples with species and its
abundance) where a value of one indicates completely same relative
importance of species in both samples and 0 denotes total absence of any
same species.

it can be expressed as a probability:

(prob. that an individual drawn from sample j 
and one from sample k belong to the same species)
-   = MH-INdex
(prob. that two ind. drawn from either sample will 
belong to same species)

it is also covered in
library(vegan);?vegdist
here it is its complement: 1-MH, which then is a dissimilarity measure

best regards,
kay

-- 
View this message in context: 
http://n4.nabble.com/glmer-with-non-integer-weights-tp1837179p2017027.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] apropos and find

2010-04-20 Thread Karsten Rincke
Hello,
I'm starting working myself in the use of R, reading M. J. Crawley, The
R Book. The problem I do encounter is concerning the commands apropos
and find:

 apropos(edit)
Fehler: is.character(what) is not TRUE
 find(edit)
Fehler: is.character(what) is not TRUE

I get the same error message typing anything else instead of edit.

The command ?edit seems to work well.

What could be the reason for that I can't use apopos and find?
Thanks for your help!

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


[R] local and global variables

2010-04-20 Thread n.via...@libero.it
Hi all,
I have a question about global and local variables.First of all, a variable 
defined in a for loop is it a local or global variable??
Second, I'm trying to build a loop in the following way:
I have these 3 data frames
bilanci_2005-bilanci1[ANNO==2005,]
bilanci_2006-bilanci1[ANNO==2006,]
bilanci_2007 --bilanci1[ANNO==2007,]

LOOP:
v=list(2005,2006,2007)  
for (a in v){
anno1=a
anno2=a+1
for (i in 1:length(bilanci_a)) {
assign(paste(bilanci,anno1,anno2,sep=), rbind(paste(bilanci,anno1,anno2,
sep=),
  bilanci_anno2[bilanci_anno2$CFISCALE==bilanci_anno1
[i,]$CFISCALE,],
  bilanci_anno1[i,])
}
}
 what I'm trying to do is for example to give the contents of   a (so the 
values which are in the list named v) to the bilanci variable. In Stata this 
means using a particular kind of  .
How can I do this in R?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 select the last non-'NA' observation in a row

2010-04-20 Thread gallon li
I have a matrix of the following form:

time
id0  2  4  6  9 12 14
  3   9  8 NA NA NA NA NA
  7   3 NA  3 NA  3 NA  4
  13 11  6  7 NA  5 NA  6
 .

I hope for each row to select the last observation which is not 'NA'.

For example, for the first row, id=3, the value I want to select is 8
for the second row, id=7, the value I want to select is 4
for the third row, id=13, the value I want to select is 6



if it would be easier for you to demonstrate for me, here I include the code
to generate the above three-row matrix:

a1=c(9,8,rep(NA,5))
a2=c(3,NA,3,NA,3,NA,4)
a3=c(11,6,7,NA,5,NA,6)
matrix=rbind(a1,a2,a3)

[[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] apropos and find

2010-04-20 Thread Christian Raschke
?apropos says that it expects a character string. Therefore use quotes:

 apropos(edit)
 [1] edit  file.edit xedit

Christian


On Tue, 2010-04-20 at 10:24 +0200, Karsten Rincke wrote:
 Hello,
 I'm starting working myself in the use of R, reading M. J. Crawley, The
 R Book. The problem I do encounter is concerning the commands apropos
 and find:
 
  apropos(edit)
 Fehler: is.character(what) is not TRUE
  find(edit)
 Fehler: is.character(what) is not TRUE
 
 I get the same error message typing anything else instead of edit.
 
 The command ?edit seems to work well.
 
 What could be the reason for that I can't use apopos and find?
 Thanks for your help!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] how to select the last non-'NA' observation in a row

2010-04-20 Thread Dimitris Rizopoulos

one way is the following:

a1 - c(9,8,rep(NA,5))
a2 - c(3,NA,3,NA,3,NA,4)
a3 - c(11,6,7,NA,5,NA,6)
M - rbind(a1,a2,a3)

ind - !is.na(M)
tapply(M[ind], row(M)[ind], tail, 1)


I hope it helps.

Best,
Dimitris


On 4/20/2010 10:33 AM, gallon li wrote:

I have a matrix of the following form:

 time
id0  2  4  6  9 12 14
   3   9  8 NA NA NA NA NA
   7   3 NA  3 NA  3 NA  4
   13 11  6  7 NA  5 NA  6
  .

I hope for each row to select the last observation which is not 'NA'.

For example, for the first row, id=3, the value I want to select is 8
for the second row, id=7, the value I want to select is 4
for the third row, id=13, the value I want to select is 6



if it would be easier for you to demonstrate for me, here I include the code
to generate the above three-row matrix:

a1=c(9,8,rep(NA,5))
a2=c(3,NA,3,NA,3,NA,4)
a3=c(11,6,7,NA,5,NA,6)
matrix=rbind(a1,a2,a3)

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


Re: [R] apropos and find

2010-04-20 Thread Gavin Simpson
On Tue, 2010-04-20 at 10:24 +0200, Karsten Rincke wrote:
 Hello,
 I'm starting working myself in the use of R, reading M. J. Crawley, The
 R Book. The problem I do encounter is concerning the commands apropos
 and find:
 
  apropos(edit)
 Fehler: is.character(what) is not TRUE
  find(edit)
 Fehler: is.character(what) is not TRUE
 
 I get the same error message typing anything else instead of edit.

From ?apropos

Usage:

 apropos(what, where = FALSE, ignore.case = TRUE, mode = any)
 
 find(what, mode = any, numeric = FALSE, simple.words = TRUE)
 
Arguments:

what: character string with name of an object, or more generally a
  regular expression to match against.

And edit is not a character string but edit is. Hence the very clear
error.

 The command ?edit seems to work well.

From ??

Usage:

 ?topic
 
 type?topic
 
Arguments:

   topic: Usually, a name or character string specifying the topic for
  which help is sought.

  Alternatively, a function call to ask for documentation on a
  corresponding S4 method: see the section on S4 method
  documentation.  The calls ‘pkg::topic’ and ‘pkg:::topic’ are
  treated specially, and look for help on ‘topic’ in package
  ‘pkg’.

Hence `?` allows a wider range of object types for it's argument topic.

 What could be the reason for that I can't use apopos and find?

You aren't providing a character a string. Not sure where you got the
usage you are using from, but it is wrong. The docs are quite clear
here.

HTH

G

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

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] local and global variables

2010-04-20 Thread Duncan Murdoch

On 20/04/2010 4:27 AM, n.via...@libero.it wrote:

Hi all,
I have a question about global and local variables.First of all, a variable 
defined in a for loop is it a local or global variable??
  


R doesn't create a local scope for for loops.  So it will have the 
same scope as other variables created in the same scope.

Second, I'm trying to build a loop in the following way:
I have these 3 data frames
bilanci_2005-bilanci1[ANNO==2005,]
bilanci_2006-bilanci1[ANNO==2006,]
bilanci_2007 --bilanci1[ANNO==2007,]

LOOP:
v=list(2005,2006,2007)  
  


I would recommend using c(2005,2006, 2007) rather than list(), but I 
don't think that has much effect.

for (a in v){
anno1=a
anno2=a+1
for (i in 1:length(bilanci_a)) {
  


Using the name of one variable as part of another name won't cause it to 
be magically expanded.  You should have set things up differently from 
the beginning:


bilanci_subsets - list(2005 = bilanci1[ANNO==2005,],
2006 = bilanci1[ANNO==2006,],
2007 = bilanci1[ANNO==2007,] )

Then you can use

for (i in names(bilanci_subsets)) {
  bilanci_subsets[[i]] 

Duncan Murdoch

assign(paste(bilanci,anno1,anno2,sep=), rbind(paste(bilanci,anno1,anno2,
sep=),
  bilanci_anno2[bilanci_anno2$CFISCALE==bilanci_anno1
[i,]$CFISCALE,],
  bilanci_anno1[i,])
}
}
 what I'm trying to do is for example to give the contents of   a (so the 
values which are in the list named v) to the bilanci variable. In Stata this 
means using a particular kind of  .

How can I do this in R?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Words appear to be bolded in the PDF output

2010-04-20 Thread Patrick Connolly
On Mon, 19-Apr-2010 at 10:54PM -0800, chrisli1223 wrote:

| 
| Hi all,
| 
| I have written a note near each of my graphs using mtext.
| mtext(text,side=1,line=4,cex=0.5,adj=0)
| 
| Then I have exported the graphs as a PDF file.
| pdf(file=name,paper='a4',width=7.27,height=10.69)

That seems backwards to me.  I'd begin with the pdf() call, then do the
plot, then dev.off().  Maybe that's what you meant: if not, I've no
idea what you did.

| 
| The mtext appears OK in R. But it looks like it is bolded in the PDF file.
| http://n4.nabble.com/file/n2016971/graph.png 

That's a fairly low res png file, not a pdf file, but even so, it
doesn't look like font = 2 to me.  It's a considerably larger cex
value than the other text, but it's still not bold.


| 
| I am not sure if this is actually my monitor/computer's
| problem. But I want to see if it can be fixed in R.

Decide after seeing what it looks like printed.





| 
| Many thanks,
| Chris
| 
| -- 
| View this message in context: 
http://n4.nabble.com/Words-appear-to-be-bolded-in-the-PDF-output-tp2016971p2016971.html
| Sent from the R help mailing list archive at Nabble.com.
| 
|  [[alternative HTML version deleted]]
| 
| __
| R-help@r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
| and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Words appear to be bolded in the PDF output

2010-04-20 Thread baptiste auguie
Hi,

Taking a wild guess, it looks to me that you might have overlaid
several times the same text,

plot.new()
text(0.5,0.5,rep(test,10))

HTH,

baptiste

On 20 April 2010 08:54, chrisli1223 chri...@austwaterenv.com.au wrote:

 Hi all,

 I have written a note near each of my graphs using mtext.
 mtext(text,side=1,line=4,cex=0.5,adj=0)

 Then I have exported the graphs as a PDF file.
 pdf(file=name,paper='a4',width=7.27,height=10.69)

 The mtext appears OK in R. But it looks like it is bolded in the PDF file.
 http://n4.nabble.com/file/n2016971/graph.png

 I am not sure if this is actually my monitor/computer's problem. But I want
 to see if it can be fixed in R.

 Many thanks,
 Chris

 --
 View this message in context: 
 http://n4.nabble.com/Words-appear-to-be-bolded-in-the-PDF-output-tp2016971p2016971.html
 Sent from the R help mailing list archive at Nabble.com.

        [[alternative HTML version deleted]]

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


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


[R] problem with retreaving column from a data.frame

2010-04-20 Thread venkata kirankumar
Hi all,
I have a problem with retreaving column from a data.frame that is

I have a data.frame named  temp
in that dataframe some column  are there whose names are

IDENTIFIERUNIQUEID  TRIALGROUPSID GRPNUMBER
GRPDESC   SEXDIDSTDID STUDYTYPE
SDID  DOSDIDSOPDIDSPECIES

i can retreave any column with using  command like  temp$STDID

but my problem is  the column name i have to get from another xml its
comming like  STDID
that one i assigned to a variable namedkk  like  kk-STDID

but now while i am trying to retreave this column from dataframe  temp
like  temp$kk   or
 with using command paste like

paste(temp,kk,sep$)
both the times its giving null result
but its having values in table

can any one help me how to get column values from dataframe like these cases

thanks in advance
kiran

[[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 set proxy settings for R

2010-04-20 Thread danda

Dear Pete,

Thanks, it works now!

I did as you suggested: 

--internet flag to the target line (right click, properties) e.g.
C:\Program Files\R\R-2.8.1\bin\Rgui.exe --internet2 

Strangely enough, I can now easly download packages but I still get these
messages:

chooseCRANmirror()

Warning message:
In open.connection(con, r) :
  cannot open: HTTP status was '407 Proxy Authentication Required'

 utils:::menuInstallPkgs()
Warning: unable to access index for repository
http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.10

..but eventually it does install what I want...any clue?

Alessandra

-- 
View this message in context: 
http://n4.nabble.com/How-to-set-proxy-settings-for-R-tp2016158p2017172.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to draw multiple vertical bands

2010-04-20 Thread Marsh Feldman

On 04/15/2010 12:36 AM, senne wrote:


  hi R gurus

  I saw some graphs with vertical band like this one:

  http://pragcap.com/wp-content/uploads/2010/04/GS.png

  how to draw the blue band in R, can't find any clue to do this,any ideas?
   


See the source code for nber.xy and nberShade.ggplot in the tis 
package by Jeff Hallman. They both do what you want.


I'm working on something similar. Besides drawing the bands, my version 
will also vary heights optionally (rather than have bands stretching the 
entire height of the graph) and use ggplot2.


Marsh Feldman

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

2010-04-20 Thread rajiv guha
I am trying to estimate a demand function:
Y=K * X1^b1 * X2^b2 * X3 ^(-1-b1)

in log form:
ln Y = ln K + b1 ln X1 + b2 ln X2 + (-1-b1) ln X3

As the regression coefficients are related for 2 of the regressors, I am not
sure of the appropriate methodology or function in R to handle this. Any
hints?

thx,
Tarun

[[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] Effective distance measures for Text Clustering

2010-04-20 Thread Harsh
Hi useRs,
Disclaimer: My question is more statistical than pertaining
specifically to the R system)
I am using the tm package in R to create a Document-Term Matrix,
with Tf-Idf measures.
A) Once done, I create a distance matrix using euclidean distance measure.

B) After this, I use hierarchical clustering to find an appropriate
separation in the data using ward measure

For A above, what are generally the best practices for distance
measures on TfIdf. I used the cosine similarity measure, but that
creates NaN/Inf values which have to be converted to zero.

For B above, I used ward since the Details alluded to it being the
most used measure which provides better results.

I understand that such a question requires extensive research since
the underlying data (emails in my case) may have a great influence on
the results.

I have used a Part of Speech tagger to extract nouns as features to
use as the dictionary in order to weed out trivial words.

Any feedback/link to online knowledge resources/your experience would
be greatly appreciated.

Thank you for your time.

Regards,
Harsh Singhal

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


[R] multiple plots problem

2010-04-20 Thread Kay Cichini

hello,

i try to plot 3 graphs which have the same x.axis underneath each other. i'd
like the plots to be aligned without margings between the boxes and draw a
single x axis beneath the lowest plot.

i managed to get the alignment by setting par(mar), but the middle box is
stretched 
and i cant't figure out how to get around this. par(pin) was my guess, but
this doesn't do the job because it seems to be overridden by par(mar).

sorry for the long example data, but this was quick at hand..

mydata:
###
ad-data.frame(
list(structure(list(pos = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 
2L, 2L), .Label = c(Gaps, Surroundings), class = factor), 
stage = structure(c(4L, 2L, 3L, 1L, 4L, 2L, 3L, 1L), .Label =
c(Alpine_Grassl., 
Early, Late, Pioneer), class = factor), mw = c(12.06293707, 
26.09265735, 37.12287713, 81.53846154, 28.88005449, 68.44004261, 
97.61124961, 100)), .Names = c(pos, stage, mw), class =
data.frame, row.names = c(NA, 
-8L

seedl-data.frame(
list(structure(list(pos = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 
2L, 2L), .Label = c(Gaps, Surroundings), class = factor), 
stage = structure(c(4L, 2L, 3L, 1L, 4L, 2L, 3L, 1L), .Label =
c(Alpine_Grassl., 
Early, Late, Pioneer), class = factor), mw = c(24.52797203, 
17.20571096, 41.68401043, 34.03846154, 13.92056379, 9.955734802, 
23.54039945, 26.11543325)), .Names = c(pos, stage, mw
), class = data.frame, row.names = c(NA, -8L

rich-data.frame(
list(structure(list(pos = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 
2L, 2L), .Label = c(Gaps, Surroundings), class = factor), 
stage = structure(c(4L, 2L, 3L, 1L, 4L, 2L, 3L, 1L), .Label =
c(Alp._Grassl., 
Early, Late, Pioneer), class = factor), n = c(44L, 
44L, 45L, 10L, 44L, 44L, 45L, 10L), mw = c(1.93, 3.59, 4.24, 
6.8, 1.84, 5.61, 7.2, 10.6)), .Names = c(pos, stage, 
n, mw), class = data.frame, row.names = c(NA, -8L
###
windows(5,15)
par(ps=8,mgp=c(2.25,1,0),mfrow=c(3,1))
###
par(mar=c(0,4,4,2))

attach(seedl)
plot(c(1:4),mw[1:4],type=o,xaxt=n,xlab=,
 ylab=Abundance
(%),ylim=c(0,100),xlim=c(0.7,4.3),pch=22,bg=white,cex=0.75,las=1)
par(new=T)
plot(c(1:4),mw[5:8],type=o,xaxt=n,xlab=,yaxt=n,
 ylab=,ylim=c(0,100),xlim=c(0.7,4.3),pch=15,cex=0.75)
text(0.7,90,adj=0,Seedlings,font=2)
legend(topright,c(Surr.,Gaps),bty=n,pch=c(15,0))

###
par(ps=8,mgp=c(2.25,1,0),mar=c(0,4,0,2))

attach(ad)
plot(c(1:4),mw[1:4],type=o,xaxt=n,xlab=,
 ylab=Abundance
(%),ylim=c(0,100),xlim=c(0.7,4.3),pch=22,bg=white,cex=0.75,las=1)
par(new=T)
plot(c(1:4),mw[5:8],type=o,xaxt=n,xlab=,yaxt=n,
 ylab=,ylim=c(0,100),xlim=c(0.7,4.3),pch=15,cex=0.75)

text(0.7,90,adj=0,Adults,font=2)
###
par(ps=8,mgp=c(2.25,1,0),mar=c(4,4,0,2))

attach(rich)
plot(c(1:4),mw[1:4],type=o,xaxt=n,xlab=,
 ylab=Abundance
(%),ylim=c(0,12),xlim=c(0.7,4.3),pch=22,bg=white,cex=0.75,las=1)
par(new=T)
plot(c(1:4),mw[5:8],type=o,xaxt=n,xlab=,yaxt=n,
 ylab=,ylim=c(0,12),xlim=c(0.7,4.3),pch=15,cex=0.75)
axis(1,at=c(1:4),labels=c(rep(,4)))
axis(1,at=c(1:4),line=1.2,lwd=0,adj=0,hadj=0.5,padj=0.5,las=2,
 labels=c(Pioneer,Early,Late,Alpine\nGrassland))
text(0.7,11,adj=0,Richness,font=2)
###
dev.off()
-- 
View this message in context: 
http://n4.nabble.com/multiple-plots-problem-tp2017326p2017326.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to set proxy settings for R

2010-04-20 Thread Pete B

Hi Alessandra

 

Did you restart R? 

 

You should be able to download packages using the Packages Install
Package(s) ... from the menu bar in the GUI.

 

Once the package has been downloaded select Packages Load Package ...
you should see what you just downloaded in a list of available packages

 

Pete

 



From: danda [via R]
[mailto:ml-node+2017172-614719349-63...@n4.nabble.com] 
Sent: Tuesday, April 20, 2010 5:02 AM
To: Brecknock, Peter
Subject: Re: How to set proxy settings for R

 

Dear Pete, 

Thanks, it works now! 

I did as you suggested: 

--internet flag to the target line (right click, properties) e.g.
C:\Program Files\R\R-2.8.1\bin\Rgui.exe --internet2 

Strangely enough, I can now easly download packages but I still get
these messages: 

chooseCRANmirror()

Warning message: 
In open.connection(con, r) : 
  cannot open: HTTP status was '407 Proxy Authentication Required' 

 utils:::menuInstallPkgs()
Warning: unable to access index for repository
http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.10

..but eventually it does install what I want...any clue? 

Alessandra 





View message @
http://n4.nabble.com/How-to-set-proxy-settings-for-R-tp2016158p2017172.h
tml 
To unsubscribe from Re: How to set proxy settings for R, click here
 (link removed) 
ub2NrQGJwLmNvbXwyMDE2NTExfC0xNDg0OTk1MTQx . 

 


-- 
View this message in context: 
http://n4.nabble.com/How-to-set-proxy-settings-for-R-tp2016158p2017327.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] multiple variables pointing to single dataframe?

2010-04-20 Thread Alex Bryant
That's great, that will work perfectly..

Thanks All!

-Alex

-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: Monday, April 19, 2010 10:34 AM
To: Alex Bryant
Cc: r-help@r-project.org
Subject: Re: [R] multiple variables pointing to single dataframe?

If you only need to retrieve x by referring to x2 and you don`t have
to modify x via x2 then this works:

 x - Orange
 makeActiveBinding(x2, function() x, .GlobalEnv)
 x$age - 50
 head(x2)
  Tree age circumference
11  5030
21  5058
31  5087
41  50   115
51  50   120
61  50   142


On Mon, Apr 19, 2010 at 10:15 AM, Alex Bryant abry...@i-review.com wrote:
 Hi, for example:

 x - Orange
 x2 - x
 x[1,]$age - 50
 x2[1,]
  Tree age circumference
 1    1 118            30

 I would like a way for x2 to also reference the modified x data frame without 
 having to reassign x2x each time x is modified.

 Thanks,
 Alex

 -Original Message-
 From: Petr PIKAL [mailto:petr.pi...@precheza.cz]
 Sent: Monday, April 19, 2010 3:18 AM
 To: Alex Bryant
 Cc: r-help@r-project.org
 Subject: Odp: [R] multiple variables pointing to single dataframe?

 Hi

 r-help-boun...@r-project.org napsal dne 16.04.2010 16:15:40:

 Hi,  I have a need to have 2 variables point to the same dataframe (d1),
  I

 What does it mean to point to data frame? Seems to me that it is something
 from C+.

 You can reference data frame by $ or by square brackets with as many
 variables as you want.

 see

 ?[

 regards
 Petr


 don't want to simply copy the dataframe ( d2-d1 ) as my understanding
 is that
 this will create a second dataframe.  Any suggestions on best practice
 here?

 Thank You,

 //
 // Alex Bryant
 // Software Developer
 // Integrated Clinical Systems, Inc.
 // 908-996-7208


 
 Confidentiality Note: This e-mail, and any attachment
 to...{{dropped:13}}

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

2010-04-20 Thread Petr PIKAL
Hi

you can also use abline function

x-rnorm(10)
plot(1:10, x)
abline(v=seq(2,10,2), lwd=50, col=lightblue)
lines(1:10, x, type=b)

Regards
Petr

r-help-boun...@r-project.org napsal dne 19.04.2010 20:59:15:

 On 04/15/2010 12:36 AM, senne wrote:
 
hi R gurus
  
I saw some graphs with vertical band like this one:
  
http://pragcap.com/wp-content/uploads/2010/04/GS.png
  
how to draw the blue band in R, can't find any clue to do this,any 
ideas?
  
 
 See the source code for nber.xy and nberShade.ggplot in the tis 
 package by Jeff Hallman. They both do what you want.
 
 I'm working on something similar. Besides drawing the bands, my version 
 will also vary heights optionally (rather than have bands stretching the 

 entire height of the graph) and use ggplot2.
 
  Marsh Feldman
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] log-linear regression question

2010-04-20 Thread Sayantani Basu Roy
open up the brackets (-1-b1) and you would get an equation in which you
would have to estimate only b1 and b2...
then you can proceed by the normal method..

On Tue, Apr 20, 2010 at 4:44 PM, rajiv guha dabr...@gmail.com wrote:

 I am trying to estimate a demand function:
 Y=K * X1^b1 * X2^b2 * X3 ^(-1-b1)

 in log form:
 ln Y = ln K + b1 ln X1 + b2 ln X2 + (-1-b1) ln X3

 As the regression coefficients are related for 2 of the regressors, I am
 not
 sure of the appropriate methodology or function in R to handle this. Any
 hints?

 thx,
 Tarun

[[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] Help: coxph() in {survival} package

2010-04-20 Thread Terry Therneau
The best answer to your question is
  help(coxph.object)

This is a manual page describing the contents of a coxph fit.

Terry Therneau

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 retreaving column from a data.frame

2010-04-20 Thread Thomas Stewart
Maybe you want something like this.

temp-data.frame(id=rbinom(10,5,.5),grp=rbinom(10,3,.3),stdid=rnorm(10))
kk-stdid
temp[,kk]

-tgs


On Tue, Apr 20, 2010 at 7:32 AM, venkata kirankumar
kiran4u2...@gmail.comwrote:

 Hi all,
 I have a problem with retreaving column from a data.frame that is

 I have a data.frame named  temp
 in that dataframe some column  are there whose names are

 IDENTIFIERUNIQUEID  TRIALGROUPSID GRPNUMBER
 GRPDESC   SEXDIDSTDID STUDYTYPE
 SDID  DOSDIDSOPDIDSPECIES

 i can retreave any column with using  command like  temp$STDID

 but my problem is  the column name i have to get from another xml its
 comming like  STDID
 that one i assigned to a variable namedkk  like  kk-STDID

 but now while i am trying to retreave this column from dataframe  temp
 like  temp$kk   or
  with using command paste like

 paste(temp,kk,sep$)
 both the times its giving null result
 but its having values in table

 can any one help me how to get column values from dataframe like these
 cases

 thanks in advance
 kiran

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


[R] the bar width of barchart plot in lattice package

2010-04-20 Thread zhenjiang xu
Dear R users,

I am trying to use the following code to make a barchar plot. The bars in
the plot turn out to be a little narrow. Is there any way to modify the
width of the bars? Thank you!

library(lattice)
scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100)
sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A',
'Gymnosporangium sabinae', 'Hymeniacidon sanguinea', 'Streptomyces
griseus'), length = 100)
levels = gl(10, 10, label = c('Cycle 1', 'Cycle 2', 'Cycle 3', 'Cycle 4',
'Order 1', 'Order 2', 'Order 3', 'MaxPairs = 20', 'MaxPairs = Average
Length', 'MaxPairs = 500'))
factors = c(rep('Cycles', 40), rep('Order', 30), rep('MaxPairs', 30))
values = rnorm(100) # this is toy data
a = data.frame(values, scores, sequences, levels, factors)
bc.factors =
  barchart(values ~ sequences | scores * factors , data = a,
   groups = levels,
   layout = c(2,3),
   between = list(y=0.5),
   clip = list(strip = 'off'),
   par.strip.text = list(cex=0.7),
   par.settings = list(fontsize=list(text=8)),
   auto.key = list(rectangles = TRUE, space = 'right', columns = 1),
   draw.key = TRUE,
   scales = list(x = list(rot = 45)))

-- 
Best,
Zhenjiang

[[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] multiple plots problem

2010-04-20 Thread Thomas Stewart
The stretching of plot two occurs because you are allotting more space for
plot two.

You set
Plot 1: mar=c(0,4,4,2)
Plot 2: mar=c(0,4,0,2)
Plot 3: mar=c(4,4,0,2)

In plot one your are dedicating 4 lines to the top margin, in plot three you
are dedicating 4 lines to the bottom margin.  In plot two, you are not
dedicating any lines to either the top or bottom margin.  It follows that
plot 2 is 4 lines taller than the other plots.  The cheapest solution is:

Before the plots: par(oma=c(4,0,4,0))
Plot 1: mar=c(0,4,0,2)
Plot 2: mar=c(0,4,0,2)
Plot 3: mar=c(0,4,0,2)

-tgs

On Tue, Apr 20, 2010 at 8:58 AM, Kay Cichini kay.cich...@uibk.ac.at wrote:


 hello,

 i try to plot 3 graphs which have the same x.axis underneath each other.
 i'd
 like the plots to be aligned without margings between the boxes and draw a
 single x axis beneath the lowest plot.

 i managed to get the alignment by setting par(mar), but the middle box is
 stretched
 and i cant't figure out how to get around this. par(pin) was my guess, but
 this doesn't do the job because it seems to be overridden by par(mar).

 sorry for the long example data, but this was quick at hand..

 mydata:
 ###
 ad-data.frame(
 list(structure(list(pos = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
 2L, 2L), .Label = c(Gaps, Surroundings), class = factor),
stage = structure(c(4L, 2L, 3L, 1L, 4L, 2L, 3L, 1L), .Label =
 c(Alpine_Grassl.,
Early, Late, Pioneer), class = factor), mw = c(12.06293707,
26.09265735, 37.12287713, 81.53846154, 28.88005449, 68.44004261,
97.61124961, 100)), .Names = c(pos, stage, mw), class =
 data.frame, row.names = c(NA,
 -8L

 seedl-data.frame(
 list(structure(list(pos = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
 2L, 2L), .Label = c(Gaps, Surroundings), class = factor),
stage = structure(c(4L, 2L, 3L, 1L, 4L, 2L, 3L, 1L), .Label =
 c(Alpine_Grassl.,
Early, Late, Pioneer), class = factor), mw = c(24.52797203,
17.20571096, 41.68401043, 34.03846154, 13.92056379, 9.955734802,
23.54039945, 26.11543325)), .Names = c(pos, stage, mw
 ), class = data.frame, row.names = c(NA, -8L

 rich-data.frame(
 list(structure(list(pos = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
 2L, 2L), .Label = c(Gaps, Surroundings), class = factor),
stage = structure(c(4L, 2L, 3L, 1L, 4L, 2L, 3L, 1L), .Label =
 c(Alp._Grassl.,
Early, Late, Pioneer), class = factor), n = c(44L,
44L, 45L, 10L, 44L, 44L, 45L, 10L), mw = c(1.93, 3.59, 4.24,
6.8, 1.84, 5.61, 7.2, 10.6)), .Names = c(pos, stage,
 n, mw), class = data.frame, row.names = c(NA, -8L
 ###
 windows(5,15)
 par(ps=8,mgp=c(2.25,1,0),mfrow=c(3,1))
 ###
 par(mar=c(0,4,4,2))

 attach(seedl)
 plot(c(1:4),mw[1:4],type=o,xaxt=n,xlab=,
 ylab=Abundance
 (%),ylim=c(0,100),xlim=c(0.7,4.3),pch=22,bg=white,cex=0.75,las=1)
 par(new=T)
 plot(c(1:4),mw[5:8],type=o,xaxt=n,xlab=,yaxt=n,
 ylab=,ylim=c(0,100),xlim=c(0.7,4.3),pch=15,cex=0.75)
 text(0.7,90,adj=0,Seedlings,font=2)
 legend(topright,c(Surr.,Gaps),bty=n,pch=c(15,0))

 ###
 par(ps=8,mgp=c(2.25,1,0),mar=c(0,4,0,2))

 attach(ad)
 plot(c(1:4),mw[1:4],type=o,xaxt=n,xlab=,
 ylab=Abundance
 (%),ylim=c(0,100),xlim=c(0.7,4.3),pch=22,bg=white,cex=0.75,las=1)
 par(new=T)
 plot(c(1:4),mw[5:8],type=o,xaxt=n,xlab=,yaxt=n,
 ylab=,ylim=c(0,100),xlim=c(0.7,4.3),pch=15,cex=0.75)

 text(0.7,90,adj=0,Adults,font=2)
 ###
 par(ps=8,mgp=c(2.25,1,0),mar=c(4,4,0,2))

 attach(rich)
 plot(c(1:4),mw[1:4],type=o,xaxt=n,xlab=,
 ylab=Abundance
 (%),ylim=c(0,12),xlim=c(0.7,4.3),pch=22,bg=white,cex=0.75,las=1)
 par(new=T)
 plot(c(1:4),mw[5:8],type=o,xaxt=n,xlab=,yaxt=n,
 ylab=,ylim=c(0,12),xlim=c(0.7,4.3),pch=15,cex=0.75)
 axis(1,at=c(1:4),labels=c(rep(,4)))
 axis(1,at=c(1:4),line=1.2,lwd=0,adj=0,hadj=0.5,padj=0.5,las=2,
 labels=c(Pioneer,Early,Late,Alpine\nGrassland))
 text(0.7,11,adj=0,Richness,font=2)
 ###
 dev.off()
 --
 View this message in context:
 http://n4.nabble.com/multiple-plots-problem-tp2017326p2017326.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] problem with retreaving column from a data.frame

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 7:32 AM, venkata kirankumar wrote:


Hi all,
I have a problem with retreaving column from a data.frame that is

I have a data.frame named  temp
in that dataframe some column  are there whose names are

IDENTIFIERUNIQUEID  TRIALGROUPSID GRPNUMBER
GRPDESC   SEXDIDSTDID STUDYTYPE
SDID  DOSDIDSOPDIDSPECIES

i can retreave any column with using  command like  temp$STDID

but my problem is  the column name i have to get from another xml its
comming like  STDID
that one i assigned to a variable namedkk  like  kk-STDID

but now while i am trying to retreave this column from dataframe  temp
like  temp$kk   or
with using command paste like

paste(temp,kk,sep$)
both the times its giving null result
but its having values in table


Don't use the $ operator for such tasks. Instead use the indexing  
operator [:


temp[ , kk]


 testdf - data.frame(aa=letters[1:10], bb=LETTERS[1:10], cc=1:10)
 colname - aa
 testdf[ , colname]
 [1] a b c d e f g h i j
Levels: a b c d e f g h i j

-- David.


can any one help me how to get column values from dataframe like  
these cases


thanks in advance
kiran

[[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] log-linear regression question

2010-04-20 Thread Thomas Stewart
I think you'll need the offset option.

ln( Y ) = ln( K ) + b1 ln( X1 ) + b2 ln( X2 / X3 ) + 1 ln( 1 / X3 )

as in:

glm( log(Y) ~ log( X1 ) + I(log( X2 / X3 )),
 offset=I(log( 1 / X3 )))

-tgs

On Tue, Apr 20, 2010 at 7:14 AM, rajiv guha dabr...@gmail.com wrote:

 I am trying to estimate a demand function:
 Y=K * X1^b1 * X2^b2 * X3 ^(-1-b1)

 in log form:
 ln Y = ln K + b1 ln X1 + b2 ln X2 + (-1-b1) ln X3

 As the regression coefficients are related for 2 of the regressors, I am
 not
 sure of the appropriate methodology or function in R to handle this. Any
 hints?

 thx,
 Tarun

[[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] the bar width of barchart plot in lattice package

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 9:46 AM, zhenjiang xu wrote:


Dear R users,

I am trying to use the following code to make a barchar plot. The  
bars in
the plot turn out to be a little narrow. Is there any way to modify  
the

width of the bars? Thank you!

library(lattice)
scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100)
sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A',
'Gymnosporangium sabinae', 'Hymeniacidon sanguinea', 'Streptomyces
griseus'), length = 100)
levels = gl(10, 10, label = c('Cycle 1', 'Cycle 2', 'Cycle 3',  
'Cycle 4',

'Order 1', 'Order 2', 'Order 3', 'MaxPairs = 20', 'MaxPairs = Average
Length', 'MaxPairs = 500'))
factors = c(rep('Cycles', 40), rep('Order', 30), rep('MaxPairs', 30))
values = rnorm(100) # this is toy data
a = data.frame(values, scores, sequences, levels, factors)
bc.factors =
 barchart(values ~ sequences | scores * factors , data = a,
  groups = levels,
  layout = c(2,3),
  between = list(y=0.5),
  clip = list(strip = 'off'),
  par.strip.text = list(cex=0.7),
  par.settings = list(fontsize=list(text=8)),
  auto.key = list(rectangles = TRUE, space = 'right',  
columns = 1),

  draw.key = TRUE,
  scales = list(x = list(rot = 45)))



?barchart

Looking at the arguments to barchart in the help page I would have  
guessed that box.ratio would do what you want. Since that is clearly  
not reproducible code , (in the absence of test dataset of the  
appropriate structure) I suppose guessing will remain the level of my  
knowledge in this instance.




--
Best,
Zhenjiang


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] Drawing a line with misc3d

2010-04-20 Thread luke

misc3d only knows about triangular mesh scenes. For our JSS paper we
added pointsTetrahedra that represents data points as small terahedra.
You could do something analogous by creating a triangular mesh
representation of a long thin bar for your lines.

luke

On Mon, 19 Apr 2010, Christophe Genolini wrote:


Hi the list,

I would like to draw some lines with misc3d. I find a lot of tools to draw 
surfaces, but nothing for simple line... Is it possible?
Note that I know that it is possible to draw lines with rgl (using lines3d), 
but I need to do it with misc3d to export the drawing in .asy format.

Any solution?

Christophe

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



--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:  l...@stat.uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


Re: [R] Exporting an rgl graph

2010-04-20 Thread luke

On Fri, 16 Apr 2010, Michael Friendly wrote:


l...@stat.uiowa.edu wrote:

The current issue of JCGS (Vol 18 No 1,
http://pubs.amstat.org/toc/jcgs/19/1) has an editorial on including
animations, 3D visualizations, and movies in on-line PDF files
supporting JCGS articles. The online supplements to the editorial
include examples.  The 3D examples related to the misc3d packages are
also available in
http://www.stat.uiowa.edu/~luke/R/misc3d/misc3d-pdf/.  At some point
the code there will be added to misc3d.  It should be possible to
adapt these ideas to other objects rendered with rgl.

luke


Luke,
Your misc3d-pdf example is very instructive and the .tex file shows how
to embed in LaTeX.  Thanks! (JCGS 19(1) is actually one of the nicest
issues in a long time.)
Of the two approaches you
describe, the Asymptote route seems easier and more capable than the
MeshLab one.


The Asymptote/PRC route was the only one I could find (with a limited
amoutn of time and effort I could put in) that would support both
color and transparency.  The downside is that PRC suport requires very
new Adobe readers and seems to result in huge files. I know the U3D
format support color but MeshLab doesn't seem to put color into its
U3D exports.  I forget whether U3D supports transparency. Someone with
the energy and motivation to do so can read the binary file format
specs and write these file formats directly usign alltheir
cababilities, but I wasn't up to doing that at the time.

It would be particularly useful to have this capability available for rgl. 
Any plans for this?


Not on my part.  misc3d scenes are very simple -- just triangular mesh
objects with optional color or transparency. rgl handles much richer
scenes so figuring out how to translate such scenes to one of the
binary formats would be a lot more work. On the other hand it may
already have been done in the OpenGL community.



One note:  With Adobe Acrobat Pro 9.3.1, the U3D and PRC images display
on screen, but do not print (replaced by the filename).  Is this your
experience too?


I believe so.  There may well be a way of including a static image in
the LaTeX that would be used by printing and readers that don't
understand the embedded formats, but I haven't had the chance to check
the movie15 documentation for that.

luke



-Michael





--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:  l...@stat.uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


[R] QCA3 segfault

2010-04-20 Thread ded0rg

Hi

I have just dwonloaded QCA3 onto this machine (ubuntu, karmic, amd64) and a
mac.  The examples run fine on teh mac, but crashed R on ubuntu.  Any help
much apprecia\ted.

Thanks

Richard

--
Terminal log:

conditions -
 c(Developed.FZ,Urban.FZ,Literate.FZ,Industrial.FZ, Stable.FZ)
 
 reduce(mydata=Lipset_fs,Survived.FZ,conditions,explain=positive,remaind=exclude,prepro=fs,consistency=0.7)

 *** caught segfault ***
address 0x4, cause 'memory not mapped'

Traceback:
 1: .C(lpslink, direction = as.integer(direction), x.count =
as.integer(x.count), objective = as.double(objective), const.count =
as.integer(const.count), constraints = as.double(constraints), int.count
= as.integer(int.count), int.vec = as.integer(int.vec), bin.count =
as.integer(bin.count), binary.vec = as.integer(binary.vec),
num.bin.solns = as.integer(num.bin.solns), objval = as.double(objval),
solution = as.double(solution), presolve = as.integer(presolve),
compute.sens = as.integer(compute.sens), sens.coef.from =
as.double(sens.coef.from), sens.coef.to = as.double(sens.coef.to), duals
= as.double(duals), duals.from = as.double(duals.from), duals.to =
as.double(duals.to), scale = as.integer(scale), use.dense =
as.integer(use.dense), dense.col = as.integer(dense.col), dense.val =
as.double(dense.val), dense.const.nrow = as.integer(dense.const.nrow),
dense.ctr = as.integer(dense.ctr), use.rw = as.integer(use.rw), tmp =
as.character(tmp), status = as.integer(status), PACKAGE = lpSolve)

  
 2: lpSolve:::lp(direction = min, objective.in = rep(1, nrow(PIChart)),
const.mat = t(PIChart), const.dir = =, 1, all.bin = TRUE)
 3: solvePIChart(PIChart)
 4: reduce.default(mydata = Lipset_fs, Survived.FZ, conditions,
explain = positive, remaind = exclude, prepro = fs, consistency =
0.7)
 5: reduce(mydata = Lipset_fs, Survived.FZ, conditions, explain =
positive, remaind = exclude, prepro = fs, consistency = 0.7)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

--
 Sys.getlocale()
[1]
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C



-- 
View this message in context: 
http://n4.nabble.com/QCA3-segfault-tp2017493p2017493.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] Exporting an rgl graph

2010-04-20 Thread Duncan Murdoch

On 20/04/2010 10:43 AM, l...@stat.uiowa.edu wrote:

On Fri, 16 Apr 2010, Michael Friendly wrote:

 l...@stat.uiowa.edu wrote:
 The current issue of JCGS (Vol 18 No 1,
 http://pubs.amstat.org/toc/jcgs/19/1) has an editorial on including
 animations, 3D visualizations, and movies in on-line PDF files
 supporting JCGS articles. The online supplements to the editorial
 include examples.  The 3D examples related to the misc3d packages are
 also available in
 http://www.stat.uiowa.edu/~luke/R/misc3d/misc3d-pdf/.  At some point
 the code there will be added to misc3d.  It should be possible to
 adapt these ideas to other objects rendered with rgl.
 
 luke


 Luke,
 Your misc3d-pdf example is very instructive and the .tex file shows how
 to embed in LaTeX.  Thanks! (JCGS 19(1) is actually one of the nicest
 issues in a long time.)
 Of the two approaches you
 describe, the Asymptote route seems easier and more capable than the
 MeshLab one.

The Asymptote/PRC route was the only one I could find (with a limited
amoutn of time and effort I could put in) that would support both
color and transparency.  The downside is that PRC suport requires very
new Adobe readers and seems to result in huge files. I know the U3D
format support color but MeshLab doesn't seem to put color into its
U3D exports.  I forget whether U3D supports transparency. Someone with
the energy and motivation to do so can read the binary file format
specs and write these file formats directly usign alltheir
cababilities, but I wasn't up to doing that at the time.

 It would be particularly useful to have this capability available for rgl. 
 Any plans for this?


Not on my part.  misc3d scenes are very simple -- just triangular mesh
objects with optional color or transparency. rgl handles much richer
scenes so figuring out how to translate such scenes to one of the
binary formats would be a lot more work. On the other hand it may
already have been done in the OpenGL community.
  


It's on my wish list, but I'm spending too much time fighting to get my 
email working to actually work on anything.


The way the rgl.postcript conversion works (using the gl2ps library) is 
to redirect OpenGL calls into calls to generate Postscript.  Working at 
this level seems like the right approach, but I don't know if anyone has 
done it for these newer formats.


Duncan


 One note:  With Adobe Acrobat Pro 9.3.1, the U3D and PRC images display
 on screen, but do not print (replaced by the filename).  Is this your
 experience too?

I believe so.  There may well be a way of including a static image in
the LaTeX that would be used by printing and readers that don't
understand the embedded formats, but I haven't had the chance to check
the movie15 documentation for that.

luke


 -Michael







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


Re: [R] multiple plots problem

2010-04-20 Thread Kay Cichini

hi thomas,

thanks a lot- of course that's it.
i knew why the middle plot is stretcht, but didn't figure out that settting
par(oma) is the key..

greetings,
kay  
-- 
View this message in context: 
http://n4.nabble.com/multiple-plots-problem-tp2017326p2017551.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] label the bars by the percentage values in the conditional histogram?

2010-04-20 Thread Changbin Du
HI, Dear R Community,

Does anyone know how to label the values in the conditional histogram?
Thanks so much!!!

h- sample(1:14, 319, rep=T)
c- sample(1:14, 608, rep=T)
n- sample(1:14, 1140, rep=T)
vt-c(h, c, n)
ta-rep(c(h, c, n), c(319, 608, 1140))

to-data.frame(vt,ta)

library(lattice)
histogram(~ vt|ta, data=to, layout=c(1,3), labels=TRUE, main=Histograms by
target, col=skyblue)



-- 
Sincerely,
Changbin
--

[[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] stupid regexp question

2010-04-20 Thread servet ahmet çizmeli
Both methods solve my problem. Thanks a lot to Gabor and David!

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


Re: [R] Weights in binomial glm

2010-04-20 Thread Jan van der Laan
Thomas, Thierry,

Thank your for your answers and my appogies for my late reply. Thomas,
from your reply it seems that dividing the weights by their average
would also make finding a suitable starting value more robust. This
indeed seems to be case from test I've ran.

However, your comments about me misusing glm() make me wonder at how
the weights are used in glm(). I was under the impression that weights
in glm are usually replicae/frequency weights. When I look at how
weights are usually taken into account in the likelihood, namely

L = Product_i L_i^w_i

each record i contributes w_i times a factor L_i to the total
likelihood, which  is the same as saying that record i represents w_i
observations. This is exactly what I want to express with my weights.
Writing out the likelihood for binomial regression also shows that in
that case it is possible to have Y's that are not only 0 or 1, but can
also have values between 0 and 1 as in R. However, looking at this I
do not see any problems with large weights and Y's equal to 0 or one.

Is it just the fact that R has problems generating the starting values
when the Y's are all between 0 and 1, or are there also some other
reasons for this?

Regards,
Jan





On Fri, Apr 16, 2010 at 6:28 PM, Thomas Lumley tlum...@u.washington.edu wrote:


 Jan,

 Thierry is correct in saying that you are misusing glm(), but there is also
 a numerical problem.

 You are misusing glm() because your model specification claims to have
 Binomial(n,p) observations with w in the vicinity of 100, where there is a
 single common p but the observed binomial proportion is either 1 or 0, never
 anything in between.  These data are a very poor fit to a binomial model.

 The correct specification if you have what you call replicate weights and I
 call frequency weights is to produce a single data record for each covariate
 pattern that has both the 1 and 0 observations. This can either be two
 columns for successes and failures, or one column of proportions and one
 column of weights.  As your quote from MASS says weights are used to give
 the number of trials when the response is the proportion of successes. In
 your data the response is *not* the proportion of successes.


 However, the MLE should still be equal to the weighted mean even with this
 misuse.  The reason it is not is because of the starting values.  R has to
 find some starting values for the iterative maximization of the likelihood,
 and for binomial data with y successes out of n it uses  starting values for
 the fitted means of  (y+0.5)/(n+1).  Starting the iteration at the data in
 this way usually makes the Fisher scoring algorithm very reliable -- it is
 correctly scaled to the data, in some sense.   Unfortunately, if you
 separate out the successes and failures, you have some points starting with
 values very close to 0.  When I used your code the starting value for the
 point with the largest weight was 0.5/199.   At iteration 2, the estimated
 mean ends up very small for all observations, and then the iteration
 diverges.  However, if you provide a starting value then the fitting works,
 even if you start the iteration at, say beta=1, corresponding to a fitted
 mean of over 70%.

 So, the result is wrong in the sense that it is not the mle, because of a
 failure of convergence, which happens because specifying the weights the way
 you did rather than the documented way leads to bad default starting values
 for the iteration.  You need either to specify the data as recommended or
 supply starting values.

    =thomas


 On Fri, 16 Apr 2010, Jan van der Laan wrote:

 I have some questions about the use of weights in binomial glm as I am
 not getting the results I would expect. In my case the weights I have
 can be seen as 'replicate weights'; one respondent i in my dataset
 corresponds to w[i] persons in the population. From the documentation
 of the glm method, I understand that the weights can indeed be used
 for this: For a binomial GLM prior weights are used to give the
 number of trials when the response is the proportion of successes.

 From Modern applied statistics with S-Plus 3rd ed. I understand the

 same.

 However, I am getting some strange results. I generated an example:

 Generate some data which is simular to my dataset

 Z - rbinom(1000, 1, 0.1)
 W - round(rnorm(1000, 100, 40))
 W[W  1] - 1

 Probability of success can either be estimated using:

 sum(Z*W)/sum(W)

 [1] 0.09642109

 Or using glm:

 model - glm(Z ~ 1, weights=W, family=binomial())

 Warning message:
 In glm.fit(x = X, y = Y, weights = weights, start = start, etastart =
 etastart,  :
  fitted probabilities numerically 0 or 1 occurred

 predict(model, type=response)[1]

          1
 2.220446e-16

 These two results are obviously not the same. The strange thing is
 that when I scale the weights, such that the total equals one, the
 probability is correctly estimated:

 model - glm(Z ~ 1, weights=W/sum(W), family=binomial())

 Warning 

[R] [R-pkgs] cudaBayesreg update

2010-04-20 Thread Adelino
Dear all,

Package cudaBayesreg, version 0.3-3, is now online.
Apart some minor corrections, the package now includes a brief report of 
the tests used to assess the quality of the random number generator.

Best regards,

Adelino Ferreira da Silva

http://cran.at.r-project.org/src/contrib/cudaBayesreg_0.3-3.tar.gz

[[alternative HTML version deleted]]

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


[R] lattice visualization - superpose multiple columns over another (fixed) column

2010-04-20 Thread Rajarshi Guha
Hi, I've been struggling with a lattice visualiation. I have a
data.frame with 4 columns. What I'd like to have is a set of 3 panels.
Ecah panel will have the first column plotted against serial number
and then will superimpose the relevant column. My non-lattice version
is as follows:

x - data.frame( ... )
par(mfrow=c(3,1))
for (i in 2:4) {
 plot(x[,1])
 points(x[,i])
}

Any suggestions as to how I could convert this to a lattice version
would be much appreciated

Thanks,

-- 
Rajarshi Guha
NIH Chemical Genomics Center

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Visualize a fitted line in a log plot of a power law distribution

2010-04-20 Thread Narges Zarabi
Hi,

I am trying to fit a line in the log plot of my networks degree distribution
to show that it is a power-law distribution. I am using the following
commands. However, I am not able to see the fitted line. Any comments to
help?
I am using following packages: igraph, splines,base,VGAM, netmodels.
g is my network, d is the degree of nodes in the network, and dd is the
degree distribution

d -degree(g)
dd - degree.distribution(g)
fitpower.law.fit(d,20)
plot(d,log=xy)
abline(fit)

Thanks in advance.
Regards, *Narcissus*

[[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] sum() returns 0 not NA

2010-04-20 Thread will . eagle
Dear all,

just a stupid R question, since the results puzzle me a bit:

 sum(c(NA,NA), na.rm=TRUE)
[1] 0
  NA + NA   
[1] NA
 NA + 1
[1] NA
 

Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?

Thanks in advance,

Will

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fit a line to power law distribution

2010-04-20 Thread Narges Zarabi
Hi,

I am trying to fit a line in the log plot of my networks degree distribution
to show that it is a power-law distribution. I am using the following
commands. However, I am not able to see the fitted line. Any comments to
help?
I am using following packages: igraph, splines,base,VGAM, netmodels.
g is my network, d is the degree of nodes in the network, and dd is the
degree distribution

d -degree(g)
dd - degree.distribution(g)
fitpower.law.fit(d,20)
plot(dd,log=xy)
abline(fit)

Thanks in advance.
Regards, *Narcissus*

[[alternative HTML version deleted]]

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


Re: [R] sum() returns 0 not NA

2010-04-20 Thread Gabor Grothendieck
So that the two lines below give the same answer:

xx - c(); yy - 1:3

sum(xx) + sum(yy)
sum(c(xx, yy))


On Tue, Apr 20, 2010 at 12:42 PM,  will.ea...@gmx.net wrote:
 Dear all,

 just a stupid R question, since the results puzzle me a bit:

 sum(c(NA,NA), na.rm=TRUE)
 [1] 0
  NA + NA
 [1] NA
 NA + 1
 [1] NA


 Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?

 Thanks in advance,

 Will

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

2010-04-20 Thread R Gott

this should have gone to the package manager
apologies to all

rg

ded0rg wrote:

Hi

I have just dwonloaded QCA3 onto this machine (ubuntu, karmic, amd64) and a
mac.  The examples run fine on teh mac, but crashed R on ubuntu.  Any help
much apprecia\ted.

Thanks

Richard

--
Terminal log:

  

   conditions -
c(Developed.FZ,Urban.FZ,Literate.FZ,Industrial.FZ, Stable.FZ)

reduce(mydata=Lipset_fs,Survived.FZ,conditions,explain=positive,remaind=exclude,prepro=fs,consistency=0.7)



 *** caught segfault ***
address 0x4, cause 'memory not mapped'

Traceback:
 1: .C(lpslink, direction = as.integer(direction), x.count =
as.integer(x.count), objective = as.double(objective), const.count =
as.integer(const.count), constraints = as.double(constraints), int.count
= as.integer(int.count), int.vec = as.integer(int.vec), bin.count =
as.integer(bin.count), binary.vec = as.integer(binary.vec),
num.bin.solns = as.integer(num.bin.solns), objval = as.double(objval),
solution = as.double(solution), presolve = as.integer(presolve),
compute.sens = as.integer(compute.sens), sens.coef.from =
as.double(sens.coef.from), sens.coef.to = as.double(sens.coef.to), duals
= as.double(duals), duals.from = as.double(duals.from), duals.to =
as.double(duals.to), scale = as.integer(scale), use.dense =
as.integer(use.dense), dense.col = as.integer(dense.col), dense.val =
as.double(dense.val), dense.const.nrow = as.integer(dense.const.nrow),
dense.ctr = as.integer(dense.ctr), use.rw = as.integer(use.rw), tmp =
as.character(tmp), status = as.integer(status), PACKAGE = lpSolve)  
 2: lpSolve:::lp(direction = min, objective.in = rep(1, nrow(PIChart)),
const.mat = t(PIChart), const.dir = =, 1, all.bin = TRUE)

 3: solvePIChart(PIChart)
 4: reduce.default(mydata = Lipset_fs, Survived.FZ, conditions,
explain = positive, remaind = exclude, prepro = fs, consistency =

0.7)
 5: reduce(mydata = Lipset_fs, Survived.FZ, conditions, explain =
positive, remaind = exclude, prepro = fs, consistency = 0.7)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

--
  

Sys.getlocale()


[1]
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C
  



  



--
Richard Gott
1 Willow Court
Finghall
Leyburn
N Yorks

DL8 5NL
01677 450 974

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


Re: [R] Huge data sets and RAM problems

2010-04-20 Thread Jay Emerson
Stella,

A few brief words of advice:

1. Work through your code a line at a time, making sure that each is what
you would expect.  I think some of your later problems are a result of
something
early not being as expected.  For example, if the read.delim() is in fact
not
giving you what you expect, stop there before moving onwards.  I suspect
some funny character(s) or character encodings might be a problem.

2. 32-bit Windows can be limiting. With 2 GB of RAM, you're probably not
going to be able to work effectively in native R with objects over 200-300
MB,
and the error indicates that something (you or a package you're using)
simply
have run out of memory.  So...

3. Consider more RAM (and preferably with 64-bit R).  Other solutions might
be possible, such as using a database to hand the data transition into R.
2.5 million rows by 18 columns is apt to be around 360 MB.  Although you
can afford 1 (or a few) copies of this, it doesn't leave you much room for
the memory overhead of working with such an object.

Part of the oringal message below.

Jay

-

Message: 80
Date: Mon, 19 Apr 2010 22:07:03 +0200
From: Stella Pachidi stella.pach...@gmail.com
To: r-h...@stat.math.ethz.ch
Subject: [R]  Huge data sets and RAM problems
Message-ID:
   g2j133363581004191307t2a48c1bfqd9d57cf0d6c62...@mail.gmail.com
Content-Type: text/plain; charset=ISO-8859-1

Dear all,



I am using R 2.10.1 in a laptop with Windows 7 - 32bit system, 2GB RAM
and CPU Intel Core Duo 2GHz.

.

Finally, another problem I have is when I perform association mining
on the data set using the package arules: I turn the data frame into
transactions table and then run the apriori algorithm. When I put too
low support in order to manage to find the rules I need, the vector of
rules becomes too big and I get problems with the memory such as:
Error: cannot allocate vector of size 923.1 Mb
In addition: Warning messages:
1: In items(x) : Reached total allocation of 153Mb: see help(memory.size)

Could you please help me with how I could allocate more RAM? Or, do
you think there is a way to process the data by loading them into a
document instead of loading all into RAM? Do you know how I could
manage to read all my data set?

I would really appreciate your help.

Kind regards,
Stella Pachidi


-- 
John W. Emerson (Jay)
Associate Professor of Statistics
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

[[alternative HTML version deleted]]

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


Re: [R] sum() returns 0 not NA

2010-04-20 Thread Joshua Wiley
As a disclaimer, I cannot say that this is why sum() was designed as it was.

0 is the sum of a set with no elements, the empty set {}.  When
na.rm=TRUE, NA values are removed.  When the only values are NA (as in
your example c(NA, NA) ), and you remove them all, you are taking the
sum of no elements, which is 0.

Also note the behavior of

sum() # returns 0

sum is one of the few functions that you can simply call that will not
return an error.

HTH,

Josh

On Tue, Apr 20, 2010 at 9:42 AM,  will.ea...@gmx.net wrote:
 Dear all,

 just a stupid R question, since the results puzzle me a bit:

 sum(c(NA,NA), na.rm=TRUE)
 [1] 0
  NA + NA
 [1] NA
 NA + 1
 [1] NA


 Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?

 Thanks in advance,

 Will

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




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

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


Re: [R] sum() returns 0 not NA

2010-04-20 Thread Ted Harding
On 20-Apr-10 17:07:31, Joshua Wiley wrote:
 As a disclaimer, I cannot say that this is why sum() was designed as it
 was.
 
 0 is the sum of a set with no elements, the empty set {}.  When
 na.rm=TRUE, NA values are removed.  When the only values are NA (as in
 your example c(NA, NA) ), and you remove them all, you are taking the
 sum of no elements, which is 0.
 
 Also note the behavior of
 
 sum() # returns 0
 
 sum is one of the few functions that you can simply call that will not
 return an error.
 
 HTH,
 
 Josh
 
 On Tue, Apr 20, 2010 at 9:42 AM,  will.ea...@gmx.net wrote:
 Dear all,

 just a stupid R question, since the results puzzle me a bit:

 sum(c(NA,NA), na.rm=TRUE)
 [1] 0
 _NA + NA
 [1] NA
 NA + 1
 [1] NA


 Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?

 Thanks in advance,

 Will

Exactly the same question was asked, in exactly the same words,
5 days ago:

https://stat.ethz.ch/pipermail/r-help/2010-April/235337.html

and, I suspect, by exactly the same person (thoug using a
different email address). And, also, it was answered 5 days ago.

Was the second sending an accident?
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 20-Apr-10   Time: 18:24:38
-- 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] What is mclust up to? Different clusters found if x and y interchanged

2010-04-20 Thread Bryan Hanson
Thanks Prof. Fraley.  This is very helpful.  I had looked at the way mclust
gets its start and that looked like a possible source of the differences,
but had not had time to get up to speed and figure it out.  I was thinking
it was more of a set.seed sort of thing.  Now I know more.  Thanks so much.
Bryan


On 4/20/10 11:41 AM, Chris Fraley fra...@u.washington.edu wrote:

 
 
 This is a really interesting case, but it is probably not that unusual.
 
 mod23 - Mclust(tur[,2:3])
 mod32 - Mclust(tur[,3:2])
 
 mod23[c(modelName,G)]
 mod32[c(modelName,G)]
 
 The 2:3 case is choosing the VVV model (more parameters per cluster) with 3
 clusters.
 The 3:2 case is choosing the EEV model (more parsimonious), but with 7
 clusters.
 
 If you look at the BIC curves, you can see that mclust is indeed choosing the
 model
 corresponding to the maximum BIC in each case.
 
 plot( mclustBIC( tur[,2:3], modelNames = c(EEV, VVV))
 plot( mclustBIC( tur[,3:2], modelNames = c(EEV, VVV))
 
 The default initialization for Mclust is via hierarchical clustering, and
 that's
 why the results differ
 
 hc23 - hcVVV( tur[,2:3]) # default initialization for mod23
 hc32 - hcVVV( tur[,3:2]) # default initialization for mod32
 
 all.equal(hc32,hc23) # they differ!
 
 The hierarchical clustering merges two groups at each stage.
 If there is more than one choice at any particular stage for
 which the merge criteria are equal or within roundoff error,
 a different pair could be chosen for merging if columns (or rows)
 are permuted. This will affect later merges, and could ultimately
 affect the mclust results.
 
 If you initialize both col permutations in the same way, you'll get
 the same results.
 
 mod23mod - Mclust(tur[,2:3], initialization = list( hcPairs = hc32)) # uses
 mod32 initialization
 mod32mod - Mclust(tur[,3:2], initialization = list( hcPairs = hc23)) # uses
 mod23 initialization
 
 mod23mod[c(modelName,G)] # same as mod32
 mod32mod[c(modelName,G)] # same as mod23
 
 Hope this helps,
 
 Chris Fraley
 
 
 On Tue, 20 Apr 2010, Bryan Hanson wrote:
 
 Prof. Fraley, I wonder if you would have a couple of moments to respond to
 this question I put to the R help list.  Thanks in advance for your time.
 
 Bryan
 *
 Bryan Hanson
 Acting Chair
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA
 
 
 -- Forwarded Message
 From: Bryan Hanson han...@depauw.edu
 Date: Mon, 19 Apr 2010 19:31:03 -0400
 To: han...@gapps.depauw.edu, R Help r-h...@stat.math.ethz.ch
 Subject: [R] What is mclust up to? Different clusters found if x and y
 interchanged
 
 Hello All...
 
 I gave a task to my students that involved using mclust to look for clusters
 in some bivariate data of isotopes vs various mining locations.  They
 discovered something I didn¹t expect; the data (called tur) is appended
 below.
 
 p - qplot(x = dD, y = dCu65, data = tur, color = mine)
 print(p) # simple bivariate plot of the data; looks fine
 
 mod1 - Mclust(tur[,2:3])
 mod1$G
 mod2 - Mclust(tur[,3:2])
 mod2$G
 
 One can use coordProj to see the clusters found, but the basic result is
 that mclust found 3 clusters in mod1, but if you interchange the x and y
 columns it finds 7 clusters (mod2).  Since this is bivariate data, I find
 this result pretty strange.  The only thing I can think of is that it has
 something to do with how the algorithm is seeded, but that isn't too
 convincing.  Since I couldn't believe my eyes, I made up some bivariate data
 with known clusters (not given here) and interchanged the x and y columns
 and got the same clusters.  I'm at a loss.  Hopefully someone can set my
 understanding on the right path.
 
 Thanks for any insight!  Bryan
 
 sessionInfo()
 R version 2.10.1 (2009-12-14)
 x86_64-apple-darwin9.8.0
 
 locale:
 [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
 
 attached base packages:
 [1] datasets  tools grid  graphics  grDevices utils stats
 methods   base
 
 other attached packages:
 [1] faraway_1.0.4  GGally_0.1 xtable_1.5-6   mvbutils_2.5.1
 ggplot2_0.8.7
 [6] digest_0.4.2   reshape_0.8.3  proto_0.3-8ChemoSpec_1.43
 R.utils_1.4.0
 [11] R.oo_1.7.1 R.methodsS3_1.2.0  rgl_0.91   lattice_0.18-3
 mvoutlier_1.4
 [16] plyr_0.1.9 RColorBrewer_1.0-2 chemometrics_0.8   som_0.3-5
 robustbase_0.5-0-1
 [21] rpart_3.1-46   pls_2.1-0  pcaPP_1.8  mvtnorm_0.9-9
 nnet_7.3-1
 [26] mclust_3.4.4   MASS_7.3-5 lars_0.9-7 e1071_1.5-23
 class_7.3-2
 
 And the data:
 
 dput(tur)
 structure(list(mine = structure(c(13L, 13L, 13L, 13L, 13L, 13L,
 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
 6L, 6L, 6L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
 9L, 9L, 9L, 9L, 12L, 12L, 12L, 12L, 12L, 8L, 8L, 8L, 8L, 8L,
 8L, 8L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 10L, 10L, 10L, 

Re: [R] Unwanted boxes in legend

2010-04-20 Thread Peter Ehlers

On 2010-04-19 8:11, Thomas Stewart wrote:

Try border=c(0,0,1,0).
-tgs


If the 'border' argument is not recognized, then this won't work.

Steve:
What version of R are you using? I have no problems with the
suggestions I gave you in R 2.10.1 or R 2.11.0 alpha.

 -Peter Ehlers



On Mon, Apr 19, 2010 at 4:21 AM, Steve Murraysmurray...@hotmail.comwrote:



Dear all,

Thanks for the response, however I'm getting the following error message
when I execute the legend command using the 'border' argument:

Error in legend(10, par(usr)[4], c(A, B,  :
   unused argument(s) (border = FALSE)


Is anyone aware of any alternative means of switching off boxes around all
but one of the elements in a legend?

Many thanks for any input,

Steve




Date: Thu, 15 Apr 2010 12:13:40 -0600
From: ehl...@ucalgary.ca
To: smurray...@hotmail.com
CC: r-help@r-project.org
Subject: Re: [R] Unwanted boxes in legend

On 2010-04-15 11:10, Steve Murray wrote:


Dear all,

I am using the following code to generate a legend in my plot

(consisting of both bars and points), but end up with boxes around my
points:


legend(10, par(usr)[4], c(A, B, C, D), fill=c(NA,NA, grey28,

NA), pch=c(16,4,NA,18), col=c(red,blue,grey28,yellow), lty=FALSE,
bty=n, horiz=FALSE)


I want a box around the third element of the legend (to represent the

bar 'fill' colour), but not for the others, where points are shown instead.


What am I doing wrong above and how do I correct it?


Add the 'border' argument:

either

border = FALSE # in which case no box is drawn for any element

or

border = c(NA, NA, black, NA)

-Peter Ehlers



Many thanks,

Steve


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



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

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

2010-04-20 Thread Xie Chao
Dear All,

I am wondering is there any shift (or pop or push or unshift) equivalent in R?
For example,
shift(x)   # should return x[1], and x becomes x[-1]

Thanks a lot.

Best Regards,
Xie Chao

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


Re: [R] comparing attitudes of 2 groups / likert scales?

2010-04-20 Thread Peter Ehlers

On 2010-04-19 9:15, Dieter Menne wrote:



David Winsemius wrote:



If you are thinking of using that quote, you might want to check the
spelling of his name. My memory is van Belle.




Sorry, I thought I had corrected that before mailing.

@BOOK{vanBelle2002,
   title = {Statistical rules of thumb},
   publisher = {Wiley series in probability and statistics},
   year = {2002},
   author = {Gerald van Belle}
}



And a very fine book it is, too. Highly recommended.

--
Peter Ehlers
University of Calgary

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


Re: [R] shift and pop equivalent in R

2010-04-20 Thread Duncan Murdoch

On 20/04/2010 2:03 PM, Xie Chao wrote:

Dear All,

I am wondering is there any shift (or pop or push or unshift) equivalent in R?
For example,
shift(x)   # should return x[1], and x becomes x[-1]
  


Not in base R.  Generally speaking, functions with side effects are 
frowned upon.  It is possible to write it yourself, but you need to 
watch out for weird cases like


shift(x + y)

where it's not at all clear what the side effect should be.

Duncan Murdoch

Thanks a lot.

Best Regards,
Xie Chao

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

2010-04-20 Thread Barry Rowlingson
On Tue, Apr 20, 2010 at 7:03 PM, Xie Chao xiech...@gmail.com wrote:
 Dear All,

 I am wondering is there any shift (or pop or push or unshift) equivalent in R?
 For example,
 shift(x)   # should return x[1], and x becomes x[-1]


 I seem to have implemented a FIFO stack in 2003:

http://finzi.psych.upenn.edu/R/Rhelp02/archive/15541.html

 but note the reply commenting on the existence of the stack
function in R which stacks data on top of other data.

Here's sample usage once you've loaded the code from that old posting:

 s=stack()
 push(s,1)
 s
[[1]]
[1] 1

 push(s,3)
 push(s,4)
 pop(s)
[1] 4
 pop(s)
[1] 3
 s
[[1]]
[1] 1

 If you want to implement a 'shift' method, just look at the existing
pop and push methods and write something similar. Note how the
functions are created on the object, and then called from S3 methods.
Note the use of - within the functions on the object. There's
probably better ways to do this, and with S4 methods.

Barry



-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [R] shift and pop equivalent in R

2010-04-20 Thread Xie Chao
Thanks Barry for the code sample, and Thanks Duncan for the clarification.

Both replies help a lot!

Best Regards,
Xie Chao


On Wed, Apr 21, 2010 at 2:50 AM, Barry Rowlingson
b.rowling...@lancaster.ac.uk wrote:
 On Tue, Apr 20, 2010 at 7:03 PM, Xie Chao xiech...@gmail.com wrote:
 Dear All,

 I am wondering is there any shift (or pop or push or unshift) equivalent in 
 R?
 For example,
 shift(x)   # should return x[1], and x becomes x[-1]


  I seem to have implemented a FIFO stack in 2003:

 http://finzi.psych.upenn.edu/R/Rhelp02/archive/15541.html

  but note the reply commenting on the existence of the stack
 function in R which stacks data on top of other data.

 Here's sample usage once you've loaded the code from that old posting:

 s=stack()
 push(s,1)
 s
 [[1]]
 [1] 1

 push(s,3)
 push(s,4)
 pop(s)
 [1] 4
 pop(s)
 [1] 3
 s
 [[1]]
 [1] 1

  If you want to implement a 'shift' method, just look at the existing
 pop and push methods and write something similar. Note how the
 functions are created on the object, and then called from S3 methods.
 Note the use of - within the functions on the object. There's
 probably better ways to do this, and with S4 methods.

 Barry



 --
 blog: http://geospaced.blogspot.com/
 web: http://www.maths.lancs.ac.uk/~rowlings
 web: http://www.rowlingson.com/
 twitter: http://twitter.com/geospacedman
 pics: http://www.flickr.com/photos/spacedman


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


[R] Help with Partial dependence bar graph

2010-04-20 Thread Daudi Jjingo
Hello,

I need to draw a partial dependence bar graph.
My the my predictor vectors are continous and so is the response variable.

Iam using the partialPlot function of the randomForest package. I get a line
graph. How can I edit it to get a bar graph instead?

(partialPlot(randomForest object ,data-matrix, number of predictor vectors,
Temp))

-- 
Daudi Jjingo

[[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] Exporting PDF

2010-04-20 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
 I run the script and it exports a PDF called version 1.
 I want it to check if version 1 already exists. If so,
  then I want the new graphs to be exported as
 version 2, and so on.

 Is it possible to do it in R?

Someone may know a way.  However its certainly possible to execute a command in 
linus from R.  So you can ls the file (in windows try dir) and see if it 
exists, and build a loop round that.
Just bew3are it'll be quick if there is only 1 file.  If you have  files it 
may slow things down a bit!
Here's my example...

#Example script to check if a file exists (linux system)
filename = somefile
fileno = 0
extension= .pdf
path=/home/user/

repeat
{
fullfile= paste(path,filename,fileno,extension, sep=)
if (length (system(paste(ls,fullfile), intern = T)) == 0) break
fileno-fileno+1
}

#your command to save the file... using 'fullfile' as the filename and path




This message may contain confidential information. If yo...{{dropped:21}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] having more than one plot in one figure

2010-04-20 Thread kayj

Hi All,

I have been trying to plot multiple line plots with different colors on one
figure. in my example below I was able to plot cat vs num1 as a dot plot
connected with lines but was not able to do that for cat vs num2 and I do
not know how to add the third plot cat vs num3. below is my code


df - data.frame(cat=1:10, num1=rnorm(10), num2=rnorm(10), num3=rnorm(10))
plot(df$num1, type=b, col=red, xlab=categories, ylab=random numbers)
points(df$num1, type=p, pch=21, col=red,bg=red)#plot num1 
points(df$num2, type=p, pch=21, col=green)   #plot num2 
legend(x=topright, legend=c(num1, num2), pch=c(16,16),
col=c(red,green))#add a legend 


how to make the second plot of type=b and how to add a  third plot cat vs
num3?

I appreciate your help


 
-- 
View this message in context: 
http://n4.nabble.com/having-more-than-one-plot-in-one-figure-tp2017471p2017471.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] Building Rblas.dll failing on Windows 7 (64-bit)

2010-04-20 Thread Udaya B. Kogalur
I'm currently attempting to build R-2.10.1 from the source on Windows
7 (64-bit version).  I've downloaded the latest Rtools (Rtools211.exe)
from the Murdoch-Sutherland site and have done a full install.  I've
also downloaded the HTML Help Workshop, MikTeX, and the InnoSetup
installer.

I am not using any 64-bit versions of the tools, such as the
MinGW-w64, or a 64-bit version of TCL as I'm just trying to build the
32-bit version of R first.

The only change necessary in Mkrules was the location of the Inno
Setup directory.

The make process gets a considerable way through before exiting with
the following error:

.
.
.
gcc -std=gnu99 -shared -s -mwindows -o R.dll R.def console.o
dataentry.o dynload.o edit.o editor.o embeddedR.o extra.o opt.o
pager.o preferences.o psignal.o rhome.o rt_complete.o rui.o run.o
shext.o sys-win32.o system.o dos_wglob.o e_pow.o malloc.o
../main/libmain.a ../appl/libappl.a ../nmath/libnmath.a getline/gl.a
../extra/xdr/libxdr.a ../extra/pcre/libpcre.a ../extra/bzip2/libbz2.a
../extra/intl/libintl.a ../extra/trio/libtrio.a ../extra/tzone/libtz.a
../extra/tre/libtre.a ../extra/xz/liblzma.a dllversion.o -L.
-lgfortran -lRblas -L../../bin -lRzlib -lRgraphapp -lRiconv -lcomctl32
-lversion

cp R.dll ../../bin/

 Building ../../../bin/Rblas.dll 

gcc -std=gnu99 -shared  -o ../../../bin/Rblas.dll blas.o cmplxblas.o
../../gnuwin32/dllversion.o Rblas.def -L../../../bin -lR -lgfortran

c:/factory/rtools/mingw/bin/../lib/gcc/mingw32/4.2.1-sjlj/../../../../mingw32/bin/ld.exe:
cannot find -lR

collect2: ld returned 1 exit status
make[3]: *** [../../../bin/Rblas.dll] Error 1
make[2]: *** [Rblas] Error 2
make[1]: *** [rbuild] Error 2
make: *** [all] Error 2

Thus we see that the prior step of building the R DLL has suceeded,
but it fails on the Rblas DLL.  Interestingly, I did notice that if I
repeat make all recommended, then it fails on the copy command

cp R.dll ../../bin/

as it tries to overwrite the file created on the proir run.  I think
this is a permission issue.  For some reason the R.dll file is read
only.   I'm wondering whether this is somehow related to the failure
in creating the Rblas.dll file.  Any thoughts would be appreciated.
Thank you.

ubk

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


Re: [R] having more than one plot in one figure

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 10:34 AM, kayj wrote:



Hi All,

I have been trying to plot multiple line plots with different colors  
on one
figure. in my example below I was able to plot cat vs num1 as a dot  
plot
connected with lines but was not able to do that for cat vs num2 and  
I do

not know how to add the third plot cat vs num3. below is my code


df - data.frame(cat=1:10, num1=rnorm(10), num2=rnorm(10),  
num3=rnorm(10))
plot(df$num1, type=b, col=red, xlab=categories, ylab=random  
numbers)

points(df$num1, type=p, pch=21, col=red,bg=red)#plot num1
points(df$num2, type=p, pch=21, col=green)   #plot num2
legend(x=topright, legend=c(num1, num2), pch=c(16,16),
col=c(red,green))#add a legend



Add the x values since points does not have exactly the same default  
behavior when given just one vector for plotting:


df - data.frame(cat=1:10, num1=rnorm(10), num2=rnorm(10),  
num3=rnorm(10))
plot(df$num1, type=b, col=red, xlab=categories, ylab=random  
numbers)
points(1:10, df$num2, type=b, pch=21, col=red,bg=red)#plot  
num1

points(1:10, df$num3, type=b, pch=21, col=green)   #plot num2
legend(x=topright, legend=c(num1, num2), pch=c(16,16),
col=c(red,green))#add a legend

If you want to have all of the random point visible than use range(c(df 
$num1, df$num2, df$num3) as your argument to ylim.





how to make the second plot of type=b and how to add a  third plot  
cat vs

num3?


I don't understand why you did not look at the help page for points  
and realize that type=b would work.




I appreciate your help



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] lattice code to plot columns over another variable

2010-04-20 Thread Rajarshi Guha
Hi, I've been struggling with a lattice visualiation. I have a
data.frame with 4 columns. What I'd like to have is a set of 3 panels.
Ecah panel will have the first column plotted against serial number
and then will superimpose the relevant column. My non-lattice version
is as follows:

x - data.frame( ... )
par(mfrow=c(3,1))
for (i in 2:4) {
  plot(x[,1])
  points(x[,i])
}

Any suggestions as to how I could convert this to a lattice version
would be much appreciated

Thanks,

-- 
Rajarshi Guha
NIH Chemical Genomics Center

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 3D surface plot with wireframe or persp?

2010-04-20 Thread Jin

Hello Dear,

I have a function, like z=f(x,y), and try a surface plot with this function.
But, on the reference of wireframe requires data option, so I generated x
and y, and computed z with them. But, still I have a problem to draw a
surface plot. The code  and errors are 

##
mle_beta0=64.43707;
mle_beta1=-24365.16;

# generating for the requirement of wireframe
data_for_c = runif(1000,30,85); # range is (30,50)
data_for_s = sort(1/(273+data_for_c)); 
data_for_time = sort(runif(1000,0,10)) # range is (0,10)
data_for_R = exp((-exp(mle_beta0+mle_beta1*data_for_s))*data_for_time)
data_all = cbind(data_for_s,data_for_time,data_for_R)

# function: plot_R_i_3d = f(data_for_time,data_for_s)
plot_R_i_3d = function(data_for_time,data_for_s)
{

R_i = exp((-exp(mle_beta0+mle_beta1*data_for_s))*data_for_time);
return(R_i)
}

# tried 1) persp or 2) wireframe

persp(data_for_time,data_for_s,plot_R_i_3d)

== Error in min(x, na.rm = na.rm) : invalid 'type' (list) of argument

wireframe(formula=data_for_R ~ data_for_s*data_for_time,data=data_all)

== Error in nrow(x) : 
   element 1 is empty;
   the part of the args list of 'dim' being evaluated was:
   (x)
###

I have two questions:

1) which one is better to plot in this case - persp and wireframe, Is
there another suggestion?
2) Is it possible to plot with only a function?
3) If not, what is wrong in the code above?

Many thank you in advance,

Jin


-- 
View this message in context: 
http://n4.nabble.com/3D-surface-plot-with-wireframe-or-persp-tp2017559p2017559.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Error in from:to : NA/NaN argument

2010-04-20 Thread cobbler_squad

Hello R gurus,

I am having difficulties running a chunk of code that I otherwise thought
was correct..

 if (lower  max(length(IC_peaks),length(IC_valleys))) {
+ valley_index - IC_valleys[lower+1]
+ for (i in seq(peak_index,valley_index-1)) {
+ IC_peaks_and_valleys - c(IC_peaks_and_valleys, v)
+ }
+ }
Error in from:to : NA/NaN argument

I can not pin point the issue and if you have any suggestions I would
greatly appreciate them. If more code is needed to figure out the problem, I
will post it right away.

Thank you all.


-- 
View this message in context: 
http://n4.nabble.com/Error-in-from-to-NA-NaN-argument-tp2017930p2017930.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Error in from:to : NA/NaN argument

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 3:54 PM, cobbler_squad wrote:



Hello R gurus,

I am having difficulties running a chunk of code that I otherwise  
thought

was correct..


if (lower  max(length(IC_peaks),length(IC_valleys))) {

+ valley_index - IC_valleys[lower+1]
+ for (i in seq(peak_index,valley_index-1)) {
+ IC_peaks_and_valleys - c(IC_peaks_and_valleys, v)
+ }
+ }
Error in from:to : NA/NaN argument


Perhaps an error in you seq() call which has from and to arguments.  
What do you get with this:


str(peak_index)
str(valley_index)



I can not pin point the issue and if you have any suggestions I would
greatly appreciate them. If more code is needed to figure out the  
problem, I

will post it right away.

Thank you all.


--

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] Basic doubt on ylim

2010-04-20 Thread poliveira

Hi all,

I'm a newbie with R and with a very basic question.
Can I define the minor unit for ylim? For example, I have a y scale ranging
from 1 to 14, jumping automatically every 2 units, but I want it to jump 1
unit at a time...is it possible? I tried something like

boxplot(bla[,1], xlim=c(1,15,1) 

and it didn't obbey... 
:( any suggestion??

Cheers from Portugal!
Patrícia
-- 
View this message in context: 
http://n4.nabble.com/Basic-doubt-on-ylim-tp2017891p2017891.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] Exporting PDF

2010-04-20 Thread Phil Spector

Since R provides the file.exists() function for exactly this
purpose, I would recommend avoiding using shell scripts for 
such a simple task.  file.exists() is a multiplatform solution

to the problem.
- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Tue, 20 Apr 2010, Polwart Calum (County Durham and Darlington NHS Foundation 
Trust) wrote:


I run the script and it exports a PDF called version 1.
I want it to check if version 1 already exists. If so,
 then I want the new graphs to be exported as
version 2, and so on.

Is it possible to do it in R?


Someone may know a way.  However its certainly possible to execute a command in 
linus from R.  So you can ls the file (in windows try dir) and see if it 
exists, and build a loop round that.
Just bew3are it'll be quick if there is only 1 file.  If you have  files it 
may slow things down a bit!
Here's my example...

#Example script to check if a file exists (linux system)
filename = somefile
fileno = 0
extension= .pdf
path=/home/user/

repeat
{
   fullfile= paste(path,filename,fileno,extension, sep=)
   if (length (system(paste(ls,fullfile), intern = T)) == 0) break
   fileno-fileno+1
}

#your command to save the file... using 'fullfile' as the filename and path




This message may contain confidential information. If yo...{{dropped:21}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error in from:to : NA/NaN argument

2010-04-20 Thread Ivan Calandra

Hi,

The problem, I think, comes from seq(peak_index,valley_index-1)
Since I don't know what is peak_index and valley_index, it is difficult 
to further help you.


Ivan

Le 20-Apr-10 21:54, cobbler_squad a écrit :

Hello R gurus,

I am having difficulties running a chunk of code that I otherwise thought
was correct..

   

if (lower  max(length(IC_peaks),length(IC_valleys))) {
 

+ valley_index- IC_valleys[lower+1]
+ for (i in seq(peak_index,valley_index-1)) {
+ IC_peaks_and_valleys- c(IC_peaks_and_valleys, v)
+ }
+ }
Error in from:to : NA/NaN argument

I can not pin point the issue and if you have any suggestions I would
greatly appreciate them. If more code is needed to figure out the problem, I
will post it right away.

Thank you all.





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


Re: [R] Basic doubt on ylim

2010-04-20 Thread Ivan Calandra
Hi,

Take a look at ?par and especially the xaxp argument.
I'm not quite sure, but if it's not this one, it's probably another one 
in par()

HTH,
Ivan

Le 20-Apr-10 21:21, poliveira a écrit :
 Hi all,

 I'm a newbie with R and with a very basic question.
 Can I define the minor unit for ylim? For example, I have a y scale ranging
 from 1 to 14, jumping automatically every 2 units, but I want it to jump 1
 unit at a time...is it possible? I tried something like


 boxplot(bla[,1], xlim=c(1,15,1)
  
 and it didn't obbey...
 :( any suggestion??

 Cheers from Portugal!
 Patrícia



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

2010-04-20 Thread David Winsemius

There's a worked example of using axis() at the bottom of ?plot.default

On Apr 20, 2010, at 4:48 PM, Ivan Calandra wrote:


Hi,

Take a look at ?par and especially the xaxp argument.
I'm not quite sure, but if it's not this one, it's probably another  
one

in par()

HTH,
Ivan

Le 20-Apr-10 21:21, poliveira a écrit :

Hi all,

I'm a newbie with R and with a very basic question.
Can I define the minor unit for ylim? For example, I have a y scale  
ranging
from 1 to 14, jumping automatically every 2 units, but I want it to  
jump 1

unit at a time...is it possible? I tried something like



boxplot(bla[,1], xlim=c(1,15,1)


and it didn't obbey...
:( any suggestion??

Cheers from Portugal!
Patrà cia


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] some problems

2010-04-20 Thread tamas barjak
Dear R community!

I am a mathematician listener, and I have to rewrite some source codes from
Matlab to R. I would like to ask a solution of people who are skilled at him
better hereby, because it is very new for me R and I do not receive it final
result than in Matlab.

So the problem:

---
Let us generate 2005 standard normal random numbers, we depict it these the
histogram of density together with the standard normal density function! We
do this so that on [0,1] we write even random numbers the normal
distribution function into inverse one's!
---

I have a problem with it mainly when who I want to have it drawn. The
drawing the arrangement of the histogram and the density function slips
compared to each other. But the same situation then, if barplot() I use it.

I apologise for my ridiculous problem, and my bad composition (translator I
use a program).

Thank you very much: Barjak Tamas

[[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] Results from clogit out of range?

2010-04-20 Thread Noah Silverman
Hi,

I'm calculating a conditional logit on some data stratified by group. 
My understanding was that a conditional logit by definition returns a
value between 0 and 1 a a probability.  Can anyone suggest why I'm
seeing results outside of the {0,1} range??

The call in R is:

m - clogit(score ~ val_1 + val_2 + strata(group), data=data)

Then

prediction - predict(m,newdata)


A sample of the data with resulting predictive values is:
 group  score   val_1   val_2prediction
1  2009-01-04_1 1 0.5913962 -1.121589  1.62455210
2  2009-01-04_1 1 0.6175472 -3.249820 -0.20093346
3  2009-01-04_1 1 0.5439640 -2.424501  0.46651849
4  2009-01-04_1 0 0.3745209 -2.477424  0.31263855
5  2009-01-04_1 0 0.6329855 -3.424174 -0.34200448
6  2009-01-04_1 0 0.4571999 -2.770247  0.11190788
7  2009-01-04_1 0 0.3822623 -2.259422  0.50627534
8  2009-01-04_1 0 0.2605742 -4.424806 -1.44566070
9  2009-01-04_1 0 0.4449604 -2.357060  0.46174993
10 2009-01-04_1 0 0.6595178 -2.246518  0.69427842
11 2009-01-04_1 0 0.5260032 -2.977887 -0.02393871

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


Re: [R] Using all variables in a linear model

2010-04-20 Thread Joshua Wiley
What about using x[,-predictor].  For instance:

x - matrix(1:9, nrow=3)
x[,-2] # all but the second column

Perhaps using your code it would be something like...

lm=lm(x[,dim(x)[2]] ~ x[,-dim(x)[2]], data=x)

Best regards,

Josh

On Tue, Apr 20, 2010 at 3:12 PM, Walter Yund IV wyun...@gmail.com wrote:
 Hello,

 I am trying to automate linear regression for many different datasets, each
 with the same rough format (the last variable is the response).  I've been
 doing something like this:

  lm=lm(x[,dim(x)[2]] ~ ., data=x)

 where the dot denotes all variables.  However, this means that the response
 is included as a predictor, which is obviously what I don't want.  How do I
 request that all the columns in my dataset be used as predictors, except for
 the response?

 Thanks,

 Walter

        [[alternative HTML version deleted]]

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




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

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


Re: [R] some problems

2010-04-20 Thread Ted Harding
On 20-Apr-10 21:25:28, tamas barjak wrote:
 Dear R community!
 
 I am a mathematician listener, and I have to rewrite some
 source codes from Matlab to R. I would like to ask a solution
 of people who are skilled at him better hereby, because it is
 very new for me R and I do not receive it final result than
 in Matlab.
 
 So the problem:
 
 ---
 Let us generate 2005 standard normal random numbers, we depict
 it these the histogram of density together with the standard normal
 density function! We do this so that on [0,1] we write even random
 numbers the normal distribution function into inverse one's!
 ---
 
 I have a problem with it mainly when who I want to have it drawn.
 The drawing the arrangement of the histogram and the density
 function slips compared to each other. But the same situation then,
 if barplot() I use it.
 
 I apologise for my ridiculous problem, and my bad composition
 (translator I use a program).
 
 Thank you very much: Barjak Tamas

Here is an example of making a histogram of 2005 standard Normal
random numbers, drawing a histogram, and plotting the curve of
the standard Normal density on top of it. Explanations are added
as comments (#).

# set the RNG seed (for reproducibility of this example)
set.seed(54321)
# Generate 2005 standard Normal numbers
X - rnorm(2005)
# Draw a histogram (arbitrary break-points)
#   breAkpoints at -4.0, -3.6, -3.2, ... -0.4, 0, 0.4, ... 3.6, 4.0
hist(X, breaks = 0.4*(-10:10))

# Draw the curve of the Normal distributiom
#   using 10 points per interval of the histogram
#   and multiplying by the width 0.4 of the interval
#   in order to match the probabilities of the intervals
#   and also by N=2005 to scale the curve up to give counts
x0 - 0.04*(-100:100)
y0 - 2005*0.4*dnorm(x0)
lines(x0,y0)

There is no perceptible slip between the histigram and the
Normal curve Ithe slight differences are due to random variation
in the positions of the X values).

To see it better, use a much larger random sample:

set.seed(54321)
# Generate 20 standard Normal numbers
X - rnorm(20)
hist(X, breaks = 0.4*(-12:12))

x0 - 0.04*(-120:120)
y0 - 20*0.4*dnorm(x0)
lines(x0,y0)

(For this, the range of the histogram has been extended,
to include all the points)

I hope this helps to make it clearer how to do this in R.

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 20-Apr-10   Time: 23:28:07
-- 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] Results from clogit out of range?

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:


Hi,

I'm calculating a conditional logit on some data stratified by group.
My understanding was that a conditional logit by definition returns a
value between 0 and 1 a a probability.  Can anyone suggest why I'm
seeing results outside of the {0,1} range??


Probably because you did not read the help page for the function  
predict.coxph. Pay special attention to the type argument.


type=c(lp, risk, expected, terms)



The call in R is:

m - clogit(score ~ val_1 + val_2 + strata(group), data=data)

Then

prediction - predict(m,newdata)


I do not see that you have defined any newdata.




A sample of the data with resulting predictive values is:
group  score   val_1   val_2prediction
1  2009-01-04_1 1 0.5913962 -1.121589  1.62455210
2  2009-01-04_1 1 0.6175472 -3.249820 -0.20093346
3  2009-01-04_1 1 0.5439640 -2.424501  0.46651849
4  2009-01-04_1 0 0.3745209 -2.477424  0.31263855
5  2009-01-04_1 0 0.6329855 -3.424174 -0.34200448
6  2009-01-04_1 0 0.4571999 -2.770247  0.11190788
7  2009-01-04_1 0 0.3822623 -2.259422  0.50627534
8  2009-01-04_1 0 0.2605742 -4.424806 -1.44566070
9  2009-01-04_1 0 0.4449604 -2.357060  0.46174993
10 2009-01-04_1 0 0.6595178 -2.246518  0.69427842
11 2009-01-04_1 0 0.5260032 -2.977887 -0.02393871


By default (which is what you have implicitly chosen) you are  
requesting lp = linear predictors rather than risk.


--
David.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Using all variables in a linear model

2010-04-20 Thread Gabor Grothendieck
lm can take a data frame whose first column is the response so:

lm(rev(x))


On Tue, Apr 20, 2010 at 6:12 PM, Walter Yund IV wyun...@gmail.com wrote:
 Hello,

 I am trying to automate linear regression for many different datasets, each
 with the same rough format (the last variable is the response).  I've been
 doing something like this:

  lm=lm(x[,dim(x)[2]] ~ ., data=x)

 where the dot denotes all variables.  However, this means that the response
 is included as a predictor, which is obviously what I don't want.  How do I
 request that all the columns in my dataset be used as predictors, except for
 the response?

 Thanks,

 Walter

        [[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] Results from clogit out of range?

2010-04-20 Thread Noah Silverman
Thanks David,

That explains a lot.  I appreciate it.

--
Noah


On 4/20/10 3:48 PM, David Winsemius wrote:

 On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:

 Hi,

 I'm calculating a conditional logit on some data stratified by group.
 My understanding was that a conditional logit by definition returns a
 value between 0 and 1 a a probability.  Can anyone suggest why I'm
 seeing results outside of the {0,1} range??

 Probably because you did not read the help page for the function
 predict.coxph. Pay special attention to the type argument.

 type=c(lp, risk, expected, terms)


 The call in R is:

 m - clogit(score ~ val_1 + val_2 + strata(group), data=data)

 Then

 prediction - predict(m,newdata)

 I do not see that you have defined any newdata.



 A sample of the data with resulting predictive values is:
 group  score   val_1   val_2prediction
 1  2009-01-04_1 1 0.5913962 -1.121589  1.62455210
 2  2009-01-04_1 1 0.6175472 -3.249820 -0.20093346
 3  2009-01-04_1 1 0.5439640 -2.424501  0.46651849
 4  2009-01-04_1 0 0.3745209 -2.477424  0.31263855
 5  2009-01-04_1 0 0.6329855 -3.424174 -0.34200448
 6  2009-01-04_1 0 0.4571999 -2.770247  0.11190788
 7  2009-01-04_1 0 0.3822623 -2.259422  0.50627534
 8  2009-01-04_1 0 0.2605742 -4.424806 -1.44566070
 9  2009-01-04_1 0 0.4449604 -2.357060  0.46174993
 10 2009-01-04_1 0 0.6595178 -2.246518  0.69427842
 11 2009-01-04_1 0 0.5260032 -2.977887 -0.02393871

 By default (which is what you have implicitly chosen) you are
 requesting lp = linear predictors rather than risk.


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


Re: [R] Results from clogit out of range?

2010-04-20 Thread Noah Silverman
I just read the help page for predict.coxph.

It indicates that the risk score is just exp(lp)

What I'm trying to find, and have seen with some other implementations
is the conditional probability within group.  Neither the lp or the
risk options seem to deliver this.

What am I missing?

-N


On 4/20/10 4:22 PM, Noah Silverman wrote:
 Thanks David,

 That explains a lot.  I appreciate it.

 --
 Noah


 On 4/20/10 3:48 PM, David Winsemius wrote:
   
 On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:

 
 Hi,

 I'm calculating a conditional logit on some data stratified by group.
 My understanding was that a conditional logit by definition returns a
 value between 0 and 1 a a probability.  Can anyone suggest why I'm
 seeing results outside of the {0,1} range??
   
 Probably because you did not read the help page for the function
 predict.coxph. Pay special attention to the type argument.

 type=c(lp, risk, expected, terms)

 
 The call in R is:

 m - clogit(score ~ val_1 + val_2 + strata(group), data=data)

 Then

 prediction - predict(m,newdata)
   
 I do not see that you have defined any newdata.

 

 A sample of the data with resulting predictive values is:
 group  score   val_1   val_2prediction
 1  2009-01-04_1 1 0.5913962 -1.121589  1.62455210
 2  2009-01-04_1 1 0.6175472 -3.249820 -0.20093346
 3  2009-01-04_1 1 0.5439640 -2.424501  0.46651849
 4  2009-01-04_1 0 0.3745209 -2.477424  0.31263855
 5  2009-01-04_1 0 0.6329855 -3.424174 -0.34200448
 6  2009-01-04_1 0 0.4571999 -2.770247  0.11190788
 7  2009-01-04_1 0 0.3822623 -2.259422  0.50627534
 8  2009-01-04_1 0 0.2605742 -4.424806 -1.44566070
 9  2009-01-04_1 0 0.4449604 -2.357060  0.46174993
 10 2009-01-04_1 0 0.6595178 -2.246518  0.69427842
 11 2009-01-04_1 0 0.5260032 -2.977887 -0.02393871
   
 By default (which is what you have implicitly chosen) you are
 requesting lp = linear predictors rather than risk.

 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Changing the position of label title and rotating the title

2010-04-20 Thread Ceylan Yozgatligil
Dear all,

I want to plot a simple xy-plot but I have some problems with the label
titles. In my plot, y-axis title should be at the top of the y-axis and it
should be perpendicular to the axis. Similarly, x-axis title should be just
next to the x-axis not at the bottom. By using mgp, I can change the
position of the title vertically for y-axis and horizontally for x-axis but
I want to change the positions in other direction too.Can I do this in R?
 If you can help me, I appreciate a lot.


Thanks a lot,

Ceylan

[[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] Words appear to be bolded in the PDF output

2010-04-20 Thread chrisli1223

Problem solved. Yes, I found that the text is overlaid several times!
Thank you very much for your help, greatly appreciated. :)
-- 
View this message in context: 
http://n4.nabble.com/Words-appear-to-be-bolded-in-the-PDF-output-tp2016971p2018219.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] sum specific rows in a data frame

2010-04-20 Thread Matthew Dowle

Or try data.table 1.4 on r-forge, its grouping is faster than aggregate :

 agg datatable
X100.012 0.008
X100   0.020 0.008
X1000  0.172 0.020
X1 1.164 0.144
X1e.05 9.397 1.180

install.packages(data.table, repos=http://R-Forge.R-project.org;)
require(data.table)
dt = as.data.table(df)
t3 - system.time(zz3 - dt[, list(sumflt=sum(fltval), sumint=sum
(intval)), by=id])

Matthew


On Thu, 15 Apr 2010 13:09:17 +, hadley wickham wrote:
 On Thu, Apr 15, 2010 at 1:16 AM, Chuck vijay.n...@gmail.com wrote:
 Depending on the size of the dataframe and the operations you are
 trying to perform, aggregate or ddply may be better.  In the function
 below, df has the same structure as your dataframe.
 
 Current version of plyr:
 
  agg  ddply
 X100.005  0.007
 X100   0.007  0.026
 X1000  0.086  0.248
 X1 0.577  3.136
 X1e.05 4.493 44.147
 
 Development version of plyr:
 
  agg ddply
 X100.003 0.005
 X100   0.007 0.007
 X1000  0.042 0.044
 X1 0.410 0.443
 X1e.05 4.479 4.237
 
 So there are some big speed improvements in the works.
 
 Hadley

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

2010-04-20 Thread chrisli1223

Hi everyone,

I have been searching for answers for the following questions but I don't
have much success. The following questions may actually be quite simple. Any
help would be greatly appreciated.

(1) I have written a script which requires user input. I am using the
readline() command.However, everytime when I run the script, R does not wait
for the user input and proceed to the next line. Is there something like
par(ask=T) to solve this problem?

(2) In my script, I want it to stop running when a certain condition is met.
I have tried using the stop() function, but apparently R only stops reading
that line and start reading the following lines. I have also thought about
quit() but it is not quite what I want. May someone please lead me to the
right function please?

(3) When a minor error happens, I would like to get the user permission by
pressing the return key before the script continues to run. What function
should I be looking at?

Many thanks,
Chris
-- 
View this message in context: 
http://n4.nabble.com/User-inputs-tp2018251p2018251.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


[R] Best subset of models for glm.nb()

2010-04-20 Thread Tim Clark
Dear List,

I am looking for a function that will find the best subset of negative binomial 
models.  I have a large data set with 15 variables that I am interested in.  I 
want an easy way to run all possible models and find a subset of the best 
models that I can then look at in more detail.  I have found two functions that 
seem to provide what I am looking for, but am not sure which one (if either) 
are appropriate.

glmulti() in package glmulti does an exhaustive search of all models and gives 
a number of candidate models to choose from based on your choice of Information 
Criterion.  This seems to be exactly what I am after, but I found nothing about 
it on this list which makes me think there is some reason no one is using it.

gl1ce() in package lasso2 uses the least absolute shrinkage and selection 
operator (lasso) to do something.  I found it at another thread:
http://tolstoy.newcastle.edu.au/R/help/05/03/0121.html
I did not understand the paper it was based on, and want to know if it even 
does what I am interested in before investing a lot of time in trying to 
understand it.

Yes, I have read about the problems with stepwise algorithms and am looking for 
a valid alternative to narrowing down models when you have a lot of data and a 
large number of variables your interested in.  

Any thoughts on either of these methods?  Or should I be doing something else?

Thanks for your help,

Tim


Tim Clark
Department of Zoology 
University of Hawaii

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

2010-04-20 Thread Liam Blanckenberg
Hi all,

I have a question about setting arbitrary breaks/labels when using GGPLOT
and date/time data on the x-axis. I want to specify the breaks/limits
arbitrarily rather than using scale_x_date(major = 'blah'), much like when
arbitrarily defining breaks/labels using scale_x_discrete(breaks = blah,
labels = blah)

I have tried variants such as:

scale_x_date(major = seq(from = as.Date('2000-01-01'), to  =
as.Date('2009-01-01'), by = 'months'));

etc but can't get this to work. I want to arbitrarily define the
breaks/labels because I want to be able to control when the ticks/labels
start (i.e. I want to be able to set where the first and last ticks/labels
occur - you do not appear to be able to do this using the major = 'blah'
command under scale_x_date).

R-version: 2.9.2
ggplotversion: 0.8.5
OS: Windows 7

Many thanks,

Liam

[[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] Results from clogit out of range?

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 7:31 PM, Noah Silverman wrote:


I just read the help page for predict.coxph.

It indicates that the risk score is just exp(lp)

What I'm trying to find, and have seen with some other implementations
is the conditional probability within group.  Neither the lp or the
risk options seem to deliver this.

What am I missing?



I'm not sure that clogit lets you estimate that quantity:

http://tolstoy.newcastle.edu.au/R/help/06/02/21443.html

Do you have citations that back up your original assumption?

--  
David,




-N


On 4/20/10 4:22 PM, Noah Silverman wrote:

Thanks David,

That explains a lot.  I appreciate it.

--
Noah


On 4/20/10 3:48 PM, David Winsemius wrote:


On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:



Hi,

I'm calculating a conditional logit on some data stratified by  
group.
My understanding was that a conditional logit by definition  
returns a

value between 0 and 1 a a probability.  Can anyone suggest why I'm
seeing results outside of the {0,1} range??


Probably because you did not read the help page for the function
predict.coxph. Pay special attention to the type argument.

type=c(lp, risk, expected, terms)



The call in R is:

m - clogit(score ~ val_1 + val_2 + strata(group), data=data)

Then

prediction - predict(m,newdata)


I do not see that you have defined any newdata.




A sample of the data with resulting predictive values is:
   group  score   val_1   val_2 
prediction

1  2009-01-04_1 1 0.5913962 -1.121589  1.62455210
2  2009-01-04_1 1 0.6175472 -3.249820 -0.20093346
3  2009-01-04_1 1 0.5439640 -2.424501  0.46651849
4  2009-01-04_1 0 0.3745209 -2.477424  0.31263855
5  2009-01-04_1 0 0.6329855 -3.424174 -0.34200448
6  2009-01-04_1 0 0.4571999 -2.770247  0.11190788
7  2009-01-04_1 0 0.3822623 -2.259422  0.50627534
8  2009-01-04_1 0 0.2605742 -4.424806 -1.44566070
9  2009-01-04_1 0 0.4449604 -2.357060  0.46174993
10 2009-01-04_1 0 0.6595178 -2.246518  0.69427842
11 2009-01-04_1 0 0.5260032 -2.977887 -0.02393871


By default (which is what you have implicitly chosen) you are
requesting lp = linear predictors rather than risk.



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


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] Changing the position of label title and rotating the title

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 5:41 PM, Ceylan Yozgatligil wrote:


Dear all,

I want to plot a simple xy-plot but I have some problems with the  
label
titles. In my plot, y-axis title should be at the top of the y-axis  
and it
should be perpendicular to the axis. Similarly, x-axis title should  
be just

next to the x-axis not at the bottom. By using mgp, I can change the
position of the title vertically for y-axis and horizontally for x- 
axis but
I want to change the positions in other direction too.Can I do this  
in R?

If you can help me, I appreciate a lot.


?mtext




Thanks a lot,

Ceylan

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


[R] 'cuts' option in levelplot()

2010-04-20 Thread Gurmeet
 Hi All,

Does anyone knows what exactly cuts=some number (say 15) does in lattice's
levelplot(). I doubt this but does it uses cut() internally, something like
cut(z, 15)?

Thanks,
Gurmeet

[[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] 'cuts' option in levelplot()

2010-04-20 Thread David Winsemius


On Apr 20, 2010, at 10:43 PM, Gurmeet wrote:


Hi All,

Does anyone knows what exactly cuts=some number (say 15) does in  
lattice's
levelplot(). I doubt this but does it uses cut() internally,  
something like

cut(z, 15)?



C'mon, man, look at the code:

seq(zrng[1], zrng[2], length.out = cuts + 2)



Thanks,
Gurmeet




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] Converting daily data series to monthly series

2010-04-20 Thread zow...@ncst.go.ke
Hi Users,
I have daily series of data from 1962 - 2000, with  the data for February 
29th in leap years  excluded, leaving 365 daily values for each year. I 
wish to convert the daily series to monthly series. How can I do this using 
the zoo package or any other package?

Thanks 

ZABLONE OWITI
 GRADUATE STUDENT
Nanjing University of Information, Science and Technology
College of International Education
Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China
Tel: +86-25-58731402
Fax: +86-25-58731456 
Mob. 15077895632
Website: www.nuist.edu.cn

 

[[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] 'cuts' option in levelplot()

2010-04-20 Thread Gurmeet
Thanks David! :P

On Tue, Apr 20, 2010 at 11:02 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Apr 20, 2010, at 10:43 PM, Gurmeet wrote:

 Hi All,

 Does anyone knows what exactly cuts=some number (say 15) does in
 lattice's
 levelplot(). I doubt this but does it uses cut() internally, something
 like
 cut(z, 15)?


 C'mon, man, look at the code:

 seq(zrng[1], zrng[2], length.out = cuts + 2)


 Thanks,
 Gurmeet



 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] Converting daily data series to monthly series

2010-04-20 Thread Gabor Grothendieck
There is a monthly aggregation of daily data example in the
zoo-quickref vignette:

vignette(zoo-quickref)

and there are also relevant examples using aggregate.zoo or duplicated
in the example section of ?aggregate.zoo


On Tue, Apr 20, 2010 at 11:16 PM, zow...@ncst.go.ke zow...@ncst.go.ke wrote:
 Hi Users,
 I have daily series of data from 1962 - 2000, with  the data for February
 29th in leap years  excluded, leaving 365 daily values for each year. I
 wish to convert the daily series to monthly series. How can I do this using
 the zoo package or any other package?

 Thanks

 ZABLONE OWITI
  GRADUATE STUDENT
 Nanjing University of Information, Science and Technology
 College of International Education
 Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China
 Tel: +86-25-58731402
 Fax: +86-25-58731456
 Mob. 15077895632
 Website: www.nuist.edu.cn
 


        [[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] Converting daily data series to monthly series

2010-04-20 Thread Rubén Roa

 -Mensaje original-
 De: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] En nombre de zow...@ncst.go.ke
 Enviado el: miércoles, 21 de abril de 2010 5:16
 Para: r-help@r-project.org
 Asunto: [R] Converting daily data series to monthly series
 
 Hi Users,
 I have daily series of data from 1962 - 2000, with  the data 
 for February 29th in leap years  excluded, leaving 365 daily 
 values for each year. I wish to convert the daily series to 
 monthly series. How can I do this using the zoo package or 
 any other package?
 
 Thanks 
 
 ZABLONE OWITI
  GRADUATE STUDENT
 Nanjing University of Information, Science and Technology 
 College of International Education

Let df be your dataframe,

#In case you have to format your data as date before setting the montth
df$date   - as.Date(df$date, %d/%m/%Y)
#Getting year, month and week from your correctly formatted date
df$Year   - as.numeric(format(df$date, %Y))#Year
df$Month  - as.numeric(format(df$date, %m))#Month
df$Week   - as.numeric(format(df$date, %W)) +1 #Week


 

Dr. Rubén Roa-Ureta
AZTI - Tecnalia / Marine Research Unit
Txatxarramendi Ugartea z/g
48395 Sukarrieta (Bizkaia)
SPAIN

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