Re: [R] Transforming relational data

2011-02-18 Thread mathijsdevaan

OK, for the last step I have tried this (among other things): 
library(data.table) 
DT = data.table(read.table(textConnection("A  B  C 
1 1  a  1999 
2 1  b  1999 
3 1  c  1999 
4 1  d  1999 
5 2  c  2001 
6 2  d  2001
7 3  a  2004
8 3  b  2004
9 3  d  2004"),head=TRUE,stringsAsFactors=FALSE)) 

firststep = DT[,cbind(expand.grid(B,B),v=1/length(B)),by=C][Var1!=Var2] 
setkey(firststep,Var1,Var2) 
list1<-firststep[J(expand.grid(DT$B,DT$B),v=1/length(DT$B)),nomatch=0][,sum(v)]
list1
#27

What I would like to get:
list
1  0
2  0.5
3  2.5

Thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Re-Transforming-relational-data-tp3307449p3312140.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] Find peaks in dataset(x,y) and area for each peak

2011-02-18 Thread Laurent Gatto
Dear Ramya

On 18 February 2011 05:08, Ramya  wrote:
>
> http://r.789695.n4.nabble.com/file/n3312061/x_and_y_values.txt
> x_and_y_values.txt
>
>
> I have the absorbance values form HPLC Chromatogram. I need to find the
> peaks in datapoints and area under each peak.
>
> I am not sure how how to find the peaks, I tried couple of libraries and
> peak function but they return me a list of values which when computed from
> area turns out to be huge nnumbers. In the dataset I know there are 4 peaks
> but i couldnt find through R.

Using DrawChromatogram from OrgMassSpecR [1] for the main peak:

> library(OrgMassSpecR)
> dd <- read.csv("x_and_y_values.txt",sep="\t")
> DrawChromatogram(dd$x,dd$y,range=list(start="490",stop="580"))
  retentionTime peakArea apexIntensity
1 528.5  1276508 65845

seems to work fine for me.

[1] http://orgmassspecr.r-forge.r-project.org/

> getPeaks method was kind of promising but i am not sure how to use it.

Which getPeak do you mean? sessionInfo() would have given us some hints.

Hope this helps,

Laurent

> Any help would be appreciated.
>
> Thanks
> Ramya
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Find-peaks-in-dataset-x-y-and-area-for-each-peak-tp3312061p3312061.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.
>



-- 
[ Laurent Gatto | slashhome.be ]

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


Re: [R] color.scale error

2011-02-18 Thread Jim Lemon

On 02/18/2011 04:31 AM, Alaios wrote:

Dear all
when I call color.scale like this:


require('plotrix')
colcolor<-color.scale(c(range_sr,sr),extremes=c("red","blue"))


Error in if (min(reds)<  0 || max(reds)>  1) reds<- rescale(reds, c(0,  :
   missing value where TRUE/FALSE needed


range_sr
[1] -10.00  44.02977813958366

str(sr)
  num [1:100, 1:100] 2.54 2.71 2.89 2.95 3.03 ...


this was working on simpler data sets before.

How can I understand more what was the problem in depth.? I have read the 
source code of color.scale but unfortunately I did not make any progress to 
understand this error message. Is it possible to raise an exception before the 
error happens and see what went wrong?


Hi Alex,
When you concatenate (c) the extremes and the matrix, you get a vector:

> sr<-matrix(runif(1,-10,44.03),100,100)
> str(sr)
 num [1:100, 1:100] 11.2 27.13 4.13 -4.46 26.44 ...
> sr_colors<-color.scale(c(-10,44.03,sr))
> str(sr_colors)
 chr [1:10002] "#00" "#FF" "#646464" "#AFAFAF" "#434343" ...

Recreate the matrix:

sr_colors<-matrix(sr_colors[-(1:2)],100,100)

and all should be well.

Jim

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


Re: [R] RGtk2 on Debian Testing

2011-02-18 Thread Jan van der Laan


It has been a while back, but I believe I had to install libgtk2.0-dev  
(that was on Ubuntu)


You could also try to install the r-cran-rgtk2 debian-package using  
dpkg, aptitude, or whatever you use as package manager. This makes  
rgtk available for all users.


HTH,

Jan



Quoting Lorenzo Isella :


Dear All,
I am running Debian testing on my system for the amd64 architecture,
When trying to install the RGtk package I get this error



install.packages('RGtk2')

Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL
'http://rm.mirror.garr.it/mirrors/CRAN/src/contrib/RGtk2_2.20.8.tar.gz'
Content type 'application/x-gzip' length 2637806 bytes (2.5 Mb)
opened URL
==
downloaded 2.5 Mb

* installing *source* package ‘RGtk2’ ...
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/usr/local/lib/R/site-library/RGtk2’

The downloaded packages are in
‘/tmp/RtmpMTHLGF/downloaded_packages’
Warning message:
In install.packages("RGtk2") :
  installation of package 'RGtk2' had non-zero exit status

Does anyone know why there is a mismatch between my GTK and the one
required by R?
Should I enable some particular R repositories (I know that the
previous Debian testing was released a few days ago, but I do not know
if this is relevant).
Any suggestion is welcome.
Cheers

Lorenzo

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

2011-02-18 Thread Ingo Reinhold
Hi John, 

seems there is no easy way. I'll just precondition it with AWK as described 
here http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg53401.html

There are some remarks in the thread that R is not supposed to read too large 
files for "political" reasons. Maybe that's it.

Many thanks again for the effort. 

Ingo

From: John Kane [jrkrid...@yahoo.ca]
Sent: Thursday, February 17, 2011 11:54 AM
To: Ingo Reinhold
Subject: RE: [R] Variable length datafile import problem

Generally most of the gurus are in this list.  Hopefully someone will take an 
interest in the problem.

I suspect that there may be some kind of weird value in the file that is 
upsetting in import.  Given the results I got when I removed the data past BD 
and then at AL it seems that the problem might be within this range.

You could try removing half the data between those columns and see what 
happens, then repeat if something turns up. It's tedious but unless someone 
with a better grasp of variable length data import can help it's the best I can 
suggest.

BTW you only replied to me.  You should make sure to cc the list otherwise 
readers won't realise that I am being of no help.

If you still have the problem by Saturday e-mail me or post to the list and 
I'll try to spent some more time messing about with the problem.

Sorry to be of so little help.
--- On Thu, 2/17/11, Ingo Reinhold  wrote:

> From: Ingo Reinhold 
> Subject: RE: [R] Variable length datafile import problem
> To: "John Kane" 
> Received: Thursday, February 17, 2011, 5:36 AM
> Hi John,
>
> as it seems we're hitting the wall here, can you maybe
> recommend another mailing list with "gurus" (as you put it)
> that may be able to help?
>
> Regards,
>
> Ingo
> 
> From: John Kane [jrkrid...@yahoo.ca]
> Sent: Thursday, February 17, 2011 11:25 AM
> To: Ingo Reinhold
> Subject: RE: [R] Variable length datafile import problem
>
> Hi Ingo,
>
> I've had a bit of time to examine the file and I must say
> that, at the moment, I have no idea what is going on.
> I tried the old cut the file into pieces trick just came up
> with even more anomalous results.
>
> My first attempt remove all the data past column AL in an
> OOo Calc spreadsheet.  This created a rectangular
> dataset It imported into R with no problem with 38 columns
> as expected.
>
> Then I deleted all the data from the orignal data file
> (test.dat) removing all the data past column BD in an OOo
> Calc spreadsheet.
>
> This imported a file with only 38 columns.
>
> Something very funny is happening but at the moment I have
> no
>
> --- On Wed, 2/16/11, Ingo Reinhold 
> wrote:
>
> > From: Ingo Reinhold 
> > Subject: RE: [R] Variable length datafile import
> problem
> > To: "John Kane" 
> > Received: Wednesday, February 16, 2011, 1:59 AM
> > Hi John,
> >
> > V1 should be just a character. However I figured
> something
> > out myself. The import looks OK in terms of column
> when
> > adding the flush=TRUE option.
> >
> > I am still very confused about the dimensions that
> the
> > imported data shows. Loading my data file into
> something
> > like OOspreadsheet shows me a maximum of about 245,
> which
> > does not correspond to the 146 generated by R. Any
> idea
> > where this saturation comes from?
> >
> > Thanks,
> >
> > Ingo
> > 
> > From: John Kane [jrkrid...@yahoo.ca]
> > Sent: Wednesday, February 16, 2011 1:57 AM
> > To: Ingo Reinhold
> > Subject: RE: [R] Variable length datafile import
> problem
> >
> > Is rawData$V1 intended to be factor or character?
> >
> > str(rawData) gives
> > $ V1  : Factor w/ 54 levels "-232.0","-234.0",..:
> 41
> > 41 41 41 41 41 41 41 41 41 ...
> >
> > If you were not expecting a factor you might try
> > options(stringsAsFactors = FALSE) before importing
> the
> > data.
> >
> > --- On Tue, 2/15/11, Ingo Reinhold 
> > wrote:
> >
> > > From: Ingo Reinhold 
> > > Subject: RE: [R] Variable length datafile import
> > problem
> > > To: "John Kane" 
> > > Received: Tuesday, February 15, 2011, 3:35 PM
> > > Dear all,
> > >
> > > I have changed the file-ending with no change in
> the
> > > result. I don't think that this should matter.
> > >
> > > http://dl.dropbox.com/u/2414056/Test.dat
> > > is a test file which represent the structure I
> am
> > trying to
> > > read. So far I have used
> > >
> > > rawData=read.table("Test.txt", fill=TRUE,
> sep="\t",
> > > header=FALSE);
> > >
> > > When then looking at rawData$V1 this gives me a
> > distorted
> > > view of my original first column.
> > >
> > > Thanks,
> > >
> > > Ingo
> >
> >
> >
>
>
>
>



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


Re: [R] RGtk2 on Debian Testing

2011-02-18 Thread Jan van der Laan
It has been a while back, but I believe I had to install libgtk2.0-dev  
(that was on Ubuntu)


You could also try to install the r-cran-rgtk2 debian-package using  
dpkg, aptitude, or whatever you use as package manager. This makes  
rgtk available for all users.


HTH,
Jan



Quoting Lorenzo Isella :


Dear All,
I am running Debian testing on my system for the amd64 architecture,
When trying to install the RGtk package I get this error



install.packages('RGtk2')

Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL
'http://rm.mirror.garr.it/mirrors/CRAN/src/contrib/RGtk2_2.20.8.tar.gz'
Content type 'application/x-gzip' length 2637806 bytes (2.5 Mb)
opened URL
==
downloaded 2.5 Mb

* installing *source* package ‘RGtk2’ ...
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/usr/local/lib/R/site-library/RGtk2’

The downloaded packages are in
‘/tmp/RtmpMTHLGF/downloaded_packages’
Warning message:
In install.packages("RGtk2") :
  installation of package 'RGtk2' had non-zero exit status

Does anyone know why there is a mismatch between my GTK and the one
required by R?
Should I enable some particular R repositories (I know that the
previous Debian testing was released a few days ago, but I do not know
if this is relevant).
Any suggestion is welcome.
Cheers

Lorenzo

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

2011-02-18 Thread Dimitris Rizopoulos

say, 'Dat' is your data frame, then one way to do it is:

with(Dat, tapply(freq, list(hair, eye, sex), c))


I hope it helps.

Best,
Dimitris



On 2/18/2011 8:50 AM, Lao Meng wrote:

The data is in the attachment.

What I wanna get is:
, , Sex = Male
Eye
HairBrown Blue Hazel Green
   Black32   1110 3
   Brown53   502515
   Red  10   10 7 7
   Blond 3   30 5 8
, , Sex = Female
Eye
HairBrown Blue Hazel Green
   Black369 5 2
   Brown66   342914
   Red  167 7 7
   Blond 4   64 5 8


Then,how to change the dataframe to tables?

Many thanks for your help.

Best



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

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


Re: [R] RGtk2 on Debian Testing

2011-02-18 Thread Lorenzo Isella
Thanks Jan, I am CCing to the list just to let everybody know that your 
suggestion pretty much fixes my problem. Installing RGtk2 was the last 
step to get rattle up and running. Somehow I had problems in running 
rattle with the RGtk2 package from the standard debian testing 
repositories (I suppose the RGtk2 version was not exactly the same).

Cheers

Lorenzo

On 18/02/11 10:24, Jan van der Laan wrote:

It has been a while back, but I believe I had to install libgtk2.0-dev
(that was on Ubuntu)

You could also try to install the r-cran-rgtk2 debian-package using
dpkg, aptitude, or whatever you use as package manager. This makes rgtk
available for all users.

HTH,
Jan



Quoting Lorenzo Isella :


Dear All,
I am running Debian testing on my system for the amd64 architecture,
When trying to install the RGtk package I get this error



install.packages('RGtk2')

Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL
'http://rm.mirror.garr.it/mirrors/CRAN/src/contrib/RGtk2_2.20.8.tar.gz'
Content type 'application/x-gzip' length 2637806 bytes (2.5 Mb)
opened URL
==
downloaded 2.5 Mb

* installing *source* package ‘RGtk2’ ...
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/usr/local/lib/R/site-library/RGtk2’

The downloaded packages are in
‘/tmp/RtmpMTHLGF/downloaded_packages’
Warning message:
In install.packages("RGtk2") :
installation of package 'RGtk2' had non-zero exit status

Does anyone know why there is a mismatch between my GTK and the one
required by R?
Should I enable some particular R repositories (I know that the
previous Debian testing was released a few days ago, but I do not know
if this is relevant).
Any suggestion is welcome.
Cheers

Lorenzo

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

2011-02-18 Thread Jari Oksanen
Damian Betebenner  nciea.org> writes:

> 
> In building a package, is it possible to make the package depend upon another
package that is only available
> on R-Forge (not CRAN). For example, by doing something in the DESCRIPTION file
> I'd like to add a dependency to my package such that when the user install my
package it will automatically
> install this other package from R-forge as well.
> 
Not strictly my business, but as an R-Forge developer I say that you should not
depend on a pacakge in R-Forge. If a package is in the R-Forge it probably is
(a) not ready for release, or (b) unstable, or (c) both. This means that you
should not depend on the package. 

If you think that neither of these is true, but the package is both ready for
the release and stable, you should urge its developer to release (a stable
version of) the package in CRAN.

Cheers, Jari Oksanen

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


Re: [R] need tick marks by 10s or 20s up to 200 on x axis

2011-02-18 Thread Jim Lemon

On 02/18/2011 07:56 AM, juliemcwh wrote:


Sorry, I have read other posts on tick marks but nothing is working.

Here is my R code.  I was able to turn off the x axis at one point (I
removed that code), but never got the tick marks on by 20s.  It always goes
to the default of 50, 100, 150, 200.

Thanks.

R code: hist(OMY$FL, main = "2010 Oncorhynchus mykiss Fork Length
Frequencies at Buck Creek Reach 1", include.lowest = TRUE, col = "blue",
border = "white", breaks = 140,
xlab = "Fork Length  in  mm", ylab = "Frequency", xlim = range(0,200), ylim
= range (0,15), xbar=10)


Hi Julie,
Joshua's suggestion will probably get you what you want. If you are 
still having trouble with some tick labels dropping out, have a look at 
staxlab (plotrix).


Jim

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


Re: [R] color.scale error

2011-02-18 Thread Alaios
Dear Jim,
this is just to confirm that it your solution worked :)

Regards
Alex

--- On Fri, 2/18/11, Jim Lemon  wrote:

> From: Jim Lemon 
> Subject: Re: [R] color.scale error
> To: "Alaios" 
> Cc: R-help@r-project.org
> Date: Friday, February 18, 2011, 9:10 AM
> On 02/18/2011 04:31 AM, Alaios
> wrote:
> > Dear all
> > when I call color.scale like this:
> >
> >
> > require('plotrix')
> >
> colcolor<-color.scale(c(range_sr,sr),extremes=c("red","blue"))
> >
> >
> > Error in if (min(reds)<  0 ||
> max(reds)>  1) reds<- rescale(reds, c(0,  :
> >    missing value where TRUE/FALSE needed
> >
> >
> > range_sr
> > [1] -10.00  44.02977813958366
> >
> > str(sr)
> >   num [1:100, 1:100] 2.54 2.71 2.89
> 2.95 3.03 ...
> >
> >
> > this was working on simpler data sets before.
> >
> > How can I understand more what was the problem in
> depth.? I have read the source code of color.scale but
> unfortunately I did not make any progress to understand this
> error message. Is it possible to raise an exception before
> the error happens and see what went wrong?
> >
> Hi Alex,
> When you concatenate (c) the extremes and the matrix, you
> get a vector:
> 
>  > sr<-matrix(runif(1,-10,44.03),100,100)
>  > str(sr)
>   num [1:100, 1:100] 11.2 27.13 4.13 -4.46 26.44 ...
>  > sr_colors<-color.scale(c(-10,44.03,sr))
>  > str(sr_colors)
>   chr [1:10002] "#00" "#FF" "#646464"
> "#AFAFAF" "#434343" ...
> 
> Recreate the matrix:
> 
> sr_colors<-matrix(sr_colors[-(1:2)],100,100)
> 
> and all should be well.
> 
> Jim
> 
> 




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


Re: [R] xyplot formula

2011-02-18 Thread Dennis Murphy
Hi:

Here's another approach using the reshape package:

library(reshape)
# id defines the grouping variables; the others are stacked, creating
# new variables 'variable' (containing the variable names as factor levels)
and
# 'value' (which holds the corresponding values)
dfm <- melt(df, id = c('country', 'food'))
# Strip off the leading 'X' and redefine as a factor with new levels
dfm$year <- factor(gsub('X', '', dfm$variable), levels = 2000:2003)

# Using foods as a groups = argument in xyplot():
xyplot(value ~ year | country, groups = food, data = dfm, type = c('p',
'l'))
# Using country and food as conditioning variables
xyplot(value ~ variable | country * food, data = dfm)

HTH,
Dennis

On Thu, Feb 17, 2011 at 10:41 PM, Geoff Russell
wrote:

> df=data.frame(country=c("A","A","A","B","B","B"),
>food=rep(c("Apples","Pears","Bananas"),2),
>X2000=c(4,5,6,7,6,8),
>X2001=c(4,5,6,7,6,8),
>X2002=c(4,5,6,7,6,8),
>X2003=c(4,5,6,7,6,8));
>
> I have data in the above form trying to get a plot of each fruit over time
> year conditioned on country and food.
>
> I tried,
>
> xyplot(X2000+X2001+X2002+X2003~2000:2003|country*food,df)
>
> But think I need to transform the data, just not sure
> how.  Any help gratefully received.
>
> Cheers,
> Geoff.
>
>[[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] xyplot formula

2011-02-18 Thread Geoff Russell
On Fri, Feb 18, 2011 at 8:35 PM, Dennis Murphy  wrote:

> Hi:
>
> Here's another approach using the reshape package:
>
> library(reshape)
> # id defines the grouping variables; the others are stacked, creating
> # new variables 'variable' (containing the variable names as factor levels)
> and
> # 'value' (which holds the corresponding values)
> dfm <- melt(df, id = c('country', 'food'))
> # Strip off the leading 'X' and redefine as a factor with new levels
> dfm$year <- factor(gsub('X', '', dfm$variable), levels = 2000:2003)
>
> # Using foods as a groups = argument in xyplot():
> xyplot(value ~ year | country, groups = food, data = dfm, type = c('p',
> 'l'))
> # Using country and food as conditioning variables
> xyplot(value ~ variable | country * food, data = dfm)
>

Yes, this helps too. The reshape package seems a little clearer, to me at
least,
than the reshape function.

Many thanks,
Geoff.


>
> HTH,
> Dennis
>
> On Thu, Feb 17, 2011 at 10:41 PM, Geoff Russell <
> geoffrey.russ...@gmail.com> wrote:
>
>> df=data.frame(country=c("A","A","A","B","B","B"),
>>food=rep(c("Apples","Pears","Bananas"),2),
>>X2000=c(4,5,6,7,6,8),
>>X2001=c(4,5,6,7,6,8),
>>X2002=c(4,5,6,7,6,8),
>>X2003=c(4,5,6,7,6,8));
>>
>> I have data in the above form trying to get a plot of each fruit over time
>> year conditioned on country and food.
>>
>> I tried,
>>
>> xyplot(X2000+X2001+X2002+X2003~2000:2003|country*food,df)
>>
>> But think I need to transform the data, just not sure
>> how.  Any help gratefully received.
>>
>> Cheers,
>> Geoff.
>>
>>[[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.
>>
>
>


-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069
http://perfidy.com.au

[[alternative HTML version deleted]]

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


Re: [R] How to change dataframe to tables

2011-02-18 Thread Dennis Murphy
This is a built-in dataset in R - see ?HairEyeColor and str() it.  I smell
homework...

Dennis

On Thu, Feb 17, 2011 at 11:50 PM, Lao Meng  wrote:

> The data is in the attachment.
>
> What I wanna get is:
> , , Sex = Male
>   Eye
> HairBrown Blue Hazel Green
>  Black32   1110 3
>  Brown53   502515
>  Red  10   10 7 7
>  Blond 3   30 5 8
> , , Sex = Female
>   Eye
> HairBrown Blue Hazel Green
>  Black369 5 2
>  Brown66   342914
>  Red  167 7 7
>  Blond 4   64 5 8
>
>
> Then,how to change the dataframe to tables?
>
> Many thanks for your help.
>
> Best
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] lm without intercept

2011-02-18 Thread Jan
Hi,

I am not a statistics expert, so I have this question. A linear model
gives me the following summary:

Call:
lm(formula = N ~ N_alt)

Residuals:
Min  1Q  Median  3Q Max 
-110.30  -35.80  -22.77   38.07  122.76 

Coefficients:
Estimate Std. Error t value Pr(>|t|)  
(Intercept)  13.5177   229.0764   0.059   0.9535  
N_alt 0.2832 0.1501   1.886   0.0739 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 56.77 on 20 degrees of freedom
  (16 observations deleted due to missingness)
Multiple R-squared: 0.151, Adjusted R-squared: 0.1086 
F-statistic: 3.558 on 1 and 20 DF,  p-value: 0.07386 

The regression is not very good (high p-value, low R-squared). 
The Pr value for the intercept seems to indicate that it is zero with a
very high probability (95.35%). So I repeat the regression forcing the
intercept to zero:

Call:
lm(formula = N ~ N_alt - 1)

Residuals:
Min  1Q  Median  3Q Max 
-110.11  -36.35  -22.13   38.59  123.23 

Coefficients:
  Estimate Std. Error t value Pr(>|t|)
N_alt 0.292046   0.007742   37.72   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 55.41 on 21 degrees of freedom
  (16 observations deleted due to missingness)
Multiple R-squared: 0.9855, Adjusted R-squared: 0.9848 
F-statistic:  1423 on 1 and 21 DF,  p-value: < 2.2e-16 

1. Is my interpretation correct?
2. Is it possible that just by forcing the intercept to become zero, a
bad regression becomes an extremely good one?
3. Why doesn't lm suggest a value of zero (or near zero) by itself if
the regression is so much better with it?

Please excuse my ignorance.

Jan Rheinländer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] line type in plots of the "ade4" package

2011-02-18 Thread Duarte Viana
Hello all,

In package "ade4", does anyone know whether there is a simple way of
setting the line type for the ellipses in an s.class plot? The
argument "lty" does not work.

Thanks,
Duarte

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


Re: [R] lm without intercept

2011-02-18 Thread Achim Zeileis

On Fri, 18 Feb 2011, Jan wrote:


Hi,

I am not a statistics expert, so I have this question. A linear model
gives me the following summary:

Call:
lm(formula = N ~ N_alt)

Residuals:
   Min  1Q  Median  3Q Max 
-110.30  -35.80  -22.77   38.07  122.76 


Coefficients:
   Estimate Std. Error t value Pr(>|t|) 
(Intercept)  13.5177   229.0764   0.059   0.9535 
N_alt 0.2832 0.1501   1.886   0.0739 .

---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 


Residual standard error: 56.77 on 20 degrees of freedom
 (16 observations deleted due to missingness)
Multiple R-squared: 0.151, Adjusted R-squared: 0.1086 
F-statistic: 3.558 on 1 and 20 DF,  p-value: 0.07386 


The regression is not very good (high p-value, low R-squared).


Yes.


The Pr value for the intercept seems to indicate that it is zero with a
very high probability (95.35%).


Not quite. Consult your statistics textbook for the correct interpretation 
of p-values. Under the null hypothesis of a true intercept of zero, it is 
very likely to observe an intercept as large as 13.52 or larger.



So I repeat the regression forcing the intercept to zero:


Do you have a good interpretation for that?


Call:
lm(formula = N ~ N_alt - 1)

Residuals:
   Min  1Q  Median  3Q Max 
-110.11  -36.35  -22.13   38.59  123.23 


Coefficients:
 Estimate Std. Error t value Pr(>|t|) 
N_alt 0.292046   0.007742   37.72   <2e-16 ***

---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 


Residual standard error: 55.41 on 21 degrees of freedom
 (16 observations deleted due to missingness)
Multiple R-squared: 0.9855, Adjusted R-squared: 0.9848 
F-statistic:  1423 on 1 and 21 DF,  p-value: < 2.2e-16 


1. Is my interpretation correct?
2. Is it possible that just by forcing the intercept to become zero, a
bad regression becomes an extremely good one?
3. Why doesn't lm suggest a value of zero (or near zero) by itself if
the regression is so much better with it?


The model without intercept needs to be interpreted differently. The 
p-value pertains to a regression with intercept zero and slope 0.292 
against a model with both intercept zero and slope zero. If I had to 
guess, I would say this is not a very meaningful comparison for your data. 
The same is true for the R-squared (see also ?summary.lm for its 
definition in the case without intercept).


hth,
Z


Please excuse my ignorance.

Jan Rheinländer

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

2011-02-18 Thread Henrique Dallazuanna
Try this:

 xtabs(Freq ~ Hair + Eye + Sex, Dat)

Using Dimitri's Dat example.

On Fri, Feb 18, 2011 at 5:50 AM, Lao Meng  wrote:

> The data is in the attachment.
>
> What I wanna get is:
> , , Sex = Male
>   Eye
> HairBrown Blue Hazel Green
>  Black32   1110 3
>  Brown53   502515
>  Red  10   10 7 7
>  Blond 3   30 5 8
> , , Sex = Female
>   Eye
> HairBrown Blue Hazel Green
>  Black369 5 2
>  Brown66   342914
>  Red  167 7 7
>  Blond 4   64 5 8
>
>
> Then,how to change the dataframe to tables?
>
> Many thanks for your help.
>
> Best
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[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] censoring symbols on survfit plot

2011-02-18 Thread Terry Therneau
--begin included message 
Hi, when ploting Kaplan-Meier estimate curves as below, the censoring
symbols
(crosses) to not change thickness along the lines 
plot(survfit(surv ~ I(x>=cut.off) ),lty=c(1,2), lwd=2)

is there any strightforward way to make it happen? thanks

-- End inclusion ---

 The symbols on the plot are characters, and are controled by the cex
parameter.  I don't know how to make a character "thicker" but not
larger, other than choosing a different font.  That would affect the
labels also, however.

Terry T.

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


Re: [R] lm without intercept

2011-02-18 Thread Dennis Murphy
Hi:


On Fri, Feb 18, 2011 at 2:49 AM, Jan  wrote:

> Hi,
>
> I am not a statistics expert, so I have this question. A linear model
> gives me the following summary:
>
> Call:
> lm(formula = N ~ N_alt)
>
> Residuals:
>Min  1Q  Median  3Q Max
> -110.30  -35.80  -22.77   38.07  122.76
>
> Coefficients:
>Estimate Std. Error t value Pr(>|t|)
> (Intercept)  13.5177   229.0764   0.059   0.9535
> N_alt 0.2832 0.1501   1.886   0.0739 .
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 56.77 on 20 degrees of freedom
>  (16 observations deleted due to missingness)
> Multiple R-squared: 0.151, Adjusted R-squared: 0.1086
> F-statistic: 3.558 on 1 and 20 DF,  p-value: 0.07386
>
> The regression is not very good (high p-value, low R-squared).
> The Pr value for the intercept seems to indicate that it is zero with a
> very high probability (95.35%). So I repeat the regression forcing the
> intercept to zero:
>

That's not the interpretation of a p-value. What it means is: *given that
the null hypothesis beta0 = 0 is true*, the probability of observing a value
of the t-statistic *more extreme than the observed value of 0.059* is about
0.9535. The presumption that H_0 is true for the purpose of the test allows
one to derive a 'reference distribution' (in this case, the t-distribution
with error degrees of freedom) against which one can compare the observed
value of the t-statistic. The second part of the emphasized statement
provides a context for which the p-value can be correctly interpreted in
relation to the reference distribution of the test statistic when H_0 is
true.

You're evidently trying to interpret the p-value as the probability that the
null hypothesis is true. No.

You can conclude, however, that there is not enough sample evidence to
contradict the null hypothesis beta0 = 0 due to the magnitude of the
p-value.


> Call:
> lm(formula = N ~ N_alt - 1)
>
> Residuals:
>Min  1Q  Median  3Q Max
> -110.11  -36.35  -22.13   38.59  123.23
>
> Coefficients:
>  Estimate Std. Error t value Pr(>|t|)
> N_alt 0.292046   0.007742   37.72   <2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 55.41 on 21 degrees of freedom
>  (16 observations deleted due to missingness)
> Multiple R-squared: 0.9855, Adjusted R-squared: 0.9848
> F-statistic:  1423 on 1 and 21 DF,  p-value: < 2.2e-16
>
> 1. Is my interpretation correct?
>
2. Is it possible that just by forcing the intercept to become zero, a
> bad regression becomes an extremely good one?
>
No.

> 3. Why doesn't lm suggest a value of zero (or near zero) by itself if
> the regression is so much better with it?
>
Because computer programs don't read minds. You may want a zero intercept;
someone else may not. And your perception that the 'regression is so much
better' with a zero intercept is in error.

If you plotted your data, you would realize that whether you fit the 'best'
least squares model or one with a zero intercept, the fit is not going to be
very good, and you would have deduced that the 0.985 R^2 returned from the
no-intercept model is an illusion. It is mathematically correct, however,
given the linear model theory behind it and the definition of R^2 as the
ratio of the model sum of squares (SS) to the total SS. If you want to have
more fun, sum the residuals from the zero-intercept fit, and then ask
yourself why they don't add to zero.

You need to educate yourself on the difference between regression with and
without intercepts. In particular, the R^2 in the with-intercept model uses
mean corrections before computing sums of squares; in the no-intercept
model, mean corrections are not applied. Since R^2 is a ratio of sums of
squares, this distinction matters. (If my use of 'mean correction' is
confusing, Y is not mean-corrected, but Y - Ybar is. Ditto for X.)

Try this:
plot(N_alt, N, pch = 16)
abline(coef(lm(N ~ N_alt)))
abline(c(0, coef(lm(N ~ N_alt + 0))), lty = 'dashed')

Do the data cluster tightly around the dashed line?

HTH,
Dennis

PS: A Google search on 'linear regression zero intercept' might be
beneficial. Here are a couple of hits from such a search:
http://www.bios.unc.edu/~truong/b663/pdf/noint.pdf
http://tltc.ttu.edu/cs/colleges__schools/rawls_college_of_business/f/42/p/288/470.aspx

Please excuse my ignorance.
>
> Jan Rheinländer
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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, min

[R] multiple regression plane

2011-02-18 Thread Rosario Garcia Gil
Hello

I have a multiple linear regression with two cofactors, I would like to 
represent a plane but I could not find any help which worked out.

Any suggestions.

Regards and thanks in advance.
Rosario
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Shared nearest neighbor (SNN) clustering algorithm implementation?

2011-02-18 Thread Jay
Hello,

is there an implementation available for a shared nearest neighbor
(SNN) clustering algorithm?


//Jay

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

2011-02-18 Thread Krijnen WP, Wim
Dear R-people,

I am trying to read a matlab file, unfortunately without success.  I enclosed 
the zipped file.

Do you have an idea how to read this file by ReadMat package into the R  system?

Thanks for your time!

Wim Krijnen


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


Re: [R] missing values in party::ctree

2011-02-18 Thread Torsten Hothorn


On Thu, 17 Feb 2011, Andrew Ziem  wrote:


After ctree builds a tree, how would I determine the direction missing values 
follow by examining the BinaryTree-class object?  For instance in the example 
below Bare.nuclei has 16 missing values and is used for the first split, but 
the missing values are not listed in either set of factors.   (I have the same 
question for missing values among numeric [non-factor] values, but I assume the 
answer is similar.)


Hi Andrew,

ctree() doesn't treat missings in factors as a category in its own right. 
Instead, it uses surrogate splits to determine the daughter node 
observations with missings in the primary split variable are send to (you 
need to specify `maxsurrogates' in ctree_control()).


However, you can recode your factor and add NA to the levels. This will
lead to the intended behaviour.

Best,

Torsten





require(party)
require(mlbench)
data(BreastCancer)
BreastCancer$Id <- NULL
ct <- ctree(Class ~ . , data=BreastCancer, controls = ctree_control(maxdepth = 
1))
ct


Conditional inference tree with 2 terminal nodes

Response:  Class
Inputs:  Cl.thickness, Cell.size, Cell.shape, Marg.adhesion, Epith.c.size, 
Bare.nuclei, Bl.cromatin, Normal.nucleoli, Mitoses
Number of observations:  699

1) Bare.nuclei == {1, 2}; criterion = 1, statistic = 488.294
 2)*  weights = 448
1) Bare.nuclei == {3, 4, 5, 6, 7, 8, 9, 10}
 3)*  weights = 251

sum(is.na(BreastCancer$Bare.nuclei))

[1] 16

nodes(ct, 1)[[1]]$psplit

Bare.nuclei == {1, 2}

nodes(ct, 1)[[1]]$ssplit

list()



Based on below, the answer is node 2, but I don't see it in the object.


sum(BreastCancer$Bare.nuclei %in% c(1,2,NA))

[1] 448

sum(BreastCancer$Bare.nuclei %in% c(1,2))

[1] 432

sum(BreastCancer$Bare.nuclei %in% c(3:10))

[1] 251


Andrew




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 optim, within polr(): "initial value in 'vmmin' is not finite"

2011-02-18 Thread Ben Haller
  An update for the benefit of the list/posterity: I resolved this issue by 
switching over to using the lrm() function of package rms.  It seems to pick 
better starts, or something; in any case, it has been able to converge on a 
solution for every model I've tried, although for the most complex ones I 
needed to raise maxit (maximum iterations) above the default of 12 slightly.  
The lrm() function does not support interactions higher than third-order, and 
it does only logistic regressions, not probit or other types, so it does have 
its drawbacks; but it has solved my difficulties quite nicely.  Just in case 
anybody cares.  :->

Ben Haller
McGill University


On Feb 16, 2011, at 5:41 PM, Ben Haller wrote:

>  Hi all.  I'm just starting to explore ordinal multinomial regression.  My 
> dataset is 300,000 rows, with an outcome (ordinal factor from 1 to 9) and 
> five independent variables (all continuous).  My first stab at it was this:
> 
> pomod <- polr(Npf ~ o_stddev + o_skewness + o_kurtosis + o_acl_1e + 
> dispersal, rlc, Hess=TRUE)
> 
>  And that worked; I got a good model fit.  However, a variety of other things 
> that I've tried give me this error:
> 
> Error in optim(s0, fmin, gmin, method = "BFGS", ...) : 
>  initial value in 'vmmin' is not finite
> 
>  This occurs, for example, when I try to use the method="probit" option of 
> polr().  It also occurs when I try a regression involving interactions, such 
> as:
> 
> pomod <- polr(Npf ~ o_stddev * o_skewness * o_kurtosis * o_acl_1e * 
> dispersal, rlc, Hess=TRUE)
> 
>  I have good reason to believe that interactions are important here, so I'd 
> very much like to be able to fit such models.  I have been doing that 
> successfully with logistic regression (considering my outcome variable to be 
> binary, either "1" or "2-9") using glm(), but now using polr() it gives me 
> this error.  I've searched Google and the R lists for information about this 
> error, and while I did find a couple of other people asking about it, I 
> didn't find any advice about what to do about it that I can apply to my 
> situation.
> 
>  I'd be happy to share my dataset with anyone willing to help me on this, but 
> 300,000 rows is a bit large to include in this email.  :->
> 
>  Thanks!
> 
> Ben Haller
> McGill University
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

2011-02-18 Thread Michael Holt
Hello Everyone,

I'm pretty new to R and I'm trying to get some idea of the capabilities of
the language. I work with some pretty large data sets and the consensus
seems to be that R does not work well with big data. I've started talking to
the guys at Revolution, but I need to get some outside opinions of what R
can actually handle. At about what size does R start to run into problems?

-- 
*Michael Holt*, *Database Administrator*  |  A.E.R.S. & TERAPEAK
2307-4464 Markham Street, Victoria, BC, CANADA V8Z 7X8
 +1 250 483 3271 (FAX)
 www.terapeak.com | www.aers.ca | [image:
facebook]| [image:
twitter] 

[[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] lm without intercept

2011-02-18 Thread Mike Marchywka








Date: Fri, 18 Feb 2011 12:25:36 +0100
From: achim.zeil...@uibk.ac.at
To: jrheinlaen...@gmx.de
CC: r-help@r-project.org
Subject: Re: [R] lm without intercept


On Fri, 18 Feb 2011, Jan wrote:

> Hi,
>
> I am not a statistics expert, so I have this question. A linear model
> gives me the following summary:

You should be able to find the equations presumably
used for the computer output you question, as suggested by the earlier 
response, 
but then I would add that you should make up data with known
attributes, and verify that the output makes sense to you. Paper, pencil,
and books still work and they don't run out of memory :) 

In any case, eventually you will not to modify your real data slightly
to explore sensitivity so what you did above will not just be a learning
effort but produce useful stuff. 

Also, it doesn't appear that you have even plotted your data.

As someone once told me just as a general philosophical point
rather than an implied insult, " do things that make sense." ( not
asking " are you an idiot" just along the lines of "buy low, sell high").
All of this computer stuff comes from something, you just need to
dig into that. 



>
> Call:
> lm(formula = N ~ N_alt)
>
> Residuals:
>Min  1Q  Median  3Q Max
> -110.30  -35.80  -22.77   38.07  122.76
>
> Coefficients:
>Estimate Std. Error t value Pr(>|t|)
> (Intercept)  13.5177   229.0764   0.059   0.9535
> N_alt 0.2832 0.1501   1.886   0.0739 .
> ---
> Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> Residual standard error: 56.77 on 20 degrees of freedom
>  (16 observations deleted due to missingness)
> Multiple R-squared: 0.151, Adjusted R-squared: 0.1086
> F-statistic: 3.558 on 1 and 20 DF,  p-value: 0.07386
>
> The regression is not very good (high p-value, low R-squared).

Yes.

> The Pr value for the intercept seems to indicate that it is zero with a
> very high probability (95.35%).

Not quite. Consult your statistics textbook for the correct interpretation
of p-values. Under the null hypothesis of a true intercept of zero, it is
very likely to observe an intercept as large as 13.52 or larger.

> So I repeat the regression forcing the intercept to zero:

Do you have a good interpretation for that?

> Call:
> lm(formula = N ~ N_alt - 1)
>
> Residuals:
>Min  1Q  Median  3Q Max
> -110.11  -36.35  -22.13   38.59  123.23
>
> Coefficients:
>  Estimate Std. Error t value Pr(>|t|)
> N_alt 0.292046   0.007742   37.72   <2e-16 ***
> ---
> Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> Residual standard error: 55.41 on 21 degrees of freedom
>  (16 observations deleted due to missingness)
> Multiple R-squared: 0.9855, Adjusted R-squared: 0.9848
> F-statistic:  1423 on 1 and 21 DF,  p-value: < 2.2e-16
>
> 1. Is my interpretation correct?
> 2. Is it possible that just by forcing the intercept to become zero, a
> bad regression becomes an extremely good one?
> 3. Why doesn't lm suggest a value of zero (or near zero) by itself if
> the regression is so much better with it?

The model without intercept needs to be interpreted differently. The
p-value pertains to a regression with intercept zero and slope 0.292
against a model with both intercept zero and slope zero. If I had to
guess, I would say this is not a very meaningful comparison for your data.
The same is true for the R-squared (see also ?summary.lm for its
definition in the case without intercept).

hth,
Z

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

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


[R] how to incorporate prior base probabilities into binomial glmm

2011-02-18 Thread sprocket

Hi,

I am modeling a gen linear mixed model with binomial repeated measures
responses (y=cbind(correct/not correct)) of some individuals (id).
I have a 2X2 design (effort and costs) and another continuous independent
variable (scr). This will lead to something like this:

mod.1<-lmer(y~effort+costs+scr+(1|id),family=binomial)
 so far so good. In my experiment the probability to score a correct depends
also on a probability based on random choice. Short example: Individual 1
has to choose 5 times before a correct can happen in the high effort
condition while in the low effort condition Ind 1 only has to choose 3
times. So there is a different probability associated to the low and high
effort condition that an individual will choose correct.
How can I incorporate this into a model or does anybody know of paper where
a similar case has occurred?

Ulf

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-incorporate-prior-base-probabilities-into-binomial-glmm-tp3312442p3312442.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] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Maas James Dr (MED)
I'm attempting to sort a 3 dimensional array that looks like this
> x
, , 1
 [,1] [,2]
[1,]99
[2,]79
, , 2
 [,1] [,2]
[1,]65
[2,]46
, , 3
 [,1] [,2]
[1,]21
[2,]32

Such that it ends up like this 
> y
, , 1
 [,1] [,2]
[1,]21
[2,]32
, , 2
 [,1] [,2]
[1,]65
[2,]46
, , 3
 [,1] [,2]
[1,]99
[2,]79

I think this is sorting across the third dimension but several attempts using 
either the sort or apply functions have not worked.  Any and all suggestions 
most welcome.  Thanks

J

===
Dr. Jim Maas
University of East Anglia


[[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] lm without intercept

2011-02-18 Thread Jay Emerson
No, this is a cute problem, though: the definition of R^2 changes
without the intercept, because the
"empty" model used for calculating the total sums of squares is always
predicting 0 (so the total sums
of squares are sums of squares of the observations themselves, without
centering around the sample
mean).

Your interpretation of the p-value for the intercept in the first
model is also backwards: 0.9535 is extremely
weak evidence against the hypothesis that the intercept is 0.  That
is, the intercept might be near zero, but
could also be something veru different.  With a standard error of 229,
your 95% confidence interval
for the intercept (if you trusted it based on other things) would have
a margin of error of well over 400.  If you
told me that an intercept of, say 350 or 400 were consistent with your
knowledge of the problem, I wouldn't
blink.

This is a very small data set: if you sent an R command such as:

x <- c(x1, x2, ..., xn)
y <- c(y1, y2, ..., yn)

you might even get some more interesting feedback.  One of the many
good intro stats textbooks might
also be helpful as you get up to speed.

Jay
-
Original post:

Message: 135
Date: Fri, 18 Feb 2011 11:49:41 +0100
From: Jan 
To: "R-help@r-project.org list" 
Subject: [R] lm without intercept
Message-ID: <1298026181.2847.19.camel@jan-laptop>
Content-Type: text/plain; charset="UTF-8"

Hi,

I am not a statistics expert, so I have this question. A linear model
gives me the following summary:

Call:
lm(formula = N ~ N_alt)

Residuals:
   Min  1Q  Median  3Q Max
-110.30  -35.80  -22.77   38.07  122.76

Coefficients:
   Estimate Std. Error t value Pr(>|t|)
(Intercept)  13.5177   229.0764   0.059   0.9535
N_alt 0.2832 0.1501   1.886   0.0739 .
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Residual standard error: 56.77 on 20 degrees of freedom
 (16 observations deleted due to missingness)
Multiple R-squared: 0.151, Adjusted R-squared: 0.1086
F-statistic: 3.558 on 1 and 20 DF,  p-value: 0.07386

The regression is not very good (high p-value, low R-squared).
The Pr value for the intercept seems to indicate that it is zero with a
very high probability (95.35%). So I repeat the regression forcing the
intercept to zero:

Call:
lm(formula = N ~ N_alt - 1)

Residuals:
   Min  1Q  Median  3Q Max
-110.11  -36.35  -22.13   38.59  123.23

Coefficients:
 Estimate Std. Error t value Pr(>|t|)
N_alt 0.292046   0.007742   37.72   <2e-16 ***
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Residual standard error: 55.41 on 21 degrees of freedom
 (16 observations deleted due to missingness)
Multiple R-squared: 0.9855, Adjusted R-squared: 0.9848
F-statistic:  1423 on 1 and 21 DF,  p-value: < 2.2e-16

1. Is my interpretation correct?
2. Is it possible that just by forcing the intercept to become zero, a
bad regression becomes an extremely good one?
3. Why doesn't lm suggest a value of zero (or near zero) by itself if
the regression is so much better with it?

Please excuse my ignorance.

Jan Rheinl?nder


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

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


Re: [R] reading a matlab file

2011-02-18 Thread Ken Knoblauch
Krijnen WP, Wim  pl.hanze.nl> writes:

> 
> Dear R-people,
> 
> I am trying to read a matlab file, unfortunately without success.  
I enclosed the zipped file.
> 
> Do you have an idea how to read this file by ReadMat package
 into the R  system?
> 
> Thanks for your time!
> 
> Wim Krijnen
> 
> 

I don't think that your file came through, at least not on gmane.
You might need the Rcompression package (from the OmegaHat project)
for ReadMat to work if the file was saved with a recent version of matlab.

http://www.omegahat.org/

This is indicated in the documentation of the R.matlab package.

-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

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


Re: [R] how to incorporate prior base probabilities into binomial glmm

2011-02-18 Thread Ken Knoblauch
sprocket  gmail.com> writes:

> 
> 
> Hi,
> 
> I am modeling a gen linear mixed model with binomial 
repeated measures
> responses (y=cbind(correct/not correct)) of some 
individuals (id).
> I have a 2X2 design (effort and costs) and another 
continuous independent
> variable (scr). This will lead to something like this:
> 
> mod.1<-lmer(y~effort+costs+scr+(1|id),family=binomial)
>  so far so good. In my experiment the probability 
to score a correct depends
> also on a probability based on random choice. Short 
example: Individual 1
> has to choose 5 times before a correct can happen 
in the high effort
> condition while in the low effort condition Ind 1 only 
has to choose 3
> times. So there is a different probability associated 
to the low and high
> effort condition that an individual will choose correct.
> How can I incorporate this into a model or does 
anybody know of paper where
> a similar case has occurred?
> 
> Ulf
> 

I think that you have to define a new factor that distinguishes the
two levels of strong effort, say EffortLeve l( for lack of imagination 
on a Friday afternoon) and then from what you describe, the
subjects are nested in this, i.e., some had a high effort of 5
and others of 3.  Perhaps, the following would work then

glmer(y ~ EffortLevel/(effort + costs + scr) + (1 | id), family = binomial)

I think that if each observer has a unique id, that the nesting
will be automatic for this variable, but you should verify that.

-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

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


Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Joshua Wiley
Dear Jim,

This works for your small example.  I was not exactly sure what you
were sorting on.  In my example, I sum all values at each level of the
third dimension and sort by that sum.  Of course, if there are many
levels or the 2 dimensions being summed are quite large, this will be
quite computationally inefficient.  I also show how you could sort but
just the value in cell [1, 1, i] where i moves across all levels of
the third dimension.

## Your data
x <- array(c(9, 9, 7, 9, 6, 5, 4, 6, 2, 1, 3, 2), dim = list(2, 2, 3))
## sorting by sum dims 1&2 at each level of 3rd
x[ , , order(apply(x, 3, sum))]
## sorting by cell [1, 1] at each level of 3rd
x[ , , order(x[1, 1, ])]

HTH,

Josh

On Fri, Feb 18, 2011 at 5:01 AM, Maas James Dr (MED)  wrote:
> I'm attempting to sort a 3 dimensional array that looks like this
>> x
> , , 1
>     [,1] [,2]
> [1,]    9    9
> [2,]    7    9
> , , 2
>     [,1] [,2]
> [1,]    6    5
> [2,]    4    6
> , , 3
>     [,1] [,2]
> [1,]    2    1
> [2,]    3    2
>
> Such that it ends up like this 
>> y
> , , 1
>     [,1] [,2]
> [1,]    2    1
> [2,]    3    2
> , , 2
>     [,1] [,2]
> [1,]    6    5
> [2,]    4    6
> , , 3
>     [,1] [,2]
> [1,]    9    9
> [2,]    7    9
>
> I think this is sorting across the third dimension but several attempts using 
> either the sort or apply functions have not worked.  Any and all suggestions 
> most welcome.  Thanks
>
> J
>
> ===
> Dr. Jim Maas
> University of East Anglia
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] lm without intercept

2011-02-18 Thread Jan
Hello Achim,

> Not quite. Consult your statistics textbook for the correct interpretation 
> of p-values. Under the null hypothesis of a true intercept of zero, it is 
> very likely to observe an intercept as large as 13.52 or larger.
thank you for that help. I suppose the net doesn't have a detailed
explanation of the output of summary.lm for someone with very little
knowledge about statistics? I worked through J. Verzani "simple R" but
it does assume some pre-knowledge.

> > So I repeat the regression forcing the intercept to zero:
> 
> Do you have a good interpretation for that?
In this case, my knowledge of the physical reality behind the numbers
tells me that the intercept should be zero.

> The model without intercept needs to be interpreted differently. The 
> p-value pertains to a regression with intercept zero and slope 0.292 
> against a model with both intercept zero and slope zero.
In other words, of course the slope of 0.292 is almost infinitely better
than a zero slope? But the same would be true for most slopes >0, I
suppose.
So what is the correct way to compare the quality of the regression with
and without intercept? Assuming that I don't know from the physical
reality that the intercept should be zero, what can I say to support one
model against the other?

Thanks,
Jan

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


Re: [R] lm without intercept

2011-02-18 Thread Jan
Hi,

thanks for your help. I'm beginning to understand things better.

> If you plotted your data, you would realize that whether you fit the
> 'best' least squares model or one with a zero intercept, the fit is
> not going to be very good
> Do the data cluster tightly around the dashed line?
No, and that is why I asked the question. The plotted fit doesn't look
any better with or without intercept, so I was surprised that the
R-value etc. indicated an excellent regression (which I now understood
is the wrong interpretation).

One of the references you googled suggests that intercepts should never
be omitted. Is this true even if I know that the physical reality behind
the numbers suggests an intercept of zero?

Thanks,
Jan

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


Re: [R] Boundaries of R

2011-02-18 Thread Duncan Murdoch

On 18/02/2011 5:44 AM, Michael Holt wrote:

Hello Everyone,

I'm pretty new to R and I'm trying to get some idea of the capabilities of
the language. I work with some pretty large data sets and the consensus
seems to be that R does not work well with big data. I've started talking to
the guys at Revolution, but I need to get some outside opinions of what R
can actually handle. At about what size does R start to run into problems?



Vectors are limited to about 2 billion entries (2^31 - 1).  Matrices are 
vectors, so that limit applies to the total count of entries.  
Dataframes are lists of vectors, so that limit applies separately to the 
numbers of rows and columns.


Simple R code keeps everything in memory, so you're likely to run into 
hardware limits if you start working with really big vectors.  There are 
a number of packages that alleviate that by paging data in and out, but 
it takes a bit of work on your part to use them.  As far as I know, 
Revolution offers nothing in this area that isn't on CRAN, but they can 
certainly give you advice.


Duncan Murdoch

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


[R] R script HELP!

2011-02-18 Thread whizevans

The following is my R script which I am struggling with to assess ICESat
data..perhaps it is the ID_min or ID_max that is wrong? I don't know, any
help would be greatly appreciated :(


# OPTIONS - CHANGE THESE VARIABLES IF NEEDED\par
##\par
\par
icesatfile <- 

'C:/Users/Whiz/My_Documents/Year3/GY3072/ICESat_GLAS/IDLreadGLASWF/out_wf_GLA01_09030918_r5947_031_L2E.dat'\par
\par
plotdir <- 'C:/Users/Whiz/My_Documents/Year3/GY3072/ICESat_GLAS/PLOT'\par
\par
\par
\par
ID_min <- 976834501  290018099.3145 1000 #231741042 # specify range of
waveforms to be plotted, -1 means all\par
ID_max <- 976834506  290018101.2895 1000 @@@note only
one ID used @@@\par
\par
\par
\par
noise <- 0.05 # values below NOISE will be disregarded in the waveform
fitting\par
sdthres <- 0.02 # threshold for a standard deviation of volt measurements
indicating the presence of a signal\par
\par
fit_waveform_model <- TRUE # set to TRUE this activates the Gaussian
waveform model fitting and plotting\par
#fit_waveform_select <- c(976834501  290018099.3145 1000)  # gives the
Unique ID for which the model fitting will 

be activated\par
\par
#\par
# END OF OPTIONS\par
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-script-HELP-tp3312644p3312644.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] Boundaries of R

2011-02-18 Thread Mike Marchywka













> Date: Fri, 18 Feb 2011 08:39:05 -0500
> From: murdoch.dun...@gmail.com
> To: mich...@aers.ca
> CC: r-help@r-project.org
> Subject: Re: [R] Boundaries of R
>
> On 18/02/2011 5:44 AM, Michael Holt wrote:
> > Hello Everyone,
> >
> > I'm pretty new to R and I'm trying to get some idea of the capabilities of
> > the language. I work with some pretty large data sets and the consensus
> > seems to be that R does not work well with big data. I've started talking to
> > the guys at Revolution, but I need to get some outside opinions of what R
> > can actually handle. At about what size does R start to run into problems?
> >
>
> Vectors are limited to about 2 billion entries (2^31 - 1). Matrices are
> vectors, so that limit applies to the total count of entries.
> Dataframes are lists of vectors, so that limit applies separately to the
> numbers of rows and columns.
>
> Simple R code keeps everything in memory, so you're likely to run into
> hardware limits if you start working with really big vectors. There are
> a number of packages that alleviate that by paging data in and out, but
> it takes a bit of work on your part to use them. As far as I know,


Do you have more details here? I anticipate working on large data sets
at some point and maybe writing my own packages. I was considering just
writing the things to take file names as source an destination but this
seems a bit restrictive. Also, the "paging" is presumably an issue with local
resources and the algorithm(s). In theory anyway, there could be an interface
that lets the algorithm tell the data struct how it will be accessed. I guess
you could make a factory that builds the right struct if you pass it size info
and some indication or what you hope to do with it but if you need to prefetch
something that should be transparent to user if algorhitms support it. 



> Revolution offers nothing in this area that isn't on CRAN, but they can
> certainly give you advice.
>
> Duncan Murdoch
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R script HELP!

2011-02-18 Thread Jonathan P Daily
It looks to me like when you assign ID_min and ID_max that you want them 
to be vectors. In R, this is accomplished by ?c.

Example:
ID_min <- c(976834501,  290018099.3145, 1000)

--
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
 - Jubal Early, Firefly

r-help-boun...@r-project.org wrote on 02/18/2011 08:21:36 AM:

> [image removed] 
> 
> [R] R script HELP!
> 
> whizevans 
> 
> to:
> 
> r-help
> 
> 02/18/2011 08:49 AM
> 
> Sent by:
> 
> r-help-boun...@r-project.org
> 
> 
> The following is my R script which I am struggling with to assess ICESat
> data..perhaps it is the ID_min or ID_max that is wrong? I don't know, 
any
> help would be greatly appreciated :(
> 
> 
> # OPTIONS - CHANGE THESE VARIABLES IF NEEDED\par
> 
##\par
> \par
> icesatfile <- 
> 
> 'C:/Users/Whiz/My_Documents/Year3/GY3072/ICESat_GLAS/IDLreadGLASWF/
> out_wf_GLA01_09030918_r5947_031_L2E.dat'\par
> \par
> plotdir <- 
'C:/Users/Whiz/My_Documents/Year3/GY3072/ICESat_GLAS/PLOT'\par
> \par
> \par
> \par
> ID_min <- 976834501  290018099.3145 1000 #231741042 # specify range of
> waveforms to be plotted, -1 means all\par
> ID_max <- 976834506  290018101.2895 1000 @@@note 
only
> one ID used @@@\par
> \par
> \par
> \par
> noise <- 0.05 # values below NOISE will be disregarded in the waveform
> fitting\par
> sdthres <- 0.02 # threshold for a standard deviation of volt 
measurements
> indicating the presence of a signal\par
> \par
> fit_waveform_model <- TRUE # set to TRUE this activates the Gaussian
> waveform model fitting and plotting\par
> #fit_waveform_select <- c(976834501  290018099.3145 1000)  # gives the
> Unique ID for which the model fitting will 
> 
> be activated\par
> \par
> 
#\par
> # END OF OPTIONS\par
> -- 
> View this message in context: http://r.789695.n4.nabble.com/R-
> script-HELP-tp3312644p3312644.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Matrix in R

2011-02-18 Thread Dieter Menne


danielepippo wrote:
> 
>I'm building a matrix in R with a cycle for like this:
> pp_ris2=matrix(NA,6,6)
> for(i in 0:6){
> .
> 

R is not like c, indexing starts with 1.

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-in-R-tp3312748p3312764.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] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Claudia Beleites

Dear James,

this is what I understood your sorting along the third dimension to be:
> x <- array(c(9, 9, 7, 9, 6, 5, 4, 6, 2, 1, 3, 2), dim = list(2, 2, 3))

> y <- apply (x, 1:2, sort)
> y
, , 1

 [,1] [,2]
[1,]21
[2,]65
[3,]99

, , 2

 [,1] [,2]
[1,]32
[2,]46
[3,]79


The results of apply are length (result of function) x [shape of x without the 
dimensions you hand to apply).


Thus, your specified result needs rearranging the dimensions:

> y <- aperm (y, c(2, 3, 1))
> y
, , 1

 [,1] [,2]
[1,]23
[2,]12

, , 2

 [,1] [,2]
[1,]64
[2,]56

, , 3

 [,1] [,2]
[1,]97
[2,]99


HTH Claudia

--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

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


Re: [R] Boundaries of R

2011-02-18 Thread Ben Bolker
Mike Marchywka  hotmail.com> writes:


> Duncan Murdoch:
> > Vectors are limited to about 2 billion entries (2^31 - 1). Matrices are
> > vectors, so that limit applies to the total count of entries.
> > Dataframes are lists of vectors, so that limit applies separately to the
> > numbers of rows and columns.
> >
> > Simple R code keeps everything in memory, so you're likely to run into
> > hardware limits if you start working with really big vectors. There are
> > a number of packages that alleviate that by paging data in and out, but
> > it takes a bit of work on your part to use them. As far as I know,
> 
> Do you have more details here? 

 [snip]

  The best starting point is the "high performance computing" task
view on CRAN, which gives an (as far as I know) up-to-date description
of the various packages that are available for handing large/out-of-memory
data sets. Some of these are RDBMS interfaces, some are systems for
file-backed objects, some are large/out-of-memory algorithms such as
lm or glm for big objects.

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


Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Maas James Dr (MED)
Hi Rex,

Thanks, this is exactly what I want but have to do it with many big arrays ... 
thus if there were a way to do it with a vectorized function would it not be a 
lot more efficient?

Much appreciated!

J

>Subject: RE: sort a 3 dimensional array across third dimension ?
>
>Although I suggested to someone else that for-loops be avoided, they are
>not in the inner loop in this code, and it's probably easier to
>understand than some sort of apply:
>
>a = array(round(100*runif(60)),dim=c(3,4,5))
>a
>for (i in 1:dim(a)[1])
> for (j in 1:dim(a)[2])
>  a[i,j,] = sort(a[i,j,])
>a
>
>Is that what you want?
>
>Subject: [R] sort a 3 dimensional array across third dimension ?
>
>I'm attempting to sort a 3 dimensional array that looks like this
>> x
>, , 1
> [,1] [,2]
>[1,]99
>[2,]79
>, , 2
> [,1] [,2]
>[1,]65
>[2,]46
>, , 3
> [,1] [,2]
>[1,]21
>[2,]32
>
>Such that it ends up like this 
>> y
>, , 1
> [,1] [,2]
>[1,]21
>[2,]32
>, , 2
> [,1] [,2]
>[1,]65
>[2,]46
>, , 3
> [,1] [,2]
>[1,]99
>[2,]79
>
>I think this is sorting across the third dimension but several attempts
>using either the sort or apply functions have not worked.  Any and all
>suggestions most welcome.  Thanks
>
>J
>
>===
>Dr. Jim Maas
>University of East Anglia
>

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


Re: [R] Matrix in R

2011-02-18 Thread danielepippo

but if in my function 
pp_ris2[i,j]=myfunction}
must be the indexes 0-0,0-1,0-2,0-3, ?

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-in-R-tp3312748p3312780.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] Matrix in R

2011-02-18 Thread danielepippo

Hi everyone,
   I'm building a matrix in R with a cycle for like this:
pp_ris2=matrix(NA,6,6)
for(i in 0:6){
for(j in 0:6){
if(i>j){
pp_ris2[i,j]=myfunction}
else if(i==j){
print(c(i,j))
pp_ris2[i,j]=myfunction}

}}

but the result is:
  [,1] [,2] [,3][,4]   [,5][,6]
[1,] 0.062   NaNNaNNaN   NaN   NaN
[2,] 0.083  0.022   NaNNaN   NaN   NaN
[3,] 0.072  0.022  0.004   NaN   NaN   NaN
[4,] 0.046  0.016  0.003  0.001  NaN   NaN
[5,] 0.023  0.009  0.002  0.000   0  NaN
[6,] 0.010  0.004  0.001  0.000   00

my problem is in the first column and row because in this matrix there are
not the column and the row with i=0 and j=0. Can anyone help me please?

thanks a lot


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

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


Re: [R] problem running scripts

2011-02-18 Thread jose Bartolomei

 


Dear Uwe,


Thanks for your time.


Definitely something was bugging my script (my mistake).


Since your replay I have been trying to find the bug, to a simple script :( , 
without success.


Preparing a reply to post with data sample and the script, everything start to 
work normally.


Sadly, I still do not know what was. I never get an error message from R. It 
just started to jump functions when I selected the whole script.


The most relevant move, for the fix, was to copy/paste the script to a new 
script page and a change the data.set name. 
 
:| ??


Anyhow, is working again.


I always appreciate the time of this collaborative group.


Thank again,


Jose



 
> Date: Wed, 16 Feb 2011 18:10:21 +0100
> From: lig...@statistik.tu-dortmund.de
> To: surfpr...@hotmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] problem running scripts
> 
> 
> 
> On 14.02.2011 19:58, jose Bartolomei wrote:
> >
> >
> > Dear all,
> >
> >
> > I have encounter an odd situation.
> >
> >
> > I have various R scripts interconnected via the source () function.
> >
> >
> > After examining the results I noticed that not all the functions or 
> > procedures within a script were adequately conducted.
> > Especially with the longest script ( about 180 lines)
> >
> >
> > Then, I ran every scripts individually (not using source () ) selecting all 
> > (Ctrl + a) and running the selection (Ctrl + r).
> >
> >
> > R read every line in my script but, again, not all of the procedures were 
> > executed.
> >
> >
> > For example:
> >
> >
> > X$DATEACCI<-as.Date(X$DATEACCI) stayed as a factor.
> >
> >
> > Or
> >
> > X$AgeG bellow was not created
> >
> >
> > ageg<-c(0, 4, 11, 50, Inf)
> >
> >
> > X$AgeG<-cut(X$AGE, ageg, include.lowest=TRUE,
> > labels=c("0-4", "5-11", "12-50", "51+"))
> >
> >
> >
> >
> > X data.set is approximately dim( 345,000, 33) for year one but I will need 
> > to run the scripts on 10 years.
> >
> >
> > I tried it using attach and the function use() from epicalc but did not 
> > work neither.
> 
> 
> Well, you need to give us a reproducible example, if my following guess 
> is incorrect: You have not looked at the error messages!
> Please report the error messages and whatch out after which lines they 
> appear if you run it as a whole. You certainly made a mistake, but we 
> cannot know.
> 
> Uwe Ligges
> 
> 
> 
> 
> 
> 
> >
> > Nonetheless, if I ran every line of my script individually, everything was 
> > OK.
> >
> >
> >
> >
> > Any insight on this?
> > What I have missed from R Manuals?
> >
> >
> > I am using R 2.12.0 embedded within eclipse Helios via StatET 0.9.1
> >
> >
> > In addition I ran the scripts using R console: 2.12.0, 32 bit (not within 
> > eclipse)
> >
> >
> > I conducted the same procedure in two different HP Z400 running in Window 
> > 7, 4Gb of RAM
> >
> >
> > I'll try under Linux in my home, if different I'll report it.
> >
> >
> > Thanks,
> >
> >
> > Jose
> >
> > 
> > [[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] ERGM + Anova

2011-02-18 Thread Roger Gomes

Hi All,

I would like to know where to find technical papers to how calculate ANOVA
using ERGM. Which parameters and so on. Thanks.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/ERGM-Anova-tp3312792p3312792.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] variance of model delta glm

2011-02-18 Thread Melen
hi everybody,

i know it a quite complicate subject but someone might have the
solution.

I am doing a delta model coupling a binomial glm and a lognormal one.
Using the Laurent correction I can predict mean values and I would
like to know if you know how to predict the variance?

Do you know the true formula and the good code for it?

Thanks in advance
Melen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plot3d, color points by group

2011-02-18 Thread Kari
Hello

I've created a 3d scatterplot, and had no problems labeling the points.
However, I've been really struggling to change the color of the points based
on a factor (see 'group' below).  Is such a thing possible?

My data look like this:

food group  x  y  z
apple  fruit  0.216 -0.112 -0.893
orange fruit  0.814  0.097  0.460
broccoli veg -0.239  0.240 -0.425
banana  fruit  0.222  0.968 -0.050
parsnip  veg  0.139  0.897  0.378
garlic veg -0.104  0.510 -0.400

pca <-  read.table(...
p3d<- plot3d(pca$x, pca$y, pca$z, xlab="Component 1", ylab="Component 2",
zlab="Component 3", col="blue",box=FALSE, size=5)
food.v<-as.vector(pca$food)
text3d(pca$x, pca$y, pca$z, food.v, cex=0.9, adj = 1)

Many thanks,
Leigh

[[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] Weights in bagged regression trees

2011-02-18 Thread Simon Gillings
Has anyone any experience of applying observational weights in bagging? I am 
performing regression trees (continuous data on bird abundance) and need to 
account for sampling intensity. In a single tree, i.e. a call of rpart, I can 
specify weights either by having a separate vector called weights, or by a 
variable called weights in the dataframe under analysis. Both produce sensible 
(and identical) output. These results are different to an rpart call without a 
weights argument and appears to be working as expected.

However, if I analyse these data with a bagging call with a weights argument 
the model runs instantaneously and the output produced is empty; no error 
messages or warnings are generated. This happens whether the weights are within 
the dataframe or in a separate vector. Even assigning the weights in the 
bagging call (weights <-1) produces empty output. If I run the data without the 
weights argument I get sensible output. 

Despite being possible in rpart, are case weights not possible in bagging? I 
know that weights are not possible in regression under randomforests.

#this works
r1w <- rpart(how_many ~ covariates, data=ttv.data.sk, weights, method="poisson")

#this works
b1 <- bagging(how_many ~ covariates, data=ttv.data.sk, method="poisson", 
coob=T, nbagg=30)

#this fails
b1w <- bagging(how_many ~ covariates, data=ttv.data.sk, weights, 
method="poisson", coob=T, nbagg=30)

thanks in advance

Simon

Sign-up for Bird Atlas 2007-11 at www.birdatlas.net

Dr Simon Gillings
Senior Research Ecologist - Land Use
British Trust for Ornithology
The Nunnery, Thetford, Norfolk, IP24 2PU, UK
Tel +44(0)1842 750050 Fax +44(0)1842 750030
Charity No 216652 (England and Wales)
Company Limited by Guarantee No 357284 (England and Wales)
Registered Office The Nunnery, Thetford, Norfolk IP24 2PU
[[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] speed up the code

2011-02-18 Thread rex.dwyer
Yes, remove the call to intersect, and rely on the results of match to tell you 
whether there is an overlap.  If there are any matches,  all(is.na(index)) will 
be false.  Read help for match.

?match


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Hui Du
Sent: Wednesday, February 16, 2011 6:29 PM
To: r-help@r-project.org
Subject: [R] speed up the code


Hi All,

The following is a snippet of my code. It works fine but it is very slow. Is it 
possible to speed it up by using different data structure or better solution? 
For 4 runs, it takes 8 minutes now. Thanks a lot



fun_activation = function(s_k, s_hat, x_k, s_hat_len)
{
common = intersect(s_k, s_hat);
if(length(common) != 0)
{
index  = match(common, s_k);
round(sum(x_k[index]) * length(common) / (s_hat_len * length(s_k)), 3);
}
else
{
0;
}

}

fun_x = function(a)
{
round(runif(length(a), 0, 1), 2);
}

symbol_len = 50;
PHI_set = 1:symbol_len;

S = matrix(replicate(M * M, sort(sample(PHI_set, sample(symbol_len, 1, M, 
M);
X = matrix(mapply(fun_x, S), M, M);

S_hat = c(28, 34, 35)
S_hat_len = length(S_hat);

  S_hat_matrix = matrix(list(S_hat), M, M);

system.time(
for(I in 1:4)
{
A = matrix(mapply(fun_activation, S, S_hat_matrix, X, S_hat_len), M, M);
}
)



HXD


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




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] calculating means

2011-02-18 Thread Mike Gibson

I apologize if you have already seen my question.  I am new to the mailing list 
and I did not get any responses the first time I posted my question.  However, 
I am not sure my post went through.  
 
Here is my situation:  
I have a spreadsheet with columns of fish species (text) and length (numbers).  
In the fish species column I have 5 different fish.  I want R to calculate the 
mean length and standard error for each species. 
  
I tried using the stats functin with 
stats(fishdata, by=species) 
  
R told me it could not find function stats.  Is there a library I need to 
install to get stats to work? 
 
Mike  
[[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] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread rex.dwyer
Although I suggested to someone else that for-loops be avoided, they are not in 
the inner loop in this code, and it's probably easier to understand than some 
sort of apply:

a = array(round(100*runif(60)),dim=c(3,4,5))
a
for (i in 1:dim(a)[1])
 for (j in 1:dim(a)[2])
  a[i,j,] = sort(a[i,j,])
a

Is that what you want?

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Maas James Dr (MED)
Sent: Friday, February 18, 2011 8:01 AM
To: r-help@r-project.org
Subject: [R] sort a 3 dimensional array across third dimension ?

I'm attempting to sort a 3 dimensional array that looks like this
> x
, , 1
 [,1] [,2]
[1,]99
[2,]79
, , 2
 [,1] [,2]
[1,]65
[2,]46
, , 3
 [,1] [,2]
[1,]21
[2,]32

Such that it ends up like this 
> y
, , 1
 [,1] [,2]
[1,]21
[2,]32
, , 2
 [,1] [,2]
[1,]65
[2,]46
, , 3
 [,1] [,2]
[1,]99
[2,]79

I think this is sorting across the third dimension but several attempts using 
either the sort or apply functions have not worked.  Any and all suggestions 
most welcome.  Thanks

J

===
Dr. Jim Maas
University of East Anglia


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




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] {Spam?} Re: sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Claudia Beleites

On 02/18/2011 04:11 PM, Maas James Dr (MED) wrote:

Hi Claudia,

It does help a lot, but not quite there yet ... I'm sure you are correct and
is much appreciated, I need some sort of generalized form, actual arrays in
my case are 3x3x1000.  Do you suspect it could be done in one step with
sapply?

Why sapply?

Sure you can to it in one step:
y<- aperm (apply (x, 1:2, sort), c(2, 3, 1))
I just think two lines are more readable.

Note that all these numbers are the "directions" of the array and don't have 
anything to do with the actual size. Just try it out with different array sizes.


> a <- array (runif (9000), c (3, 3, 1000))
> a [,,1:2]
, , 1

   [,1]   [,2][,3]
[1,] 0.8721 0.5102 0.47370
[2,] 0.7721 0.5744 0.98281
[3,] 0.9357 0.1969 0.08784

, , 2

   [,1]   [,2]   [,3]
[1,] 0.1485 0.6878 0.1018
[2,] 0.3784 0.3864 0.9814
[3,] 0.9219 0.5664 0.4565

> y<- aperm (apply (a, 1:2, sort), c(2, 3, 1))
> y [,,1:2]
, , 1

  [,1]  [,2]  [,3]
[1,] 1.121e-03 1.517e-03 0.0008285
[2,] 7.118e-05 3.303e-04 0.0003870
[3,] 7.445e-04 2.461e-05 0.0005980

, , 2

 [,1]  [,2] [,3]
[1,] 0.001375 0.0049272 0.004581
[2,] 0.002204 0.0004947 0.001148
[3,] 0.004214 0.0006355 0.001610

> y [,,999:1000]
, , 1

   [,1]   [,2]   [,3]
[1,] 0.9989 0.9980 0.9998
[2,] 0.9982 0.9973 0.9994
[3,] 0.9994 0.9978 0.9993

, , 2

   [,1]   [,2]   [,3]
[1,] 0.9997 0.9992 0.
[2,] 0.9986 0.9981 0.9997
[3,] 0.9998 0.9988 0.9996


BTW: as your MARGINS are short, only 3 x 3 = 9 calls to FUN are necessary. I 
don't think you can gain much time here. The calculation with 3 x 3 x 1000 on my 
computer had 3 ms elapsed, and increasing every direction by a factor of 10 
still needs 1/3 s.




Claudia





Regards

J


=== Dr. Jim Maas Research Associate in Network
Meta-Analysis School of Medicine, Health Policy and Practice CD Annex, Room
1.04 University of East Anglia Norwich, UK NR4 7TJ

+44 (0) 1603 591412



From: Claudia Beleites [mailto:cbelei...@units.it]

Dear James,

this is what I understood your sorting along the third dimension to be:

x<- array(c(9, 9, 7, 9, 6, 5, 4, 6, 2, 1, 3, 2), dim = list(2, 2,

3))


y<- apply (x, 1:2, sort) y

, , 1

[,1] [,2] [1,]21 [2,]65 [3,]99

, , 2

[,1] [,2] [1,]32 [2,]46 [3,]79


The results of apply are length (result of function) x [shape of x without
the dimensions you hand to apply).

Thus, your specified result needs rearranging the dimensions:


y<- aperm (y, c(2, 3, 1)) y

, , 1

[,1] [,2] [1,]23 [2,]12

, , 2

[,1] [,2] [1,]64 [2,]56

, , 3

[,1] [,2] [1,]97 [2,]99


HTH Claudia

-- Claudia Beleites Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste Via Alfonso Valerio 6/a I-34127 Trieste

phone: +39 0 40 5 58-37 68 email: cbelei...@units.it



--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

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


Re: [R] R script HELP!

2011-02-18 Thread whizevans

OK thanks Jonathon, I will have a go.
Is the plotdir file technically my output file? Or what is this otherwise?

Also, having never used R script before, is it not very good at reading
data, may I have to alter my input file in excel first?
Thanks


-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-script-HELP-tp3312644p3312898.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] calculating means

2011-02-18 Thread Bert Gunter
Have you read an Intro to R or, indeed, any R documentation? Perhaps
you received no reply because you do not appear to have made an honest
effort to answer the question for yourself. Maybe you should consider
accessing R thru R Commander or one of the other R GUI's -- search
CRAN for details.

-- Bert

On Fri, Feb 18, 2011 at 6:45 AM, Mike Gibson  wrote:
>
> I apologize if you have already seen my question.  I am new to the mailing 
> list and I did not get any responses the first time I posted my question.  
> However, I am not sure my post went through.
>
> Here is my situation:
> I have a spreadsheet with columns of fish species (text) and length 
> (numbers).  In the fish species column I have 5 different fish.  I want R to 
> calculate the mean length and standard error for each species.
>
> I tried using the stats functin with
> stats(fishdata, by=species)
>
> R told me it could not find function stats.  Is there a library I need to 
> install to get stats to work?
>
> Mike
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Variogram (nlme) of a lme object - corSpatial element question

2011-02-18 Thread Arnaud Mosnier
Dear Users,

>From previous analysis (semi-variograms using package gstat), I found
spatial autocorrelation in my dataset.
The best fitted model to this spatial correlation structure is the Gaussian
model (Spherical, Exponential, Linear tested and comparison done by Sum of
Square errors).
So I used corGaus function to define this spatial autocorrelation in my lme
model using the option "correlation".

The Variogram function (package nlme) used on a lme object calculates the
semi-variogram for the within-group residuals and add the semi-variogram of
the corSpatial element (corGaus in my case) included in my model ... so far
no problem.

I was surprised, however, to see on the plot of the semi-variogram issued
from the Variogram function, (see figure at http://imm.io/3OLe) the low
range value (~1600 meters) used in the corGaus structure included in the lme
object.
When I fitted the same corGaus structure manually or using the fit.variogram
function (package gstat) on the data of each group defined in lme, it gaves
me ranges between 2050 and 2700 meters (mean 2350 meters).

Can anyone explain me those differences ?

Note: As I mentioned in a previous message (
http://markmail.org/message/gjgag4ohjopevgax), I tried to define a different
range in the corGaus function directly in the lme function, but it is not
taken into account.

Arnaud

[[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] Matrix in R

2011-02-18 Thread Philipp Pagel
On Fri, Feb 18, 2011 at 06:32:01AM -0800, danielepippo wrote:
> 
> but if in my function 
> pp_ris2[i,j]=myfunction}
> must be the indexes 0-0,0-1,0-2,0-3, ?

You'll have to take care of that yourself with a bit of index
arithmetics. It's  the same you encounter in C, if you are
modelling something that would like to be indexed starting with 1 -
just the other way round.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


Re: [R] ERGM + Anova

2011-02-18 Thread Bert Gunter
What does this have to do with R?
-- Bert

On Fri, Feb 18, 2011 at 6:37 AM, Roger Gomes  wrote:
>
> Hi All,
>
> I would like to know where to find technical papers to how calculate ANOVA
> using ERGM. Which parameters and so on. Thanks.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/ERGM-Anova-tp3312792p3312792.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.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml

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


Re: [R] Matrix in R

2011-02-18 Thread David Winsemius


On Feb 18, 2011, at 9:32 AM, danielepippo wrote:



but if in my function
pp_ris2[i,j]=myfunction}
must be the indexes 0-0,0-1,0-2,0-3, ?



From a search of RSiteSearch() that started with with terms:  zero  
matrix indexing


http://finzi.psych.upenn.edu/R/Rhelp02/archive/39031.html
http://finzi.psych.upenn.edu/R/Rhelp02/archive/26476.html
http://finzi.psych.upenn.edu/R/Rhelp02/archive/32960.html



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



--
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] Matrix in R

2011-02-18 Thread David Winsemius


On Feb 18, 2011, at 9:32 AM, danielepippo wrote:



but if in my function
pp_ris2[i,j]=myfunction}
must be the indexes 0-0,0-1,0-2,0-3, ?


I came across a posting in r-help that called this package "blasphemy":

http://cran.r-project.org/web/packages/Oarray/index.html




--

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] Bug in the function Variogram (package nlme) ?

2011-02-18 Thread Arnaud Mosnier
Dears UseRs,

In Zuur's book (Mixed effects models and extensions in ecology with R), p
167, it is mentionned that the Variogram function (package nlme) scale the
sill to 1.
Here is the plot of the semi-variogram given by the Variogram function on my
"lme" object. (http://imm.io/3OLe)
Note that the semi-variance exceed 1 !!

It can probably explain why the Gaussian correlation structure fitted in my
"lme" model is strange (curve is probably fitted to the data above 1).
See my previous message a few minutes ago untitled "Variogram (nlme) of a
lme object - corSpatial element question."

I don't know if it is a bug, but Implications could be important for model
fitted with a spatial correlation structure.

Arnaud

[[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] R script HELP!

2011-02-18 Thread Jonathan P Daily
Well, this script only shows the option settings, so I assumed that the 
string being used as your infile was formatted for R. As for how it will 
have to look for R to read it in, there are many ways to do this - I would 
start by reading "R Data Import/Export" that ships with every copy of R. 
As for scripts and their default writing methods AFAIR Rscript writes to 
stdout, though if you want it to save your modified data in some other 
format than a text dump, look at the various methods of exporting data... 
again in the aforementioned "R Data Import/Export".
--
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
 - Jubal Early, Firefly

r-help-boun...@r-project.org wrote on 02/18/2011 10:29:55 AM:

> [image removed] 
> 
> Re: [R] R script HELP!
> 
> whizevans 
> 
> to:
> 
> r-help
> 
> 02/18/2011 11:06 AM
> 
> Sent by:
> 
> r-help-boun...@r-project.org
> 
> 
> OK thanks Jonathon, I will have a go.
> Is the plotdir file technically my output file? Or what is this 
otherwise?
> 
> Also, having never used R script before, is it not very good at reading
> data, may I have to alter my input file in excel first?
> Thanks
> 
> 
> -- 
> View this message in context: http://r.789695.n4.nabble.com/R-
> script-HELP-tp3312644p3312898.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Dependency on R-Forge Package

2011-02-18 Thread Spencer Graves
  I echo Prof. Ripley's and Jari Oksanen's concerns.  I see two 
options in case the R-Forge package maintainer does not submit the 
package to CRAN:



(1) Copy the function(s) you want from that package into 
your own.  In such cases, I recommend you change the name of the 
function slightly to avoid confusion regarding which version of a 
function to use.  Failing to do this can lead to problems that are 
difficult to diagnose.  Later, if and when the desired non-CRAN package 
is released, you can replace your copy with a dummy function that just 
calls the function in the other package.  This allows you to offer your 
users more "trustworthy software" (Chambers, 2008, Software for Data 
Analysis, Springer).



(2) List it as "suggests" in your DESCRIPTION file and 
precede each use with "if(require(desiredR_ForgePackage))".  If 
"require" returns TRUE, you do what you want.  Else issue an error message.



  Hope this helps.
  Spencer
p.s.  I've had reasonably good luck writing package maintainers, 
including being invited to co-author a book.  More commonly, I've been 
added as a developer on their project, accelerating the release to CRAN 
with minor extensions of their code that I suggested.  I've also had the 
opposite experience, namely being told to develop my own package 
separate from theirs, which I did.



On 2/18/2011 1:34 AM, Jari Oksanen wrote:

Damian Betebenner  nciea.org>  writes:


In building a package, is it possible to make the package depend upon another

package that is only available

on R-Forge (not CRAN). For example, by doing something in the DESCRIPTION file
I'd like to add a dependency to my package such that when the user install my

package it will automatically

install this other package from R-forge as well.


Not strictly my business, but as an R-Forge developer I say that you should not
depend on a pacakge in R-Forge. If a package is in the R-Forge it probably is
(a) not ready for release, or (b) unstable, or (c) both. This means that you
should not depend on the package.

If you think that neither of these is true, but the package is both ready for
the release and stable, you should urge its developer to release (a stable
version of) the package in CRAN.

Cheers, Jari Oksanen

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



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


[R] How to flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
Hi,

I am running a simulation study with the survival::coxph.  Some of the 
simulations result in problematic fits due to flat partial likelihood. So, you 
get the warning message:

Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights,  ... :
  Loglik converged before variable  2 ; beta may be infinite. 

How can I keep track of the simulations which yield any kind of warning 
message, so that I can appropriately handle them in the post-processing of 
simulation results?

I know that `try' can be used to capture errors, but I would like to capture 
and detect warnings.

Any pointers would be appreciated.

Thanks,
Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.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] How to flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
May be I could do:

for (i in 1:nsim) {

last.warning <- NULL

# do model fitting

if(!is.null(last.warning)) # discard simulation result

}

I think this might work.  Any other ideas?

Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Ravi Varadhan 
Date: Friday, February 18, 2011 11:29 am
Subject: [R] How to flag those iterations which yield a warning?
To: r-help@r-project.org


> Hi,
>  
>  I am running a simulation study with the survival::coxph.  Some of 
> the simulations result in problematic fits due to flat partial 
> likelihood. So, you get the warning message:
>  
>  Warning message:
>  In fitter(X, Y, strats, offset, init, control, weights = weights,  
> ... :
>Loglik converged before variable  2 ; beta may be infinite. 
>  
>  How can I keep track of the simulations which yield any kind of 
> warning message, so that I can appropriately handle them in the 
> post-processing of simulation results?
>  
>  I know that `try' can be used to capture errors, but I would like to 
> capture and detect warnings.
>  
>  Any pointers would be appreciated.
>  
>  Thanks,
>  Ravi.
>  
>  
>  Ravi Varadhan, Ph.D.
>  Assistant Professor,
>  Division of Geriatric Medicine and Gerontology
>  School of Medicine
>  Johns Hopkins University
>  
>  Ph. (410) 502-2619
>  email: rvarad...@jhmi.edu
>  
>  __
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  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] heatmap & cluster

2011-02-18 Thread Duke

Hi all,

I am new to heatmap function in stats package, so any advice will be 
greatly appreciated. So I have a dataset that I want to draw a heatmap, 
for example:


> dput(a)
structure(c(-8.256023, -14.764429, -10.145779, -5.123104, -11.974729,
-16.329029, -16.329029, -16.329029, -2.764114, -4.924921, -7.321333,
-2.126415, -2.854843, -12.222569, -12.259916, -16.329029, -9.313669,
-16.329029, -5.094692, -12.732754, -11.327074, -16.329029, -15.172729,
-10.447779, -14.086353, -16.329029, -10.383026, -3.319923, -14.463295,
-16.329029, -8.449667, -8.253173, -13.481955, -9.660365, -5.394456,
-11.934001, -16.294595, -16.294595, -14.250207, -2.62437, -4.644073,
-7.067632, -2.445758, -2.948815, -12.52094, -12.514855, -16.294595,
-9.087692, -16.294595, -4.850505, -12.895911, -11.067373, -16.294595,
-14.268018, -10.069949, -13.807715, -13.527525, -10.316585, -3.417455,
-14.623739, -16.294595, -8.502865, -10.403515, -15.2687, -8.355925,
-6.885027, -13.231369, -16.198643, -16.198643, -15.764126, -3.919298,
-4.499501, -9.05365, -3.968495, -4.655705, -13.426923, -14.570927,
-16.198643, -7.830833, -16.198643, -7.067999, -15.453797, -11.583553,
-16.198643, -14.172943, -12.111882, -16.198643, -16.198643, -12.738674,
-4.654217, -16.198643, -16.198643, -7.265043, -9.8028525, -13.7499485,
-8.2308125, -6.5919095, -12.6615125, -16.2597525, -15.1882525,
-15.3079125, -3.8327565, -4.2444845, -8.6616275, -3.4870585,
-4.7037395, -13.5807625, -13.7311925, -16.2597525, -6.9568865,
-16.2597525, -6.8470535, -15.1680125, -11.4887425, -16.2597525,
-16.2597525, -12.7272155, -16.2597525, -14.2869125, -12.5119475,
-4.5236895, -16.2597525, -16.2597525, -7.0275195, -8.9830315,
-13.0446825, -8.1959965, -4.6491995, -11.9283305, -16.9771775,
-16.9771775, -13.7994815, -4.4080155, -1.6757765, -7.9315575,
-3.2130445, -3.4857205, -13.1048685, -13.9564575, -16.9771775,
-6.1871915, -16.9771775, -4.3551415, -12.0167665, -10.7453525,
-16.9771775, -16.0470245, -12.0249945, -15.4854135, -13.3358695,
-10.0600285, -4.0888575, -13.4507575, -16.9771775, -8.9060255,
-8.634967, -13.750961, -8.435369, -4.731479, -11.715743, -16.752252,
-16.752252, -12.963094, -4.4797, -1.463899, -7.906436, -3.152959,
-3.391109, -12.930829, -14.488798, -16.752252, -6.469909, -15.831212,
-4.433538, -12.227548, -11.186935, -16.752252, -14.044114, -11.980335,
-14.957818, -11.995889, -9.870448, -3.886888, -12.473371, -16.752252,
-8.724162, -8.7089345, -12.8237805, -8.8060835, -5.3402075, -12.1008855,
-16.5511075, -16.5511075, -13.0755235, -2.8258155, -3.5159225,
-7.8480855, -3.4192395, -3.9034425, -12.3911935, -12.8279675,
-16.5511075, -6.1173955, -16.5511075, -5.5393875, -13.1495495,
-10.5958215, -16.5511075, -14.3079245, -11.4168585, -14.5230275,
-12.2255155, -10.8862915, -3.6071265, -11.2295815, -16.5511075,
-9.0285975, -8.718233, -12.411424, -8.425561, -5.109361, -12.150056,
-16.541389, -16.541389, -12.836315, -2.687709, -3.469224, -7.879879,
-3.214229, -3.658531, -12.144212, -12.668222, -16.541389, -6.090829,
-16.541389, -5.342092, -12.970741, -10.186492, -14.869239, -16.387516,
-11.085016, -14.030487, -13.375982, -10.042753, -3.512882, -11.498157,
-16.541389, -8.946685), .Dim = c(31L, 8L), .Dimnames = list(NULL,
c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8")))

If I do
> heatmap(a)
then I think this heatmap shows the data clustered along columns and 
along rows separately. The question is: how do I cluster data a along 
the columns first, then cluster along the rows of row-clustered data of 
a, and then draw the heatmap?


Thank you very much in advance,

D.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
Nope - that does not work.  The value of last.warning is not reset after the 
initial NULL.

Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Ravi Varadhan 
Date: Friday, February 18, 2011 11:35 am
Subject: Re: [R] How to flag those iterations which yield a warning?
To: Ravi Varadhan 
Cc: r-help@r-project.org


> May be I could do:
>  
>  for (i in 1:nsim) {
>  
>  last.warning <- NULL
>  
>  # do model fitting
>  
>  if(!is.null(last.warning)) # discard simulation result
>  
>  }
>  
>  I think this might work.  Any other ideas?
>  
>  Ravi.
>  
>  
>  
>  Ravi Varadhan, Ph.D.
>  Assistant Professor,
>  Division of Geriatric Medicine and Gerontology
>  School of Medicine
>  Johns Hopkins University
>  
>  Ph. (410) 502-2619
>  email: rvarad...@jhmi.edu
>  
>  
>  - Original Message -
>  From: Ravi Varadhan 
>  Date: Friday, February 18, 2011 11:29 am
>  Subject: [R] How to flag those iterations which yield a warning?
>  To: r-help@r-project.org
>  
>  
>  > Hi,
>  >  
>  >  I am running a simulation study with the survival::coxph.  Some of 
> 
>  > the simulations result in problematic fits due to flat partial 
>  > likelihood. So, you get the warning message:
>  >  
>  >  Warning message:
>  >  In fitter(X, Y, strats, offset, init, control, weights = weights,  
> 
>  > ... :
>  >Loglik converged before variable  2 ; beta may be infinite. 
>  >  
>  >  How can I keep track of the simulations which yield any kind of 
>  > warning message, so that I can appropriately handle them in the 
>  > post-processing of simulation results?
>  >  
>  >  I know that `try' can be used to capture errors, but I would like 
> to 
>  > capture and detect warnings.
>  >  
>  >  Any pointers would be appreciated.
>  >  
>  >  Thanks,
>  >  Ravi.
>  >  
>  >  
>  >  Ravi Varadhan, Ph.D.
>  >  Assistant Professor,
>  >  Division of Geriatric Medicine and Gerontology
>  >  School of Medicine
>  >  Johns Hopkins University
>  >  
>  >  Ph. (410) 502-2619
>  >  email: rvarad...@jhmi.edu
>  >  
>  >  __
>  >  R-help@r-project.org mailing list
>  >  
>  >  PLEASE do read the posting guide 
>  >  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 flag those iterations which yield a warning?

2011-02-18 Thread David Winsemius


On Feb 18, 2011, at 11:35 AM, Ravi Varadhan wrote:


May be I could do:

for (i in 1:nsim) {

last.warning <- NULL

# do model fitting

if(!is.null(last.warning)) # discard simulation result


You can raise warnings to behave as errors with options:

options(warn=2)

And you can define where R goes on error with

options(error=  ... some function

?options

?utils::recover



I think this might work.  Any other ideas?

Ravi.



Ravi Varadhan, Ph.D.

Hi,

I am running a simulation study with the survival::coxph.  Some of
the simulations result in problematic fits due to flat partial
likelihood. So, you get the warning message:

Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights,
... :
  Loglik converged before variable  2 ; beta may be infinite.

How can I keep track of the simulations which yield any kind of
warning message, so that I can appropriately handle them in the
post-processing of simulation results?

I know that `try' can be used to capture errors, but I would like to
capture and detect warnings.

Any pointers would be appreciated.

Thanks,
Ravi.


Ravi Varadhan, Ph.D.


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] How to flag those iterations which yield a warning?

2011-02-18 Thread William Dunlap
If you have a function that may produce warnings you
can use withCallingHandlers() to make a new function
that does what the original does but adds some
contextual information to the usual warning report.
E.g.,

addWarningReporting <- function(FUN) {
   force(FUN)
   function(args) {
  withCallingHandlers(
 FUN(args),
 warning=function(w){
 cat("WARNING: ")
 print(w)
 cat("args=", deparse(args), "\n")
 invokeRestart("muffleWarning")}
  )
   }
}

> for(i in -2:2) log(i)
Warning messages:
1: In log(i) : NaNs produced
2: In log(i) : NaNs produced
> myLog <- addWarningReporting(log)
> for(i in -2:2) myLog(i)
WARNING: 
args= -2L
WARNING: 
args= -1L

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Varadhan
> Sent: Friday, February 18, 2011 8:29 AM
> To: r-help@r-project.org
> Subject: [R] How to flag those iterations which yield a warning?
> 
> Hi,
> 
> I am running a simulation study with the survival::coxph.  
> Some of the simulations result in problematic fits due to 
> flat partial likelihood. So, you get the warning message:
> 
> Warning message:
> In fitter(X, Y, strats, offset, init, control, weights = 
> weights,  ... :
>   Loglik converged before variable  2 ; beta may be infinite. 
> 
> How can I keep track of the simulations which yield any kind 
> of warning message, so that I can appropriately handle them 
> in the post-processing of simulation results?
> 
> I know that `try' can be used to capture errors, but I would 
> like to capture and detect warnings.
> 
> Any pointers would be appreciated.
> 
> Thanks,
> Ravi.
> 
> 
> Ravi Varadhan, Ph.D.
> Assistant Professor,
> Division of Geriatric Medicine and Gerontology
> School of Medicine
> Johns Hopkins University
> 
> Ph. (410) 502-2619
> email: rvarad...@jhmi.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] calculating means

2011-02-18 Thread David Winsemius


On Feb 18, 2011, at 9:45 AM, Mike Gibson wrote:



I apologize if you have already seen my question.  I am new to the  
mailing list and I did not get any responses the first time I posted  
my question.  However, I am not sure my post went through.


It didn't.


Here is my situation:
I have a spreadsheet with columns of fish species (text) and length  
(numbers).  In the fish species column I have 5 different fish.  I  
want R to calculate the mean length and standard error for each  
species.


I tried using the stats functin with
stats(fishdata, by=species)

R told me it could not find function stats.  Is there a library I  
need to install to get stats to work?


"stats" is a rather fundamental package that is loaded by default when  
R starts up, while "mean" is a function in  the base package.


> ?mean
> help(package=stats)

It's possible that "stats" is also a function in some other package,  
but you have not told us why you think so. I can tell you that (at  
least) 5 different packages have a "describe" function and the base  
package has "summary".


> RSiteSearch("stats")

Unfortunately that is not a productive answer to your questions, since  
it provides more than 1500 hits, not too surprising I suppose since  
this is a "stats" program.


And  please pay careful attention to the list sig.
--

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] fit a distribution

2011-02-18 Thread Simone Gabbriellini
hello list,

I have this array of distribution of frequencies:

freq<-c(45,18,10,8,13,5,9,3,4,1,2,2,2,3,4,4,1,1,2,1,2,1,1,1,1,1,2,3,1,1,1,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

for this array of values:

values<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,19,20,21,24,25,26,27,28,29,32,34,35,37,39,40,42,43,44,45,46,54,61,66,70,72,75,78,80,87,90,95,101,110,169,175,193,204,209,218,269,284,290,299,310,345,403,506,520,523,842,981,1034)

I would like to fit this distribution with a theoretical model, and i need a 
help to select the best one... is this an example of Zipf's law? 

thanks in advance for any help.

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


Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread jamaas

Thanks Claudia (and all others!0

This works beautifully!  The instructions for aperm are a bit vauge!

J
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sort-a-3-dimensional-array-across-third-dimension-tp3312612p3313126.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] hdf5 library install issue

2011-02-18 Thread Jerome

Dear all

I'm trying to install the hdf5 library into R. The HDF5 package is 
installed in a special directory, distributed accross my cluster: 
/share/apps/HDF5


So i put the args option to the configure command as i read in previous 
post in the list:


jerome]# R CMD INSTALL --configure-vars='LDFLAGS=-L/share/apps/HDF5/lib' 
--configure-args='--with-hdf5=/share/apps/HDF5' hdf5_1.6.9.tar.gz


* installing to library '/share/apps/R-core-2.12.1_SHLIB/lib64/R/library'
* installing *source* package 'hdf5' ...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for library containing inflate... -lz
checking for library containing H5open... -lhdf5
checking for sufficiently new HDF5... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/share/apps/R-core-2.12.1_SHLIB/lib64/R/include 
-I/share/apps/HDF5/include -I/usr/local/include-fpic  -g -O2 -c 
hdf5.c -o hdf5.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o hdf5.so hdf5.o 
-Wl,-rpath,/share/apps/HDF5/lib -lhdf5 -lz -lm 
-L/share/apps/R-core-2.12.1_SHLIB/lib64/R/lib -lR

/usr/bin/ld: cannot find -lhdf5
collect2: ld returned 1 exit status
make: *** [hdf5.so] Error 1
ERROR: compilation failed for package 'hdf5'
* removing '/share/apps/R-core-2.12.1_SHLIB/lib64/R/library/hdf5'


So, the problem is taht the configure don't use in a correct way the 
option "--with-hdf5", and neither the other configure-vars option.


How can i do to have this library usable in R?

Regards

--
-- Jérôme
Si quelqu'un vous dit : "Je me tue à vous le répéter",
laissez-le mourir.
   (Jacques Prévert)

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


Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread rex.dwyer
I was going to say:

The problem with for-loops (as best I understand it) is that the R code gets 
interpreted over and over; what you normally want to do is design the 
computation so that you jump into the internals of R and stay there.  But the 
inner loop is in the R internals of the sort in this case. If the third 
dimension is even just moderately large, the cost of interpretation is small 
relative to the cost of the sort.

But my quick experiments don't exactly bear that out:

> foo = runif(1)
> system.time(for (i in 1:1000) sort(foo))
   user  system elapsed
   1.600.001.61
> system.time(for (i in 1:1000) for (j in 1:1) k=k+1)
   user  system elapsed
   7.520.007.54

I imagine I could find a prettier way with various flavors of apply, if my 
employer didn't have other things for me to do.

Maybe someone else can explain why the for loop is so slow that the overhead to 
increment the index is greater than sorting 1 doubles.  I know it used to 
be even slower in splus than in R.


-Original Message-
From: Maas James Dr (MED) [mailto:j.m...@uea.ac.uk]
Sent: Friday, February 18, 2011 10:06 AM
To: Dwyer Rex USRE; r-help@r-project.org
Subject: RE: sort a 3 dimensional array across third dimension ?

Hi Rex,

Thanks, this is exactly what I want but have to do it with many big arrays ... 
thus if there were a way to do it with a vectorized function would it not be a 
lot more efficient?

Much appreciated!

J

>Subject: RE: sort a 3 dimensional array across third dimension ?
>
>Although I suggested to someone else that for-loops be avoided, they are
>not in the inner loop in this code, and it's probably easier to
>understand than some sort of apply:
>
>a = array(round(100*runif(60)),dim=c(3,4,5))
>a
>for (i in 1:dim(a)[1])
> for (j in 1:dim(a)[2])
>  a[i,j,] = sort(a[i,j,])
>a
>
>Is that what you want?
>
>Subject: [R] sort a 3 dimensional array across third dimension ?
>
>I'm attempting to sort a 3 dimensional array that looks like this
>> x
>, , 1
> [,1] [,2]
>[1,]99
>[2,]79
>, , 2
> [,1] [,2]
>[1,]65
>[2,]46
>, , 3
> [,1] [,2]
>[1,]21
>[2,]32
>
>Such that it ends up like this 
>> y
>, , 1
> [,1] [,2]
>[1,]21
>[2,]32
>, , 2
> [,1] [,2]
>[1,]65
>[2,]46
>, , 3
> [,1] [,2]
>[1,]99
>[2,]79
>
>I think this is sorting across the third dimension but several attempts
>using either the sort or apply functions have not worked.  Any and all
>suggestions most welcome.  Thanks
>
>J
>
>===
>Dr. Jim Maas
>University of East Anglia
>




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ERGM + Anova

2011-02-18 Thread Roger Gomes

Hi Bert, thanks about your answer.

Well, I would like to calculate anova.ergm in R. Wich values (edges,
vertices) the library use to calculate F values or p-value with  graphos.

The calculus is like a Pandora Box... I put there a network (ergm) and then,
values show me like a magic.

Do you know?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/ERGM-Anova-tp3312792p3313090.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] gaoshan

2011-02-18 Thread wang peter
 i have got a svm MODEL from e1071
by
svmModel<-svm(x, y, kernel = "linear", cost = gamma, scaled=FALSE)
who can tell me how can i get the alpha of decision functions
i just remembered rho is the bias of decision functions

i think the manual of e1071 is a piece of usely garbage
thank u
gao shan

[[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] Is the Diebold Mariano Test in forecast package adjusted?

2011-02-18 Thread Paka yag

   Hello

I would like to know if the Diebold Mariano Test in the forecast Package is 
adjusted to small samples (as Harvey, Leybourne, Newbold suggest) If not, how 
can I do that manually?

Paka

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


Re: [R] plot3d, color points by group

2011-02-18 Thread Dieter Menne


Kari-4 wrote:
> 
> 
> I've created a 3d scatterplot, and had no problems labeling the points.
> However, I've been really struggling to change the color of the points
> based
> on a factor (see 'group' below).  Is such a thing possible?
> 
> 

Its always polite to make the example self-running by adding the library and
the input. But your's was close.
Dieter


library(rgl)
ttt = textConnection("
food group  x  y  z
apple  fruit  0.216 -0.112 -0.893
orange fruit  0.814  0.097  0.460
broccoli veg -0.239  0.240 -0.425
banana  fruit  0.222  0.968 -0.050
parsnip  veg  0.139  0.897  0.378
garlic veg -0.104  0.510 -0.400
")

colors =c("green","blue","red")
pca <-  read.table(ttt,header=TRUE)
p3d<- plot3d(pca$x, pca$y, pca$z, xlab="Component 1", ylab="Component 2",
zlab="Component 3", 
col=as.integer(pca$group) ,
box=FALSE, size=5)
food.v<-as.vector(pca$food)
text3d(pca$x, pca$y, pca$z, food.v, cex=0.9, adj = 1)


-- 
View this message in context: 
http://r.789695.n4.nabble.com/plot3d-color-points-by-group-tp3312955p3313268.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to calculate the perimeter and common border of polygons?

2011-02-18 Thread Leonardo Monasterio
Dear R-users,

Is there any way of calculating the perimeter of a polygon in a shapefile
object? Furthermore, how to calculate the length of the common border of two
polygons?
I've searched the code of spded, but could not find a hint on how to do it.
Thank you very much,
Leo.

[[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] question of elimination drawn lines on competing risk graph

2011-02-18 Thread Gerard Smits
Hi All,

I am using the package, cmprisk, to plot competing risks.  In my case, I have 
four lines showing risk of going on dialysis (by a lab test [fgf-23] in 
quartiles), where the 4 lower lines are for the competing risk of death.

I am trying to edit the function to just plot the upper curves (and not show 
the lower (competing) risk death curves.   I am not especially facile in 
editing this code, so would appreciate any help as to where I should be making 
changes.

Hope OK to include the function code.

Thanks.

Gerard



require(cmprsk)

#
#   #
# CUMULATIVE INCIDENCE CURVES IN R  #
#   #
# Written by Luca Scrucca   #
#   #
# Reference:#
# Scrucca L., Santucci A., Aversa F. (2007) Competing risks analysis using  #
#   R: an easy guide for clinicians. Bone Marrow Transplantation, 40,   #
#   381--387.   #
#
# ver. 1.1 Feb 2008
#  - allow group to be missing
#  - if t is provided both computation and plots use t as time points
#  - allow col, lwd to be used for curves with confidence bands
#  - fix some bugs in the legend
#  - added help on source code
# ver. 1.0 May 2007
#  - Version appearing in the BMT paper
#
#
# Usage:
# 
#   CumIncidence(ftime, fstatus, group, t, strata, rho = 0, cencode = 0,
#subset, na.action = na.omit, level, 
#xlab = "Time", ylab = "Probability", 
#col, lty, lwd, digits = 4)
# 
# Arguments:
# 
# ftime   = failure time variable.
# fstatus = variable with distinct codes for different causes of 
#   failure and also a distinct code for censored observations.
# group   = estimates will be calculated within groups given by distinct
#   values of this variable. Tests will compare these groups. If 
#   missing then treated as all one group (no test statistics).
# t =   a vector of time points where the cumulative incidence function 
#   should be evaluated.
# strata =  stratification variable. Has no effect on estimates. Tests 
#   will be stratified on this variable. (all data in 1 stratum,
#   if missing).
# rho = power of the weight function used in the tests. By default is
#   set to 0.
# cencode = value of fstatus variable which indicates the failure time
#   is censored.
# subset =  a logical vector specifying a subset of cases to include in 
#   the analysis.
# na.action=a function specifying the action to take for any cases 
#   missing any of ftime, fstatus, group, strata, or subset. 
#   By default missing cases are omitted.
# level =   a value in the range [0,1] specifying the level for pointwise
#   confidence bands.
# xlab =text for the x-axis label.
# ylab =text for the y-axis label.
# col = color(s) used for plotting curves (see plot.default).
# lty = line type(s) used for plotting curves (see plot.default).
# lwd = line width(s) used for plotting curves (see plot.default).
# digits =  number of significant digits used for printing values. By 
#   default set at 4.
# 
#

"CumIncidence" <- function(ftime, fstatus, group, t, strata, rho = 0, 
 cencode = 0, subset, na.action = na.omit, 
level,
 xlab = "Time", ylab = "Probability", 
 col, lty, lwd, digits = 4)
{
  # check for the required package
  if(!require("cmprsk"))
{ stop("Package `cmprsk' is required and must be installed.\n 
   See help(install.packages) or write the following command at prompt
   and then follow the instructions:\n
   > install.packages(\"cmprsk\")") } 
  # collect data
  mf  <- match.call(expand.dots = FALSE)
  mf[[1]] <- as.name("list")
  mf$t <- mf$digits <- mf$col <- mf$lty <- mf$lwd <- mf$level <- 
  mf$xlab <- mf$ylab <- NULL
  mf <- eval(mf, parent.frame())
  g <- max(1, length(unique(mf$group)))
  s <- length(unique(mf$fstatus))
  if(missing(t)) 
{ time <- pretty(c(0, max(mf$ftime)), 6)
  ttime <- time <- time[time < max(mf$ftime)] }
  else { ttime <- time <- t }
  # fit model and estimates at time points
  fit   <- do.call("cuminc", mf)
  tfit <- timepoints(fit, time)
  # print result
  cat("\n+", paste(rep("-"

[R] segfault during example(svm)

2011-02-18 Thread Juergen Rose
If do:
> library("e1071")
> example(svm)

I get:


svm> data(iris)

svm> attach(iris)

svm> ## classification mode
svm> # default with factor response:
svm> model <- svm(Species ~ ., data = iris)

svm> # alternatively the traditional interface:
svm> x <- subset(iris, select = -Species)

svm> y <- Species

svm> model <- svm(x, y) 

svm> print(model)

Call:
svm.default(x = x, y = y)


Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  radial 
   cost:  1 
  gamma:  0.25 

Number of Support Vectors:  51


svm> summary(model)

Call:
svm.default(x = x, y = y)


Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  radial 
   cost:  1 
  gamma:  0.25 

Number of Support Vectors:  51

 ( 8 22 21 )


Number of Classes:  3 

Levels: 
 setosa versicolor virginica




svm> # test with train data
svm> pred <- predict(model, x)

svm> # (same as:)
svm> pred <- fitted(model)

svm> # Check accuracy:
svm> table(pred, y)
y
pred setosa versicolor virginica
  setosa 50  0 0
  versicolor  0 48 2
  virginica   0  248

svm> # compute decision values and probabilities:
svm> pred <- predict(model, x, decision.values = TRUE)

svm> attr(pred, "decision.values")[1:4,]
  setosa/versicolor setosa/virginica versicolor/virginica
1  1.196152 1.0914600.6705626
2  1.064621 1.0563320.8479934
3  1.180842 1.0745340.6436474
4  1.110699 1.0531430.6778595

svm> # visualize (classes by color, SV by crosses):
svm> plot(cmdscale(dist(iris[,-5])),
svm+  col = as.integer(iris[,5]),
svm+  pch = c("o","+")[1:150 %in% model$index + 1])

 *** caught segfault ***
address (nil), cause 'unknown'

Traceback:
 1: .Call("La_rs", x, only.values, PACKAGE = "base")
 2: eigen(-x/2, symmetric = TRUE)
 3: cmdscale(dist(iris[, -5]))
 4: plot(cmdscale(dist(iris[, -5])), col = as.integer(iris[, 5]),
pch = c("o", "+")[1:150 %in% model$index + 1])
 5: eval.with.vis(expr, envir, enclos)
 6: eval.with.vis(ei, envir)
 7: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
getOption("continue"), sep = ""), verbose = verbose, max.deparse.length
= Inf, encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
 8: example(svm)

Possible actions:
1: abort (with core dump, if enabled)
..

I did already "update.packages(), what can I still do.

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

2011-02-18 Thread danielepippo

Hi everyone,
if I have the bootsrap values of the parameters of my regression model,
how can I calculate the standard error of them to refer to the parameters?

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Bootstraps-standard-error-tp3313322p3313322.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] Scaling Lattice Graphics for tikzDevice

2011-02-18 Thread Elliot Joel Bernstein
I'm trying to use lattice graphics to produce some small plots for inclusion in 
a LaTeX file. I want the LaTeX fonts to be used in the plots, but to be scaled 
down to match the size of the plot. I have written the following code to apply 
a scaling factor to all the "cex" and "padding" entries in the trellis 
parameters, but there is still a large white space between the key and the top 
of the plot area. Does anyone know how I can get rid of that (or if I'm going 
about this all wrong and there's a much cleaner way)?

## -- ##
## test.R ##
## -- ##

require(tikzDevice) 

   
require(lattice)

   


   
rescale.pars <- function(cex.factor = 0.5,  

   
 padding.factor = 0.25, 

   
 pars   = trellis.par.get()) {  

   


   
  result <- NULL

   
  for (i in seq_along(pars)) {  

   


   
if (names(pars)[[i]] == "cex") {

   


   
  if (is.null(result)) {

   
result <- list()

   
  } 

   
  result <- c(result, cex=cex.factor*pars[[i]]) 

   


   
} else if (grepl("padding$", names(pars)[[i]])) {   

   


   
  if (is.null(result)) {

   
result <- list()

   
  } 

   
  eval(parse(text=sprintf("result <- c(result, 
%s=padding.factor*pars[[i]])", names(pars)[[i]])))  



   
} else if (inherits(pars[[i]], "list")) {   

[R] non-ascii characters in R output

2011-02-18 Thread Matt Shotwell

All,

I'd like to automatically output text from R to HTML. In doing this I've 
run into trouble with non-ascii characters, as my browser (and 
presumably others) does not render such characters correctly. For 
example, the 'fancy' single quotes associated with summary.lm are 
multi-byte characters on my platform. This particular problem is solved 
by options(useFancyQuotes=FALSE). But now I'm concerned about other 
non-ascii characters. As an overkill maybe, my current solution involves 
capture.output and iconv(..., to="ASCII//TRANSLIT"). Are there other 
sources of non-ascii character? Is there a better or general solution?


Best,
Matt

> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

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

--
Matthew S Shotwell   Assistant Professor   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


[R] clustered bar chart help

2011-02-18 Thread Li, Qinghong, ST. LOUIS, NRC St. Louis Petcare
Hi,

 

Can anyone help me to plot a chart graph? I have a data set like this. I
would like a bar chart graph which mouse1's two treatments are clustered
together, so on.

I tried with barplot, but couldn't get it right.

 

 

Thanks

Johnny

Mouse1

Mouse2

Mouse3


Trial

Cont

Treat

Cont

Treat

Cont

Treat

1

2.4

4.3

2

4.3

2

7

2

2.8

5.4

2.8

6

2

8

3

3.1

4.5

3

4.5

3

7

4

3.1

4.4

3.1

4

3.1

7

5

2

4.1

2

4.1

2

7

6

2.2

4

2.2

3

4

6.9

7

2.7

5

4

5

2.7

6.5

8

4.5

5.6

4.5

6

4

5.6

9

2.3

4.5

2.3

4.5

2.3

4

10

3

4

4

6

2

4

 


[[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] When is *interactive* data visualization useful to use?

2011-02-18 Thread Tom Hopper
Tal,

One interactive capability that I have repeatedly wished for (but
never taken the time to develop with the existing R tools) is the
ability to interactively zoom in on and out of a data set, and to
interactively create "call-outs of sections of the data. Much of the
data that I deal with takes the form of time series where both the
full data and small section carry meaningful information.

Some of the capabilities of Deducer approach interactive graphing,
such as adjusting alpha values or smoothers, though the updates don't
happen in quite real-time.

- Tom

On Friday, February 11, 2011, Tal Galili  wrote:
> Hello all,
>
> Before getting to my question, I would like to apologize for asking this
> question here.  My question is not directly an R question, however, I still
> find the topic relevant to R community of users  - especially due to only *
> partial* (current) support for interactive data visualization (see here:
> http://cran.r-project.org/web/views/Graphics.html  were with iplots we are
> waiting for iplots extreme, and with rggobi, it currently can not run with R
> 2.12 and windows 7 OS).
>
> And now for my question:
>
> While preparing for a talk I will give soon, I recently started digging into
> two major (Free) tools for interactive data visualization:
> GGobi
>  and mondrian  - both offer a great range of
> capabilities (even if they're a bit buggy).
>
> I wish to ask for your help in articulating (both to myself, and for my
> future audience) *When is it helpful to use interactive plots? Either for
> data exploration (for ourselves) and data presentation (for a "client")?*
>
> For when explaining the data to a client, I can see the value of animation
> for:
>
>    - Using "identify/linking/brushing" for seeing which data point in the
>    graph is what.
>    - Presenting a sensitivity analysis of the data (e.g: "if we remove this
>    point, here is what we will get)
>    - Showing the effect of different groups in the data (e.g: "let's look at
>    our graphs for males and now for the females")
>    - Showing the effect of time (or age, or in general, offering another
>    dimension to the presentation)
>
> For when exploring the data ourselves, I can see the value of
> identify/linking/brushing when exploring an outlier in a dataset we are
> working on.
>
> But other then these two examples, I am not sure what other practical use
> these techniques offer. Especially for our own data exploration!
>
> It could be argued that the interactive part is good for exploring (For
> example) a different behavior of different groups/clusters in the data. But
> when (in practice) I approached such situation, what I tended to do was to
> run the relevant statistical procedures (and post-hoc tests) - and what I
> found to be significant I would then plot with colors clearly dividing the
> data to the relevant groups. From what I've seen, this is a safer approach
> then "wondering around" the data (which could easily lead to data dredging
> (were the scope of the multiple comparison needed for correction is not even
> clear).
>
> I'd be very happy to read your experience/thoughts on this matter.
>
>
> Thanks in advance,
> Tal
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> --
>
>         [[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] Bootstraps standard error

2011-02-18 Thread David Winsemius


On Feb 18, 2011, at 1:36 PM, danielepippo wrote:



Hi everyone,
   if I have the bootsrap values of the parameters of my regression  
model,
how can I calculate the standard error of them to refer to the  
parameters?


The same way you would any other vector?



Thank you
--
View this message in context: 
http://r.789695.n4.nabble.com/Bootstraps-standard-error-tp3313322p3313322.html



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] segfault during example(svm)

2011-02-18 Thread Peter Ehlers

On 2011-02-18 11:16, Juergen Rose wrote:

If do:

library("e1071")
example(svm)


I get:


svm>  data(iris)

svm>  attach(iris)

svm>  ## classification mode
svm>  # default with factor response:
svm>  model<- svm(Species ~ ., data = iris)

svm>  # alternatively the traditional interface:
svm>  x<- subset(iris, select = -Species)

svm>  y<- Species

svm>  model<- svm(x, y)

svm>  print(model)

Call:
svm.default(x = x, y = y)


Parameters:
SVM-Type:  C-classification
  SVM-Kernel:  radial
cost:  1
   gamma:  0.25

Number of Support Vectors:  51


svm>  summary(model)

Call:
svm.default(x = x, y = y)


Parameters:
SVM-Type:  C-classification
  SVM-Kernel:  radial
cost:  1
   gamma:  0.25

Number of Support Vectors:  51

  ( 8 22 21 )


Number of Classes:  3

Levels:
  setosa versicolor virginica




svm>  # test with train data
svm>  pred<- predict(model, x)

svm>  # (same as:)
svm>  pred<- fitted(model)

svm>  # Check accuracy:
svm>  table(pred, y)
 y
pred setosa versicolor virginica
   setosa 50  0 0
   versicolor  0 48 2
   virginica   0  248

svm>  # compute decision values and probabilities:
svm>  pred<- predict(model, x, decision.values = TRUE)

svm>  attr(pred, "decision.values")[1:4,]
   setosa/versicolor setosa/virginica versicolor/virginica
1  1.196152 1.0914600.6705626
2  1.064621 1.0563320.8479934
3  1.180842 1.0745340.6436474
4  1.110699 1.0531430.6778595

svm>  # visualize (classes by color, SV by crosses):
svm>  plot(cmdscale(dist(iris[,-5])),
svm+  col = as.integer(iris[,5]),
svm+  pch = c("o","+")[1:150 %in% model$index + 1])

  *** caught segfault ***
address (nil), cause 'unknown'

Traceback:
  1: .Call("La_rs", x, only.values, PACKAGE = "base")
  2: eigen(-x/2, symmetric = TRUE)
  3: cmdscale(dist(iris[, -5]))
  4: plot(cmdscale(dist(iris[, -5])), col = as.integer(iris[, 5]),
pch = c("o", "+")[1:150 %in% model$index + 1])
  5: eval.with.vis(expr, envir, enclos)
  6: eval.with.vis(ei, envir)
  7: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
getOption("continue"), sep = ""), verbose = verbose, max.deparse.length
= Inf, encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
  8: example(svm)

Possible actions:
1: abort (with core dump, if enabled)
..

I did already "update.packages(), what can I still do.


Works just fine for me. What's your sessionInfo()?
Here's mine:
> sessionInfo()
R version 2.12.1 Patched (2010-12-27 r53883)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages:
[1] e1071_1.5-24 class_7.3-3

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


Peter Ehlers

>


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] question of elimination drawn lines on competing risk graph

2011-02-18 Thread David Winsemius


On Feb 18, 2011, at 2:10 PM, Gerard Smits wrote:


Hi All,

I am using the package, cmprisk, to plot competing risks.  In my  
case, I have four lines showing risk of going on dialysis (by a lab  
test [fgf-23] in quartiles), where the 4 lower lines are for the  
competing risk of death.


I am trying to edit the function to just plot the upper curves (and  
not show the lower (competing) risk death curves.   I am not  
especially facile in editing this code, so would appreciate any help  
as to where I should be making changes.


Two problems:
A) You don't provide the data or something that give a reasonable look  
at the data.
B) When I use that function with the dataset provided on the webpage  
maintained by the authors, it appears to me that it simply plots  
cuminc for each group separately. (They are al crossingeach other,  
hence there is no summary curve "on top".)  So you would just remove  
whatever groups were superfluous prior to forwarding to the plotting  
function. (Hence no need to edit anything.)


--
David



Hope OK to include the function code.

Thanks.

Gerard



require(cmprsk)

#
#   #
# CUMULATIVE INCIDENCE CURVES IN  
R  #

#   #
# Written by Luca  
Scrucca   #

#   #
#  
Reference 
:#
# Scrucca L., Santucci A., Aversa F. (2007) Competing risks analysis  
using  #
#   R: an easy guide for clinicians. Bone Marrow Transplantation,  
40,   #
#
381 
--387.   #

#
# ver. 1.1 Feb 2008
#  - allow group to be missing
#  - if t is provided both computation and plots use t as  
time points
#  - allow col, lwd to be used for curves with confidence  
bands

#  - fix some bugs in the legend
#  - added help on source code
# ver. 1.0 May 2007
#  - Version appearing in the BMT paper
#
#
# Usage:
#
#   CumIncidence(ftime, fstatus, group, t, strata, rho = 0, cencode  
= 0,

#subset, na.action = na.omit, level,
#xlab = "Time", ylab = "Probability",
#col, lty, lwd, digits = 4)
#
# Arguments:
#
# ftime   = failure time variable.
# fstatus = variable with distinct codes for different causes of
#   failure and also a distinct code for censored  
observations.
# group	  = estimates will be calculated within groups given by  
distinct
#   values of this variable. Tests will compare these  
groups. If
#   missing then treated as all one group (no test  
statistics).
# t =   a vector of time points where the cumulative incidence  
function

#   should be evaluated.
# strata =  stratification variable. Has no effect on estimates. Tests
#   will be stratified on this variable. (all data in 1  
stratum,

#   if missing).
# rho = power of the weight function used in the tests. By  
default is

#   set to 0.
# cencode = value of fstatus variable which indicates the failure time
#   is censored.
# subset =  a logical vector specifying a subset of cases to include  
in

#   the analysis.
# na.action=a function specifying the action to take for any cases
#   missing any of ftime, fstatus, group, strata, or subset.
#   By default missing cases are omitted.
# level =   a value in the range [0,1] specifying the level for  
pointwise

#   confidence bands.
# xlab =text for the x-axis label.
# ylab =text for the y-axis label.
# col = color(s) used for plotting curves (see plot.default).
# lty = line type(s) used for plotting curves (see plot.default).
# lwd = line width(s) used for plotting curves (see plot.default).
# digits =  number of significant digits used for printing values. By
#   default set at 4.
#
#

"CumIncidence" <- function(ftime, fstatus, group, t, strata, rho = 0,
	 cencode = 0, subset, na.action = na.omit,  
level,

 xlab = "Time", ylab = "Probability",
 col, lty, lwd, digits = 4)
{
 # check for the required package
 if(!require("cmprsk"))
   { stop("Package `cmprsk' is required and must be installed.\n
  See help(install.packages) or write the following command  
at prompt

  and then follow the instructions:\n

install.packages(\"cmprsk\")") }

 #

Re: [R] segfault during example(svm)

2011-02-18 Thread Juergen Rose
Am Freitag, den 18.02.2011, 11:53 -0800 schrieb Peter Ehlers:
> On 2011-02-18 11:16, Juergen Rose wrote:
> > If do:
> >> library("e1071")
> >> example(svm)
> >
> > I get:
> >
> >
> > svm>  data(iris)
> >
> > svm>  attach(iris)
> >
> > svm>  ## classification mode
> > svm>  # default with factor response:
> > svm>  model<- svm(Species ~ ., data = iris)
> >
> > svm>  # alternatively the traditional interface:
> > svm>  x<- subset(iris, select = -Species)
> >
> > svm>  y<- Species
> >
> > svm>  model<- svm(x, y)
> >
> > svm>  print(model)
> >
> > Call:
> > svm.default(x = x, y = y)
> >
> >
> > Parameters:
> > SVM-Type:  C-classification
> >   SVM-Kernel:  radial
> > cost:  1
> >gamma:  0.25
> >
> > Number of Support Vectors:  51
> >
> >
> > svm>  summary(model)
> >
> > Call:
> > svm.default(x = x, y = y)
> >
> >
> > Parameters:
> > SVM-Type:  C-classification
> >   SVM-Kernel:  radial
> > cost:  1
> >gamma:  0.25
> >
> > Number of Support Vectors:  51
> >
> >   ( 8 22 21 )
> >
> >
> > Number of Classes:  3
> >
> > Levels:
> >   setosa versicolor virginica
> >
> >
> >
> >
> > svm>  # test with train data
> > svm>  pred<- predict(model, x)
> >
> > svm>  # (same as:)
> > svm>  pred<- fitted(model)
> >
> > svm>  # Check accuracy:
> > svm>  table(pred, y)
> >  y
> > pred setosa versicolor virginica
> >setosa 50  0 0
> >versicolor  0 48 2
> >virginica   0  248
> >
> > svm>  # compute decision values and probabilities:
> > svm>  pred<- predict(model, x, decision.values = TRUE)
> >
> > svm>  attr(pred, "decision.values")[1:4,]
> >setosa/versicolor setosa/virginica versicolor/virginica
> > 1  1.196152 1.0914600.6705626
> > 2  1.064621 1.0563320.8479934
> > 3  1.180842 1.0745340.6436474
> > 4  1.110699 1.0531430.6778595
> >
> > svm>  # visualize (classes by color, SV by crosses):
> > svm>  plot(cmdscale(dist(iris[,-5])),
> > svm+  col = as.integer(iris[,5]),
> > svm+  pch = c("o","+")[1:150 %in% model$index + 1])
> >
> >   *** caught segfault ***
> > address (nil), cause 'unknown'
> >
> > Traceback:
> >   1: .Call("La_rs", x, only.values, PACKAGE = "base")
> >   2: eigen(-x/2, symmetric = TRUE)
> >   3: cmdscale(dist(iris[, -5]))
> >   4: plot(cmdscale(dist(iris[, -5])), col = as.integer(iris[, 5]),
> > pch = c("o", "+")[1:150 %in% model$index + 1])
> >   5: eval.with.vis(expr, envir, enclos)
> >   6: eval.with.vis(ei, envir)
> >   7: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
> > getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
> > getOption("continue"), sep = ""), verbose = verbose, max.deparse.length
> > = Inf, encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
> >   8: example(svm)
> >
> > Possible actions:
> > 1: abort (with core dump, if enabled)
> > ..
> >
> > I did already "update.packages(), what can I still do.
> 
> Works just fine for me. What's your sessionInfo()?
> Here's mine:
>  > sessionInfo()
> R version 2.12.1 Patched (2010-12-27 r53883)
> Platform: i386-pc-mingw32/i386 (32-bit)
> 
> locale:
> [1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252
> [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
> [5] LC_TIME=English_Canada.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> other attached packages:
> [1] e1071_1.5-24 class_7.3-3
> 
> loaded via a namespace (and not attached):
> [1] tools_2.12.1


> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

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

It is working at some of my systems and is failing at the most.

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


Re: [R] segfault during example(svm)

2011-02-18 Thread Claudia Beleites

Dear Jürgen,

did you update.packages (checkBuilt = TRUE) ?
I recently had segfaults, too on 64bit linux (with rgl, though) and they 
disappeared only after updating with checkBuilt (including also the packages 
originally installed via Dirk's .deb packages.


HTH,

Claudia



On 02/18/2011 09:32 PM, Juergen Rose wrote:

Am Freitag, den 18.02.2011, 11:53 -0800 schrieb Peter Ehlers:

On 2011-02-18 11:16, Juergen Rose wrote:

If do:

library("e1071")
example(svm)


I get:


svm>   data(iris)

svm>   attach(iris)

svm>   ## classification mode
svm>   # default with factor response:
svm>   model<- svm(Species ~ ., data = iris)

svm>   # alternatively the traditional interface:
svm>   x<- subset(iris, select = -Species)

svm>   y<- Species

svm>   model<- svm(x, y)

svm>   print(model)

Call:
svm.default(x = x, y = y)


Parameters:
 SVM-Type:  C-classification
   SVM-Kernel:  radial
 cost:  1
gamma:  0.25

Number of Support Vectors:  51


svm>   summary(model)

Call:
svm.default(x = x, y = y)


Parameters:
 SVM-Type:  C-classification
   SVM-Kernel:  radial
 cost:  1
gamma:  0.25

Number of Support Vectors:  51

   ( 8 22 21 )


Number of Classes:  3

Levels:
   setosa versicolor virginica




svm>   # test with train data
svm>   pred<- predict(model, x)

svm>   # (same as:)
svm>   pred<- fitted(model)

svm>   # Check accuracy:
svm>   table(pred, y)
  y
pred setosa versicolor virginica
setosa 50  0 0
versicolor  0 48 2
virginica   0  248

svm>   # compute decision values and probabilities:
svm>   pred<- predict(model, x, decision.values = TRUE)

svm>   attr(pred, "decision.values")[1:4,]
setosa/versicolor setosa/virginica versicolor/virginica
1  1.196152 1.0914600.6705626
2  1.064621 1.0563320.8479934
3  1.180842 1.0745340.6436474
4  1.110699 1.0531430.6778595

svm>   # visualize (classes by color, SV by crosses):
svm>   plot(cmdscale(dist(iris[,-5])),
svm+  col = as.integer(iris[,5]),
svm+  pch = c("o","+")[1:150 %in% model$index + 1])

   *** caught segfault ***
address (nil), cause 'unknown'

Traceback:
   1: .Call("La_rs", x, only.values, PACKAGE = "base")
   2: eigen(-x/2, symmetric = TRUE)
   3: cmdscale(dist(iris[, -5]))
   4: plot(cmdscale(dist(iris[, -5])), col = as.integer(iris[, 5]),
pch = c("o", "+")[1:150 %in% model$index + 1])
   5: eval.with.vis(expr, envir, enclos)
   6: eval.with.vis(ei, envir)
   7: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
getOption("continue"), sep = ""), verbose = verbose, max.deparse.length
= Inf, encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
   8: example(svm)

Possible actions:
1: abort (with core dump, if enabled)
..

I did already "update.packages(), what can I still do.


Works just fine for me. What's your sessionInfo()?
Here's mine:
  >  sessionInfo()
R version 2.12.1 Patched (2010-12-27 r53883)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages:
[1] e1071_1.5-24 class_7.3-3

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




sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

It is working at some of my systems and is failing at the most.

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



--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

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


Re: [R] segfault during example(svm)

2011-02-18 Thread Peter Ehlers

On 2011-02-18 12:32, Juergen Rose wrote:

Am Freitag, den 18.02.2011, 11:53 -0800 schrieb Peter Ehlers:

On 2011-02-18 11:16, Juergen Rose wrote:

If do:

library("e1071")
example(svm)


I get:


svm>   data(iris)

svm>   attach(iris)

svm>   ## classification mode
svm>   # default with factor response:
svm>   model<- svm(Species ~ ., data = iris)

svm>   # alternatively the traditional interface:
svm>   x<- subset(iris, select = -Species)

svm>   y<- Species

svm>   model<- svm(x, y)

svm>   print(model)

Call:
svm.default(x = x, y = y)


Parameters:
 SVM-Type:  C-classification
   SVM-Kernel:  radial
 cost:  1
gamma:  0.25

Number of Support Vectors:  51


svm>   summary(model)

Call:
svm.default(x = x, y = y)


Parameters:
 SVM-Type:  C-classification
   SVM-Kernel:  radial
 cost:  1
gamma:  0.25

Number of Support Vectors:  51

   ( 8 22 21 )


Number of Classes:  3

Levels:
   setosa versicolor virginica




svm>   # test with train data
svm>   pred<- predict(model, x)

svm>   # (same as:)
svm>   pred<- fitted(model)

svm>   # Check accuracy:
svm>   table(pred, y)
  y
pred setosa versicolor virginica
setosa 50  0 0
versicolor  0 48 2
virginica   0  248

svm>   # compute decision values and probabilities:
svm>   pred<- predict(model, x, decision.values = TRUE)

svm>   attr(pred, "decision.values")[1:4,]
setosa/versicolor setosa/virginica versicolor/virginica
1  1.196152 1.0914600.6705626
2  1.064621 1.0563320.8479934
3  1.180842 1.0745340.6436474
4  1.110699 1.0531430.6778595

svm>   # visualize (classes by color, SV by crosses):
svm>   plot(cmdscale(dist(iris[,-5])),
svm+  col = as.integer(iris[,5]),
svm+  pch = c("o","+")[1:150 %in% model$index + 1])

   *** caught segfault ***
address (nil), cause 'unknown'

Traceback:
   1: .Call("La_rs", x, only.values, PACKAGE = "base")
   2: eigen(-x/2, symmetric = TRUE)
   3: cmdscale(dist(iris[, -5]))
   4: plot(cmdscale(dist(iris[, -5])), col = as.integer(iris[, 5]),
pch = c("o", "+")[1:150 %in% model$index + 1])
   5: eval.with.vis(expr, envir, enclos)
   6: eval.with.vis(ei, envir)
   7: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
getOption("continue"), sep = ""), verbose = verbose, max.deparse.length
= Inf, encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
   8: example(svm)

Possible actions:
1: abort (with core dump, if enabled)
..

I did already "update.packages(), what can I still do.


Works just fine for me. What's your sessionInfo()?
Here's mine:
  >  sessionInfo()
R version 2.12.1 Patched (2010-12-27 r53883)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages:
[1] e1071_1.5-24 class_7.3-3

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




sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

It is working at some of my systems and is failing at the most.



It would be good to know what version of e1071 you're using;
presumably it's 1.5-24. I've run the example on both 32-bit
and 64-bit R 12.2.1pat and 2.13.0dev with no problems.
Could you be having a problem with your graphics device?

Peter Ehlers

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


Re: [R] segfault during example(svm)

2011-02-18 Thread Juergen Rose
Am Freitag, den 18.02.2011, 21:42 +0100 schrieb Claudia Beleites:
> update.packages (checkBuilt = TRUE)

Dear Claudia,

I just tried update.packages (checkBuilt = TRUE), it did not solved the
issue.

Nevertheless thanks,

Juergen

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

2011-02-18 Thread Dmitry Berman
Listers,

Is there a command/function to get the population standard deviation (N) and
the sample standard deviation (n-1)

Thanks

[[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] Means

2011-02-18 Thread Ted Harding
On 18-Feb-11 20:51:40, Dmitry Berman wrote:
> Listers,
> 
> Is there a command/function to get the population standard deviation
> (N) and
> the sample standard deviation (n-1)
> 
> Thanks

Using data (1:10), with N=10, as an example:

  c(SampSD=1, PopSD=sqrt(9/10))*sd((1:10))
  #   SampSDPopSD
  # 3.027650 2.872281 

More generally, with data x and N<-length(x):

  c(SampSD=1, PopSD=sqrt((N-1)/N))*sd(x)

These are examples of commands. You could wrap the latter into
a function on the lines of:

  PopSampSD <- function(x){
N <- length(x)
c(SampSD=1, PopSD=sqrt((N-1)/N))*sd(x)
  }

and then:

  PopSampSD((1:10))
  #   SampSDPopSD 
  # 3.027650 2.872281 

as before. Hoping this helps,
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 18-Feb-11   Time: 22:12:00
-- 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] segfault during example(svm)

2011-02-18 Thread Claudia Beleites

Dear Jürgen,


I just tried update.packages (checkBuilt = TRUE), it did not solved the
issue.

Was just a guess.


Nevertheless thanks,

Bitte, bitte.


In case that helps tracking down the problem:
it works with my normal R as well as with r-devel. In case it helps you, I also 
put the installation protocol for r-devel below (for the normal I had it already).


Claudia


> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
 [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] e1071_1.5-24 class_7.3-3

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

> sessionInfo ()
R version 2.13.0 Under development (unstable) (2011-02-18 r54483)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
 [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] e1071_1.5-24 class_7.3-2

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

trying URL 'http://cran.stat.unipd.it/src/contrib/e1071_1.5-24.tar.gz'
Content type 'application/octet-stream' length 312648 bytes (305 Kb)
opened URL
==
downloaded 305 Kb

* installing *source* package ‘e1071’ ...
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
** libs
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include-fpic  -g -O2 
-c Rsvm.c -o Rsvm.o
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include-fpic  -g -O2 
-c cmeans.c -o cmeans.o
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include-fpic  -g -O2 
-c cshell.c -o cshell.o
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include-fpic  -g -O2 
-c floyd.c -o floyd.o
g++ -I/home/cb/r-devel/include  -I/usr/local/include-fpic  -g -O2 -c svm.cpp 
-o svm.o

svm.cpp: In function ‘svm_model* svm_load_model(const char*)’:
svm.cpp:2712: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2716: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2738: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2759: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2761: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2763: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2765: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2767: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2773: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2780: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2787: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2794: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2801: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2862: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result
svm.cpp:2871: warning: ignoring return value of ‘int fscanf(FILE*, const char*, 
...)’, declared with attribute warn_unused_result

g++ -shared -L/usr/local/lib64 -o e1071.so Rsvm.o cmeans.o cshell.o floyd.o 
svm.o
installing to /home/cb/r-devel/library/e1071/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
**

[R] breaks/bins question

2011-02-18 Thread Julie McWhorter

Thank you Joshua and Jim--I got the tick marks on finally!
One last question: I am supposed to make bins in 1, 2 and 5 mm increments for 
fish up to 170 mm.  I assume these are the breaks?  So breaks = 170 for 1 mm 
and 340 for 2 mm and 1550 for 5 mm?  I couldn't find any specific examples in 
the R manual.  The problem is I don't think that is correct, as the histogram 
disappears at breaks = 1550.
Thank you again,
Julie 
[[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] clustered bar chart help

2011-02-18 Thread Li, Qinghong, ST. LOUIS, NRC St. Louis Petcare
Sorry the data were all messed up. Let me try again.
Can anyone help me to plot a chart graph? I have a data set like this. I
would like a bar chart graph which mouse1's two treatments are clustered
together, so on.

I tried with barplot, but couldn't get it right.

Mouse1  Mouse2  Mouse3  
Trial   C   T   C   T   C   T

1   2.4 4.3 2   4.3 2   7
2   2.8 5.4 2.8 6   2   8
3   3.1 4.5 3   4.5 3   7
4   3.1 4.4 3.1 4   3.1 7
5   2   4.1 2   4.1 2   7
6   2.2 4   2.2 3   4   6.9
7   2.7 5   4   5   2.7 6.5
8   4.5 5.6 4.5 6   4   5.6
9   2.3 4.5 2.3 4.5 2.3 4
10  3   4   4   6   2   4

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Li,Qinghong,ST. LOUIS,NRC St. Louis Petcare
Sent: Friday, February 18, 2011 12:06 PM
To: r-help@r-project.org
Subject: [R] clustered bar chart help

Hi,

 

Can anyone help me to plot a chart graph? I have a data set like this. I
would like a bar chart graph which mouse1's two treatments are clustered
together, so on.

I tried with barplot, but couldn't get it right.

 

 

Thanks

Johnny

Mouse1

Mouse2

Mouse3


Trial

Cont

Treat

Cont

Treat

Cont

Treat

1

2.4

4.3

2

4.3

2

7

2

2.8

5.4

2.8

6

2

8

3

3.1

4.5

3

4.5

3

7

4

3.1

4.4

3.1

4

3.1

7

5

2

4.1

2

4.1

2

7

6

2.2

4

2.2

3

4

6.9

7

2.7

5

4

5

2.7

6.5

8

4.5

5.6

4.5

6

4

5.6

9

2.3

4.5

2.3

4.5

2.3

4

10

3

4

4

6

2

4

 


[[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] R2wd

2011-02-18 Thread rookie r user

Hi all, 

I'm currently trying to get accustomed to R and some of its packages, thus
need some help for a package called R2wd. As I am trying to use the wdGET()
function I'm getting the following message:

Error in if (!(tmp[["ActiveDocument"]][["Name"]] == filename))
tmp$Open(paste("path",  : 
  argument is of length zero

Does anybody know what that means?

Best,
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R2wd-tp3313527p3313527.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.


  1   2   >