Re: [R] loading igraph package on Solaris

2008-01-10 Thread Gabor Csardi
Peter,

the changes you made should be ok. (No changes are needed for gcc/g++
anyway.)  The problem is not the C compiler, which is (most likely)
gcc, but the c++ compiler, which is not the GNU 
c++ compiler, but the Sun version. I guess that the GNU c++ compiler
is called g++ or gxx. If you found out which one, or that this 
compiler is installed on your system at all, see 
6.3.3 in http://cran.r-project.org/doc/manuals/R-admin.pdf
on how to supply your Makevars file.
--configure-args might work as well, but you need to set the 
CXX variable, not CC.

My understanding is that once you set up gcc/g++ in your Makevars file,
you can simply do 'install.packages("igraph")'.

Someone who knows Solaris/R better, please correct me if i'm wrong.

Gabor

On Thu, Jan 10, 2008 at 06:21:28PM -0600, Peter McMahan wrote:
[...]
> I compiled and installed using:
> R CMD INSTALL --configure-args="CC='gcc'" igraph
> 
> and still, library(igraph) gives me:
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
>  unable to load shared library '/home/mcmahan/R/i386-pc- 
> solaris2.10-library/2.5/igraph/libs/igraph.so':
>ld.so.1: R: fatal: relocation error: file /home/mcmahan/R/i386-pc- 
> solaris2.10-library/2.5/igraph/libs/igraph.so: symbol __1cDstdEcerr_:  
> referenced symbol not found
> Error : .onLoad failed in 'loadNamespace' for 'igraph'
> Error: package/namespace load failed for 'igraph'
[...]

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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


Re: [R] 4 dimensional graphics

2008-01-10 Thread Petr PIKAL
Thanks to all who replied. I will check all suggestions to see what is the 
best one in respect of readability. 
Suggestion of using LSD monitor from Alberto is quite attracting however I 
am not sure if legal :-)

Thank you again and best regards.

Petr
[EMAIL PROTECTED]

jiho <[EMAIL PROTECTED]> napsal dne 10.01.2008 18:46:12:

> 
> On 2008-January-10  , at 17:41 , Petr PIKAL wrote:
> > Thank you
> >
> > Basically I have a rectangular space (like an aquarium) in which I 
> > made
> > some analysis.
> > I can make
> >
> > image(lat, long, value) for each height but what I dream about is to 
> > make
> > something like scatterplot3d(lat, long, height) with points set 
> > according
> > to a value.
> >
> > Up to now i can do
> >
> > scatterplot3d(sloupecn, radan, vrstvan, color=as.numeric(cut(value, 
> > c(0,
> > 100, 400, 1000
> >
> > which will give you green and red points in upper right corner. I 
> > started
> > to try to make cex.symbols scaled according to value too but up to 
> > now I
> > did not manage to work correctly.
> >
> > in
> >
> > scatterplot3d(sloupecn, radan, vrstvan, cex.symbols = value/ 
> > max(value)+2,
> > color=as.numeric(cut(value, c(0, 100, 400, 1000
> >
> > the biggest points are at other places then I expected.
> 
> so you have measures at x,y,z points basically. and your measures 
> appear to be on z layers so you can probably make several x,y plots 
> with point size according to value, stacked on top of each other or 
> side by side. one liner ggplots:
> 
> A=read.table("petr.txt",header=T)
> library("ggplot2")
> # stacked
> ggplot(A,aes(x=x,y=y)) + geom_point(aes(size=value, colour=factor(z))) 
> + scale_size(to=c(0,10)) + scale_colour_hue(alpha=0.3)
> # side by side
> ggplot(A,aes(x=x,y=y)) + geom_point(aes(size=value)) + 
> scale_size(to=c(0,10)) +facet_grid(z~.)
> 
> if you want 3d to explore your data, rgl (in which you can rotate 
> plots etc) is probably the best choice
> 
> # 3D with rgl
> library("rgl")
> open3d()
> spheres3d(A$x,A$y,A$z,A$value/1000) 
> # NB. scaling your value is necessary since the values are so big 
> compared to the coordinates
> axes3d()
> 
> hope that helps.
> 
> petr.txt:
> 
> x y z value
> 1   4   1   73.8
> 1   4   9   54.9
> 1   4   17  72
> 1   1   1   96
> 1   1   9   52.1
> 1   1   17  53.3
> 4   4   1   58.4
> 4   4   9   93.5
> 4   4   17  140.2
> 4   1   1   90.3
> 4   1   9   36.5
> 4   1   17  55.1
> 7   4   1   169.1
> 7   4   9   718
> 7   4   17  813
> 7   1   1   73.4
> 7   1   9   46.5
> 7   1   17  205
> 
> 
> JiHO
> ---
> http://jo.irisson.free.fr/
> 
>

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

2008-01-10 Thread Poizot Emmanuel

Dear all,

I facing pbs using RODBC library.
I'm working on a Linux (Ubuntu Gutsy) os, with R version 2.5.1.
I've got Postgresql 8.2.5 installed with the odbc-postgresql package.
I try to connect in a R session to a  postgresql database using:

odbcConnect(dsn="thedatabasename",uid="theuser",pwf="thepasswd",case="postgresql")
I get a message error, connection failes in odbcDriverConnect(...)
I don't know where I'm wrong, as I verified the postgresql deamon is ok 
and that the database I want to access is defined.


--


Emmanuel Poizot
Cnam/Intechmer
B.P. 324
50103 Cherbourg Cedex

Phone (Direct) : (00 33)(0)233887342
Fax : (00 33)(0)233887339


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

2008-01-10 Thread RAJA SEKHAR REDDY MAYALURU
Hi All ,

i want to use this R project  to implement  project mix model .

i have seen some tutorials about  R tool , i did nt fidn any thing related
to implement product mix model .

my requirement is :

i want to give some data and some constraints , the tool need to give the
output optimum sloution  for the given data .

thanks for the help .

[[alternative HTML version deleted]]

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


Re: [R] installing and using a package

2008-01-10 Thread jpolo
> I'm not sure what you have done but using a package requires two steps:
> 1) installing or downloading the package,
> 2) loading an installed package.
>
> Since you are using windows you can click on Packages, Install packages,
> and
> after choosing a CRAN mirror, selecting the package you want.  R will do
> the
> rest and tell you that it has installed the package (which it apparently
> has
> in your case).
>
> Now click on Packages again and choose Load package.
that helped. thank you

john

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


Re: [R] error message translation

2008-01-10 Thread jpolo

> Do you mean expansions on the terse messages, or translations from
> another language?  There aren't really any expansions available: the
> messages are supposed to be clear in themselves.  If you really want to
> know why you got one you might be able to look it up in the source code,
> but generally the best thing is to ask a few times on this list, and
> then you'll pick up the style, and will generally just recognize them.
>
> Duncan Murdoch
yes, i meant an expansion. you've helped me though. thank you.

john

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


Re: [R] changing the values in a list

2008-01-10 Thread dxc13

I will give it a try, thanks for your input!


Peter McMahan wrote:
> 
> 
> On Jan 10, 2008, at 9:48 PM, Peter McMahan wrote:
> 
>> y <- matrix(rep(y,ncol(x)),nrow=nrow(y))
>> x[is.na(x)] <- y[is.na(x)]
> 
> oops, i meant:
> y <- matrix(rep(y,ncol(res)),nrow=nrow(y))
> res[is.na(res)] <- y[is.na(res)]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/changing-the-values-in-a-list-tp14749183p14749502.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] changing the values in a list

2008-01-10 Thread Peter McMahan

On Jan 10, 2008, at 9:48 PM, Peter McMahan wrote:

> y <- matrix(rep(y,ncol(x)),nrow=nrow(y))
> x[is.na(x)] <- y[is.na(x)]

oops, i meant:
y <- matrix(rep(y,ncol(res)),nrow=nrow(y))
res[is.na(res)] <- y[is.na(res)]

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


Re: [R] changing the values in a list

2008-01-10 Thread Peter McMahan
try:
res <- apply(res,2,function(x){x[is.na(x)] <- y[is.na(x)];x})

should work, though not the most efficient/elegant

alternately:
y <- matrix(rep(y,ncol(x)),nrow=nrow(y))
x[is.na(x)] <- y[is.na(x)]

(also not the most efficient/elegant)

On Jan 10, 2008, at 9:38 PM, dxc13 wrote:

>
> useR's,
>
> Does anyone know of an efficient way to change the values in a list to
> different numbers stored in an object?  For example, consider the  
> following:
>
> y <- matrix(c(20, 13, 25, 10, 17), ncol = 1)
>
>> res
> [[1]]
>  [,1]  [,2]  [,3]  [,4] [,5]  [,6]  [,7] [,8]  [,9] [,10] [,11]  
> [,12]
> [,13] [,14]
> [1,]   NA   NA   NA 1.25 0.25 0.75   NA   NA   NANANANA   
> 1.25
> 0.25
> [2,] 1.25 0.25 0.75   NA   NA   NA   NA   NA   NA  1.25  0.25   
> 0.75NA
> NA
> [3,]   NA   NA   NA   NA   NA   NA 1.25 0.25 0.75NANA 
> NANA
> NA
> [4,]   NA   NA 1.25 0.25 0.75   NA   NA   NA   NANANA  1.25   
> 0.25
> 0.75
> [5,]   NA   NA   NA   NA   NA 1.25 0.25 0.75   NANANA 
> NANA
> NA
>
> [[2]]
>   [,1] [,2]  [,3] [,4]  [,5]  [,6] [,7]  [,8]  [,9] [,10] [,11]  
> [,12]
> [,13] [,14]
> [1,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANA 
> NANA
> NA
> [2,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANA 
> NANA
> NA
> [3,] 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25  0.25  0.25  0.25   
> 0.25
> 0.25
> [4,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANA 
> NANA
> NA
> [5,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANA 
> NANA
> NA
>
> What I want to do is change the values in each column of the list  
> that are
> not NA to their corresponding Y values in the matrix given.  So any  
> real
> number in the first position of any column in the list should be  
> changed to
> 20, the second number would be changed to 13, and so on...
> Does anyone know an easy way to do this?
> Thanks in advance.
>
> Derek
> -- 
> View this message in context: 
> http://www.nabble.com/changing-the-values-in-a-list-tp14749183p14749183.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] changing the values in a list

2008-01-10 Thread dxc13

useR's,

Does anyone know of an efficient way to change the values in a list to
different numbers stored in an object?  For example, consider the following:

y <- matrix(c(20, 13, 25, 10, 17), ncol = 1)

> res
[[1]]
  [,1]  [,2]  [,3]  [,4] [,5]  [,6]  [,7] [,8]  [,9] [,10] [,11] [,12]
[,13] [,14]
[1,]   NA   NA   NA 1.25 0.25 0.75   NA   NA   NANANANA  1.25 
0.25
[2,] 1.25 0.25 0.75   NA   NA   NA   NA   NA   NA  1.25  0.25  0.75NA   
NA
[3,]   NA   NA   NA   NA   NA   NA 1.25 0.25 0.75NANANANA   
NA
[4,]   NA   NA 1.25 0.25 0.75   NA   NA   NA   NANANA  1.25  0.25 
0.75
[5,]   NA   NA   NA   NA   NA 1.25 0.25 0.75   NANANANANA   
NA

[[2]]
   [,1] [,2]  [,3] [,4]  [,5]  [,6] [,7]  [,8]  [,9] [,10] [,11] [,12]
[,13] [,14]
[1,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANANANA   
NA
[2,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANANANA   
NA
[3,] 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25  0.25  0.25  0.25  0.25 
0.25
[4,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANANANA   
NA
[5,]   NA   NA   NA   NA   NA   NA   NA   NA   NANANANANA   
NA

What I want to do is change the values in each column of the list that are
not NA to their corresponding Y values in the matrix given.  So any real
number in the first position of any column in the list should be changed to
20, the second number would be changed to 13, and so on...
Does anyone know an easy way to do this?
Thanks in advance.

Derek
-- 
View this message in context: 
http://www.nabble.com/changing-the-values-in-a-list-tp14749183p14749183.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] installing and using a package

2008-01-10 Thread jpolo
> R distinguishes between "installing" and "loading" a package. It looks
> like your installation of yags went fine. Now type
> library(yags)
> to load the package.
> now help(yags) should bring up something, as should example(yags) .
that helped. thank you

john

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


Re: [R] installing and using a package

2008-01-10 Thread jpolo
>> -Original Message-


> You need to read the "An Introduction to R" manual which was probably
> installed when you installed R on your un-named OS (Windows, I take it).
yes, i did find what i needed there. thanks you.

john

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


Re: [R] ggplot2, coord_equal and aspect ratio

2008-01-10 Thread hadley wickham
On Jan 10, 2008 6:16 PM, jiho <[EMAIL PROTECTED]> wrote:
> Hi everyone, Hi Hadley,
>
> I am a heavy user of coord_equal() in ggplot2 since most of my data is
> spatial, on x,y coordinates. Everything works. However by enforcing an
> aspect ratio of 1 for the plotting region, coord_equal() usually
> wastes a lot of space if the region of interest is not a perfect square.
>
> For example:
> x=runif(10)
> a=data.frame(x=x*3,y=x)
> ggplot(data=a, aes(x=x,y=y)) + geom_point() + coord_equal()
> produces a square plotting region while all the data is constrained in
> an horizontally extended rectangle. I would expect the coordinates to
> stay equal but the plot to be extended so that it fills as much as the
> plotting region as possible. It does not appear to be currently
> doable. Is it a limitation of ggplot? of the underlying grids
> graphics? Is there a workaround this?

That's not currently possible unfortunately because coord_equal has no
information about the size of the plotting device.  Of course, if
there is specific a non-square aspect ratio that you want, you can use
e.g.

qplot(x, y, data=a) + coord_equal(ratio = 2) + opts(aspect.ratio = 2)

(or in the next version of ggplot
qplot(x, y, data=a) + coord_equal(ratio = 2)
where the aspect ratio is automatically set)

> x=runif(10)
> qplot(x*3, x) + coord_equal()
> produces some very strange scales. this looks like a bug to me.
> especially since:
> foo=x
> qplot(foo*3, foo) + coord_equal()
> works as expected

Yes, that's a bug that's fixed in the next version (which should be
available on cran soon)

> PPS: I tried
> ggplot(data=a, aes(x=x,y=y)) + geom_point() + coord_equal() +
> scale_y_continuous(limits=c(0,1))
> which has no effect. but the side effect of enforcing the square
> domain is that:
> ggplot(data=a, aes(x=x,y=y)) + geom_point() + coord_equal() +
> scale_y_continuous(limits=c(0,0.3))
> has no effect either (i would expect to see only the points <0.3)

That seems to have been fixed in the next version too.

Hadley

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

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


Re: [R] cairo and rapache [was: Weird errors on MAC OS X Leopard when using Cairo/GDD through Rserve]

2008-01-10 Thread Simon Urbanek
Charles, Greg,

the problem is that Apple's  FreeType on Leopard uses CF calls (albeit  
just to get files), so it breaks on fork. (The message is moot,  
because the whole point of using fork is to *not* use exec).

In any case the solution is to compile your own version of freetype,  
fontconfig and cairo without any CF or Carbon API. Fortunately most  
recent versions of FreeType will do so automatically on Leopard.  
Compiling Cairo can be a bit tricky, because you must make sure that  
you newly compiled FT/FC will have higher precedence than Apple's and  
yet it relies on X11. In my experience it will make the typesetting  
results worse, but unless Apple fixes their CF there is no other way  
around that (other than using serial access like on Windows).

Cheers,
Simon

PS: As a side note, I opted for static ft/fc/cairo builds and I had to  
add -lexpat to the flags and override ft/fc with the full path to the  
static library, so my CAIRO_LIBS were
-L/opt/lib -L/usr/X11/lib /opt/lib/libfreetype.a /opt/lib/ 
libfontconfig.a /opt/lib/libpng12.a -lz -lXrender -lSM -lICE -lX11 / 
opt/lib/libcairo.a -lexpat


Greg Dingle [EMAIL PROTECTED] wrote on Sun Dec 9 23:46:58 CET 2007

> I'm trying to get Cairo and RApache to work together on OS X leopard.
>
> Initializing Cairo stops the whole HTTP response. Apache logs show
> this message:
>
> Break on
> __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__
> () to debug.
> The process has forked and you cannot use this CoreFoundation
> functionality safely. You MUST exec().
>


On Jan 10, 2008, at 6:10 AM, Charles Girardot wrote:

> [...]
> I just upgraded my mac computer to the new OS X Leopard. And all my  
> code that uses Rserve to produce pictures doesn t work anymore. I am  
> using the latest version of Rserve (0.5), I have tried the old and  
> the new java client. My R is 2.6.1. All libs (GDD, Cairo are the  
> latest as well)
>
> For example a simple :
> connection.voidEval("library(GDD)");
>
> produces a bunch of :
> The process has forked and you cannot use this CoreFoundation  
> functionality safely. You MUST exec().
> Break on  
> __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__
>  
> () to debug.
>
> in the console.

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


Re: [R] error message translation

2008-01-10 Thread Duncan Murdoch
On 10/01/2008 7:12 PM, [EMAIL PROTECTED] wrote:
> sorry if my first msg was posted twice. this email system at school sucks.
> 
> i've looked in the Admin and Main manual and the Intro manual for
> something that tells me what error messages mean, but haven't found
> anything. where can i find the meanings of the error messages?

Do you mean expansions on the terse messages, or translations from 
another language?  There aren't really any expansions available: the 
messages are supposed to be clear in themselves.  If you really want to 
know why you got one you might be able to look it up in the source code, 
but generally the best thing is to ask a few times on this list, and 
then you'll pick up the style, and will generally just recognize them.

Duncan Murdoch

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


Re: [R] Extracting last time value

2008-01-10 Thread Gabor Grothendieck
Here is a slight variation of ones you have already received.  This
also uses zoo.

In the DF<- line we read it in as a data frame.  In the z<- line we convert
it to zoo using chron date/times (see R News 4/1 for more).
We calculate the positions of duplicate dates and in the last line we
extract the rows corresponding to non-duplicates.

Lines <- "Datetimevalue
2011062011:18:007
2011062011:39:009
2011062111:41:008
2011062111:40:006
2011062214:05:008
2011062214:06:006
"

library(zoo)
library(chron)
DF <- read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
z <- zoo(DF$value, chron(unclass(as.Date(format(DF$Date), "%Y%m%d"))), DF$time)

isdup <- duplicated(dates(time(z)), fromLast = TRUE)
z[!isdup,]

For more on zoo see:

library(zoo)
vignette("zoo")
vignette("zoo-quickref")


On Jan 10, 2008 5:36 PM, Kondamani, Arjun (GMI - NY Corporate Bonds)
<[EMAIL PROTECTED]> wrote:
> I have a dataframe as follows:
>
> Datetimevalue
> 2011062011:18:007
> 2011062011:39:009
> 2011062111:41:008
> 2011062111:40:006
> 2011062214:05:008
> 2011062214:06:006
>
> For every date, I want to extract the row that has the greatest time.
> Therefore, ending up like:
> 2011062011:39:009
> 2011062111:41:008
> 2011062214:07:006
>
> I am using for loops (for every date, find largest time value) to do
> this determination, but I am sure there is a simpler way in "R". Has
> anyone run into this before?
> 
>
> This message w/attachments (message) may be privileged, confidential or 
> proprietary, and if you are not an intended recipient, please notify the 
> sender, do not use or share it and delete it. Unless specifically indicated, 
> this message is not an offer to sell or a solicitation of any investment 
> products or other financial product or service, an official confirmation of 
> any transaction, or an official statement of Merrill Lynch. Subject to 
> applicable law, Merrill Lynch may monitor, review and retain e-communications 
> (EC) traveling through its networks/systems. The laws of the country of each 
> sender/recipient may impact the handling of EC, and EC may be archived, 
> supervised and produced in countries other than the country in which you are 
> located. This message cannot be guaranteed to be secure or error-free. This 
> message is subject to terms available at the following link: 
> http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch 
> you consent to the foregoing.
> 
>
>[[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] Cycle Regression Analysis in R?

2008-01-10 Thread Charles C. Berry
On Thu, 10 Jan 2008, Carson Farmer wrote:

> Hello R community,
>
> Does anyone know of a package that will perform cycle regression
> analysis? I have searched the R-help archives etc. but have come up with
> nothing so far.
> If I am unable to find an existing R package to do so, is there anyone
> familiar with fitting sine functions to data.  My problem is this:
> I have a long time-series of daily SWE estimates (SWE = snow water
> equivalence, or the amount of water stored in a snowpack) which follows
> a sinusoidal pattern, and I need to estimate the parameters of the sine
> function that best fits this data. While there may be many contributing
> sine functions and/or linear trends, I am only interested in a single
> sine function that most closely fits the data (trends can be removed
> separately if need be).  Perhaps some sort of non-linear least squares
> method would be best?


Or maybe stl? ( Seasonal Decomposition of Time Series by Loess )

Try

example( stl )

and see the reference in

?stl

HTH,

Chuck

p.s. Surely, SWE is NOT sinusoidal. At least not in my local mountains.


>
> Any help, or suggestions to get me on the right track are greatly
> appreciated.
>
> Carson
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] loading igraph package on Solaris

2008-01-10 Thread Peter McMahan
With a fresh copy of igraph 0.4.5 I made all of the changes at
http://code.google.com/p/igraph/issues/detail?id=1
*except* for those to rinterface.c (I know very little about C and it  
wasn't clear what changes should be made).
This still left some errors with pottsmodel_2.cpp ('Overloading  
ambiguity between "std::log(double)" and "std::log(long double)"'),  
which I worked around by replacing the offending instances of  
"log(foo)" with "log(static_cast(foo))". (again, C and C++ are  
mostly black boxes to me, so I have no idea if this was the right  
thing to do)

I compiled and installed using:
R CMD INSTALL --configure-args="CC='gcc'" igraph

and still, library(igraph) gives me:
Error in dyn.load(x, as.logical(local), as.logical(now)) :
 unable to load shared library '/home/mcmahan/R/i386-pc- 
solaris2.10-library/2.5/igraph/libs/igraph.so':
   ld.so.1: R: fatal: relocation error: file /home/mcmahan/R/i386-pc- 
solaris2.10-library/2.5/igraph/libs/igraph.so: symbol __1cDstdEcerr_:  
referenced symbol not found
Error : .onLoad failed in 'loadNamespace' for 'igraph'
Error: package/namespace load failed for 'igraph'

At this point I think I'm going to give up getting it working. The  
initial reason to use the remote solaris system was for convenience —  
to run some long-running code on a remote machine rather than my  
laptop — but it seems like it will be easier to just run it here.

Thanks, everybody, for all of your help and patience.
Peter

On Jan 9, 2008, at 2:17 AM, Gabor Csardi wrote:

> On Wed, Jan 09, 2008 at 08:03:59AM +, Prof Brian Ripley wrote:
> [...]
>>
>> You say you are using gcc, but that would be relevant to the Sun C++
>> compiler (see the R-admin manual, which also says that configure  
>> adds it
>> where needed).  So which C++ compiler is this?  The symptoms do  
>> look as if
>> you are mixing incompatible C and C++ compilers.
>>
>> I don't have anything like as old components as you have, but igraph
>> contains C++ errors and will not compile under the SunStudio 12 C++
>> compiler (reported to the maintainer a long time ago).  It did work  
>> for me
>> just now using gcc/g++ 4.2.1 and R 2.6.1 patched.
>
> Brian, indeed, i made the fixes you sent me, but it seems that only
> in the development branch of igraph not in the one which is on CRAN.
> Anyway, i'll fix them in both. Thanks again.
>
> Peter, here are the changes you need to make to the source if  
> compiling
> with the Sun Studio compiler:
> http://code.google.com/p/igraph/issues/detail?id=1
> (although it seems that the easiest is compiling with gcc/g++).
>
> Gabor
>
>>> Any ideas? My system info is:
>>> SunOS 5.10 i386  Generic_120012-14 09-19-2007
>>> gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
>>> R version 2.5.1 (2007-06-27)
>>> igraph version 0.4.5 (with a few changes to compile on Solaris)
>>
>> Since no changes are needed to compile under gcc, this suggests you  
>> are
>> not using gcc's C++ compiler.
>>
>>> thanks,
>>> Peter
>>
>> -- 
>> Brian D. Ripley,  [EMAIL PROTECTED]
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford, Tel:  +44 1865 272861 (self)
>> 1 South Parks Road, +44 1865 272866 (PA)
>> Oxford OX1 3TG, UKFax:  +44 1865 272595
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> -- 
> Csardi Gabor <[EMAIL PROTECTED]>MTA RMKI, ELTE TTK
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] pairwise cross tabulation tables

2008-01-10 Thread Charles C. Berry
On Thu, 10 Jan 2008, AndyZon wrote:

>
> Thank you so much, Chuck!
>
> This is brilliant, I just tried some dichotomous variables, it was really
> fast.


Yes, and if you are on a multicore system with multithreaded linear 
algebra, crossprod() will distribute the job across the cores making the 
elapsed time shorter (by almost half on my Core 2 Duo MacBook as long as I 
have nothing else gobbling up CPU cycles)!

>
> Most categorical variables I am interested in are 3 levels, they are
> actually SNPs, I want to look at their interactions. My question is: after
> generating 0-1 codings, like 00, 01, 10, how should I use "crossprod()"?
> Should I just apply this function on these 2*n columns (originally I have n
> variables), and then operate on the generated cell counts?


If I followed you here, and you have ONLY those three categories, then 
yes.

Try a test case with perhaps 3 SNPs and a few subjects. Table the results 
the old fashioned way via table() or xtabs() or even by hand. Then look at 
what crossprod( test.case } gives you.

---

If '11' shows up you'll have to use a 'contr.treatment' style 
approach. ( run 'example( contrasts )' and look at what is going on).

Guess what these give:

contrasts( factor( c( "00","01","10" ) ) )
contrasts( factor( c( "00","01","10","11" ) ) )

then run them if you have trouble seeing why '11' changes the picture.

---

BTW, what I said (below) suggests that crossprod() returns integer 
values, but its storage.mode is actually "double".

HTH,

Chuck

I am confused
> about this.
>
> Your input will be greatly appreciated.
>
> Andy




>
>
>
> Charles C. Berry wrote:
>>
>> On Wed, 9 Jan 2008, AndyZon wrote:
>>
>>>
>>> Hi,
>>>
>>> I have a huge number of categorical variables, say at least 1, and I
>>> put
>>> them into a matrix, each column is one variable. The question is: how can
>>> I
>>> make all of the pairwise cross tabulation tables efficiently? The
>>> straightforward solution is to use for-loops by looping two indexes on
>>> the
>>> table() function, but it was just too slow. Is there a more efficient way
>>> to
>>> do that? Any guidance will be greatly appreciated.
>>
>> The totals are merely the crossproducts of a suitably constructed binary
>> (zero-one) matrix is used to encode the categories. See '?contr.treatment'
>> if you cannot grok 'suitably constructed'.
>>
>> If the categories are all dichotomies coded as 0:1, you can use
>>
>>  res <- crossprod( dat )
>>
>> to find the totals for the (1,1) cells
>>
>> If you need the full tables, you can get them from the marginal totals
>> using
>>
>>  diag( res )
>>
>> to get the number in each '1' margin and
>>
>>  nrow(dat)
>>
>> to get the table total from which the numbers in each '0' margin by
>> subtracting the corresponding '1' margin.
>>
>> With dichotomous variables, dat has 1 columns and you will only need
>> 1^2 integers or about 0.75 Gigabytes to store the 'res'. And it takes
>> about 20 seconds to run 1000 rows on my MacBook. Of course, 'res' has a
>> redundant triangle
>>
>> This approach generalizes to any number of categories:
>>
>> To extend this to more than two categories, you will need to do for each
>> such column what model.matrix(~factor( dat[,i] ) ) does by default
>> ( using 'contr.treatment' ) - construct zero-one codes for all but one
>> (reference) category.
>>
>> Note that with 1 trichotomies, you will have a result with
>>
>>  1^2 * ( 3-1 )^2
>>
>> integers needing about 3 Gigabytes, and so on.
>>
>> HTH,
>>
>> Chuck
>>
>> p.s. Why on Earth are you doing this
>>
>>
>>>
>>> Andy
>>> --
>>> View this message in context:
>>> http://www.nabble.com/pairwise-cross-tabulation-tables-tp14723520p14723520.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.
>>>
>>
>> Charles C. Berry(858) 534-2098
>>  Dept of Family/Preventive
>> Medicine
>> E mailto:[EMAIL PROTECTED]   UC San Diego
>> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> -- 
> View this message in context: 
> http://www.nabble.com/pairwise-cross-tabulation-tables-tp14723520p14744086.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/li

Re: [R] installing and using a package

2008-01-10 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, January 10, 2008 4:06 PM
> To: r-help@r-project.org
> Subject: [R] installing and using a package
> 
> i'm trying to learn R. i have no programing experience. i 
> tried to add on
> a package and just picked "yags". i can't get it to work or 
> get any help.
> 
> ---
> > install.packages("yags")
> Warning in install.packages("yags") :
>   argument 'lib' is missing: using 'C:\Documents and Settings\j\My
> Documents/R/win-library/2.6'
> trying URL
> 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6/ya
> gs_4.0-2.zip'
> Content type 'application/zip' length 183779 bytes (179 Kb)
> opened URL
> downloaded 179 Kb
> 
> package 'yags' successfully unpacked and MD5 sums checked
> 
> The downloaded packages are in
> C:\Documents and Settings\j\Local
> Settings\Temp\RtmpXGE7rd\downloaded_packages
> updating HTML package descriptions
> ---
> 
> then i tried:
> 
> ---
> > help("yags")
> No documentation for 'yags' in specified packages and libraries:
> you could try 'help.search("yags")'
> ---
> 
> help.search doesn't help. when i type library() the result says:
> 
> ---
> Packages in library 'C:\Documents and Settings\j\My
> Documents/R/win-library/2.6':
> 
> yags  Yet Another GEE Solver
> 
> Packages in library 'C:/PROGRA~1/R/R-26~1.0/library':
> 
> base  The R Base Package
> boot  Bootstrap R (S-Plus) Functions (Canty)
> class Functions for Classification
> cluster   Cluster Analysis Extended 
> Rousseeuw et al.
> ...
> ---
> 
> i've checked the Admin and Maint manual, but i'm stumped as 
> to how to get
> yags to actually work. i copied and pasted the example from 
> the html file
> in the yags folder and after every line that called yags, there was an
> error message that said:
> Error: could not find function "yags".
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

You need to read the "An Introduction to R" manual which was probably installed 
when you installed R on your un-named OS (Windows, I take it).  You probably 
also want to read the posting-guide referenced at the bottom of the email.  But 
to get you started, you need to load a package before using it.  In your case 

library(yags) 

should get you started.  Hope this is helpful,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204
 
 

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


Re: [R] installing and using a package

2008-01-10 Thread Peter McMahan
R distinguishes between "installing" and "loading" a package. It looks  
like your installation of yags went fine. Now type
library(yags)
to load the package.
now help(yags) should bring up something, as should example(yags) .

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


Re: [R] installing and using a package

2008-01-10 Thread Charles Annis, P.E.
I'm not sure what you have done but using a package requires two steps:
1) installing or downloading the package, 
2) loading an installed package.

Since you are using windows you can click on Packages, Install packages, and
after choosing a CRAN mirror, selecting the package you want.  R will do the
rest and tell you that it has installed the package (which it apparently has
in your case).

Now click on Packages again and choose Load package.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Thursday, January 10, 2008 7:07 PM
To: r-help@r-project.org
Subject: [R] installing and using a package

i'm trying to learn R. i have no programing experience. i tried to add on
a package and just picked "yags". i can't get it to work or get any help.

---
> install.packages("yags")
Warning in install.packages("yags") :
  argument 'lib' is missing: using 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6'
trying URL
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6/yags_4.0-2.zip'
Content type 'application/zip' length 183779 bytes (179 Kb)
opened URL
downloaded 179 Kb

package 'yags' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\j\Local
Settings\Temp\RtmpXGE7rd\downloaded_packages
updating HTML package descriptions
---

then i tried:

---
> help("yags")
No documentation for 'yags' in specified packages and libraries:
you could try 'help.search("yags")'
---

help.search doesn't help. when i type library() the result says:

---
Packages in library 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6':

yags  Yet Another GEE Solver

Packages in library 'C:/PROGRA~1/R/R-26~1.0/library':

base  The R Base Package
boot  Bootstrap R (S-Plus) Functions (Canty)
class Functions for Classification
cluster   Cluster Analysis Extended Rousseeuw et al.
...
---

i've checked the Admin and Maint manual, but i'm stumped as to how to get
yags to actually work. i copied and pasted the example from the html file
in the yags folder and after every line that called yags, there was an
error message that said:
Error: could not find function "yags".

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

2008-01-10 Thread jiho
Hi everyone, Hi Hadley,

I am a heavy user of coord_equal() in ggplot2 since most of my data is  
spatial, on x,y coordinates. Everything works. However by enforcing an  
aspect ratio of 1 for the plotting region, coord_equal() usually  
wastes a lot of space if the region of interest is not a perfect square.

For example:
x=runif(10)
a=data.frame(x=x*3,y=x)
ggplot(data=a, aes(x=x,y=y)) + geom_point() + coord_equal()
produces a square plotting region while all the data is constrained in  
an horizontally extended rectangle. I would expect the coordinates to  
stay equal but the plot to be extended so that it fills as much as the  
plotting region as possible. It does not appear to be currently  
doable. Is it a limitation of ggplot? of the underlying grids  
graphics? Is there a workaround this?

Thanks in advance for your help.

PS:
x=runif(10)
qplot(x*3, x) + coord_equal()
produces some very strange scales. this looks like a bug to me.  
especially since:
foo=x
qplot(foo*3, foo) + coord_equal()
works as expected

PPS: I tried
ggplot(data=a, aes(x=x,y=y)) + geom_point() + coord_equal() +  
scale_y_continuous(limits=c(0,1))
which has no effect. but the side effect of enforcing the square  
domain is that:
ggplot(data=a, aes(x=x,y=y)) + geom_point() + coord_equal() +  
scale_y_continuous(limits=c(0,0.3))
has no effect either (i would expect to see only the points <0.3)

JiHO
---
http://jo.irisson.free.fr/

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


[R] error message translation

2008-01-10 Thread jpolo
sorry if my first msg was posted twice. this email system at school sucks.

i've looked in the Admin and Main manual and the Intro manual for
something that tells me what error messages mean, but haven't found
anything. where can i find the meanings of the error messages?

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


[R] installing and using a package

2008-01-10 Thread jpolo
i'm trying to learn R. i have no programing experience. i tried to add on
a package and just picked "yags". i can't get it to work or get any help.

---
> install.packages("yags")
Warning in install.packages("yags") :
  argument 'lib' is missing: using 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6'
trying URL
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6/yags_4.0-2.zip'
Content type 'application/zip' length 183779 bytes (179 Kb)
opened URL
downloaded 179 Kb

package 'yags' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\j\Local
Settings\Temp\RtmpXGE7rd\downloaded_packages
updating HTML package descriptions
---

then i tried:

---
> help("yags")
No documentation for 'yags' in specified packages and libraries:
you could try 'help.search("yags")'
---

help.search doesn't help. when i type library() the result says:

---
Packages in library 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6':

yags  Yet Another GEE Solver

Packages in library 'C:/PROGRA~1/R/R-26~1.0/library':

base  The R Base Package
boot  Bootstrap R (S-Plus) Functions (Canty)
class Functions for Classification
cluster   Cluster Analysis Extended Rousseeuw et al.
...
---

i've checked the Admin and Maint manual, but i'm stumped as to how to get
yags to actually work. i copied and pasted the example from the html file
in the yags folder and after every line that called yags, there was an
error message that said:
Error: could not find function "yags".

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


[R] installing and using a package

2008-01-10 Thread jpolo
i'm trying to learn R. i have no programing experience. i tried to add on
a package and just picked "yags". i can't get it to work or get any help.

---
> install.packages("yags")
Warning in install.packages("yags") :
  argument 'lib' is missing: using 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6'
trying URL
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6/yags_4.0-2.zip'
Content type 'application/zip' length 183779 bytes (179 Kb)
opened URL
downloaded 179 Kb

package 'yags' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\j\Local
Settings\Temp\RtmpXGE7rd\downloaded_packages
updating HTML package descriptions
---

then i tried:

---
> help("yags")
No documentation for 'yags' in specified packages and libraries:
you could try 'help.search("yags")'
---

help.search doesn't help. when i type library() the result says:

---
Packages in library 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6':

yags  Yet Another GEE Solver

Packages in library 'C:/PROGRA~1/R/R-26~1.0/library':

base  The R Base Package
boot  Bootstrap R (S-Plus) Functions (Canty)
class Functions for Classification
cluster   Cluster Analysis Extended Rousseeuw et al.
...
---

i've checked the Admin and Maint manual, but i'm stumped as to how to get
yags to actually work. i copied and pasted the example from the html file
in the yags folder and after every line that called yags, there was an
error message that said:
Error: could not find function "yags".

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


Re: [R] Omnibus main effects in summary.lme?

2008-01-10 Thread Andrew Beckerman
Adam -

Without resorting to the rather rich lmer/lme4 discussion realm, you  
need to base anova() comparisons of lme models with different fixed  
effects on maximum liklihood estimates rather tham REML.

anova(update(l2,method="ML"),update(l2,~.-useful:nusience,method="ML"))

should avoid the error and give a conservative estimate of the  
significance of your interaction.

see also:
http://tolstoy.newcastle.edu.au/R/e2/help/06/10/3565.html

and related posts.

A

-
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/
--


On 10 Jan 2008, at 22:32, Adam D. I. Kramer wrote:

> Hello,
>
>   I've been running some HLMs using the lme function quite happily; it
> does what I want and I'm pretty sure I understand it.
>
>   The issue is that I'm currently trying to estimate a model with a
> 14-level "nusiance" factor as an independent variable...which makes  
> the
> output quite ugly. All I'm really interested in is the question of  
> whether
> these factor as a whole (and its interactions with other factors) are
> significant.
>
>   The summary.aov function provides this sort of aggregation for lm
> objects, but does not run on lme objects. I've also tried estimating  
> the
> full model and restricted model, leaving out a main effect or  
> interaction
> term and then using anova.lme to compare the models, but these  
> models appear
> to be being fit differently. Say I have l2, and then
>
> l3 <- update(l2, .~.-useful:nusience)
> anova.lme(l3,l2)
>
> ...to see whether the interaction term is significant, produces the  
> error,
> "Fitted objects with different fixed effects. REML comparisons are not
> meaningful." Upon examination using summary(l3), it seems that the  
> fixed
> factors are indeed different.
>
>   So, my question is this: How do I estimate omnibus main effects for
> multi-level factors and multi-level factor interactions in lme models?
>
> Many thanks,
> Adam D. I. Kramer
> Ph.D. Student, Social and Personality Psychology
> University of Oregon
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Cycle Regression Analysis in R?

2008-01-10 Thread roger koenker
Peter Bloomfield's Fourier Analysis of Time Series is a good
reference for this sort of thing...


On Jan 10, 2008, at 5:25 PM, Gabor Grothendieck wrote:

> To do it from first principles using nonlinear optimization see:
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/20100.html
>
> On Jan 10, 2008 5:27 PM, Carson Farmer <[EMAIL PROTECTED]> wrote:
>> Hello R community,
>>
>> Does anyone know of a package that will perform cycle regression
>> analysis? I have searched the R-help archives etc. but have come up  
>> with
>> nothing so far.
>> If I am unable to find an existing R package to do so, is there  
>> anyone
>> familiar with fitting sine functions to data.  My problem is this:
>> I have a long time-series of daily SWE estimates (SWE = snow water
>> equivalence, or the amount of water stored in a snowpack) which  
>> follows
>> a sinusoidal pattern, and I need to estimate the parameters of the  
>> sine
>> function that best fits this data. While there may be many  
>> contributing
>> sine functions and/or linear trends, I am only interested in a single
>> sine function that most closely fits the data (trends can be removed
>> separately if need be).  Perhaps some sort of non-linear least  
>> squares
>> method would be best?
>>
>> Any help, or suggestions to get me on the right track are greatly
>> appreciated.
>>
>> Carson
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Cycle Regression Analysis in R?

2008-01-10 Thread Gabor Grothendieck
To do it from first principles using nonlinear optimization see:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/20100.html

On Jan 10, 2008 5:27 PM, Carson Farmer <[EMAIL PROTECTED]> wrote:
> Hello R community,
>
> Does anyone know of a package that will perform cycle regression
> analysis? I have searched the R-help archives etc. but have come up with
> nothing so far.
> If I am unable to find an existing R package to do so, is there anyone
> familiar with fitting sine functions to data.  My problem is this:
> I have a long time-series of daily SWE estimates (SWE = snow water
> equivalence, or the amount of water stored in a snowpack) which follows
> a sinusoidal pattern, and I need to estimate the parameters of the sine
> function that best fits this data. While there may be many contributing
> sine functions and/or linear trends, I am only interested in a single
> sine function that most closely fits the data (trends can be removed
> separately if need be).  Perhaps some sort of non-linear least squares
> method would be best?
>
> Any help, or suggestions to get me on the right track are greatly
> appreciated.
>
> Carson
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Extracting last time value

2008-01-10 Thread Achim Zeileis
On Thu, 10 Jan 2008, Kondamani, Arjun (GMI - NY Corporate Bonds) wrote:

> I have a dataframe as follows:
>
> Date  timevalue
> 20110620  11:18:007
> 20110620  11:39:009
> 20110621  11:41:008
> 20110621  11:40:006
> 20110622  14:05:008
> 20110622  14:06:006
>
> For every date, I want to extract the row that has the greatest time.
> Therefore, ending up like:
> 20110620  11:39:009
> 20110621  11:41:008
> 20110622  14:07:006

You could use the time series functionality in "zoo" for this:

  ## data and package
  x <- read.table(textConnection("Date time value
2011062011:18:007
2011062011:39:009
2011062111:41:008
2011062111:40:006
2011062214:05:008
2011062214:06:006"),
header = TRUE, as.is = TRUE)
  library("zoo")

  ## turn data frame into a time series
  z <- zoo(x$value,
as.POSIXct(strptime(paste(x$Date, x$time), "%Y%m%d %H:%M:%S")))

  ## aggregate
  aggregate(z, as.Date, tail, 1)

  ## or if you want to retain the associated last time
  ix <- zoo(1:length(z), time(z))
  last.ix <- aggregate(ix, as.Date, tail, 1)
  z[as.numeric(last.ix)]

hth,
Z

> I am using for loops (for every date, find largest time value) to do
> this determination, but I am sure there is a simpler way in "R". Has
> anyone run into this before?
> 
>
> This message w/attachments (message) may be privileged, confidential or 
> proprietary, and if you are not an intended recipient, please notify the 
> sender, do not use or share it and delete it. Unless specifically indicated, 
> this message is not an offer to sell or a solicitation of any investment 
> products or other financial product or service, an official confirmation of 
> any transaction, or an official statement of Merrill Lynch. Subject to 
> applicable law, Merrill Lynch may monitor, review and retain e-communications 
> (EC) traveling through its networks/systems. The laws of the country of each 
> sender/recipient may impact the handling of EC, and EC may be archived, 
> supervised and produced in countries other than the country in which you are 
> located. This message cannot be guaranteed to be secure or error-free. This 
> message is subject to terms available at the following link: 
> http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch 
> you consent to the foregoing.
> 
>
>   [[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] Extracting last time value

2008-01-10 Thread jim holtman
This should do it:

> x <- read.table(textConnection("Datetimevalue
+ 2011062011:18:007
+ 2011062011:39:009
+ 2011062111:41:008
+ 2011062111:40:006
+ 2011062214:05:008
+ 2011062214:06:006"), header=TRUE, as.is=TRUE)
>
> x$time <- as.POSIXct(strptime(x$time, "%H:%M:%S"))
> do.call(rbind, lapply(split(x, x$Date), function(.day){
+ .day[which.max(.day$time),]
+ }))
 Datetime value
20110620 20110620 2008-01-10 11:39:00 9
20110621 20110621 2008-01-10 11:41:00 8
20110622 20110622 2008-01-10 14:06:00 6
>


On Jan 10, 2008 5:36 PM, Kondamani, Arjun (GMI - NY Corporate Bonds)
<[EMAIL PROTECTED]> wrote:
> I have a dataframe as follows:
>
> Datetimevalue
> 2011062011:18:007
> 2011062011:39:009
> 2011062111:41:008
> 2011062111:40:006
> 2011062214:05:008
> 2011062214:06:006
>
> For every date, I want to extract the row that has the greatest time.
> Therefore, ending up like:
> 2011062011:39:009
> 2011062111:41:008
> 2011062214:07:006
>
> I am using for loops (for every date, find largest time value) to do
> this determination, but I am sure there is a simpler way in "R". Has
> anyone run into this before?
> 
>
> This message w/attachments (message) may be privileged, confidential or 
> proprietary, and if you are not an intended recipient, please notify the 
> sender, do not use or share it and delete it. Unless specifically indicated, 
> this message is not an offer to sell or a solicitation of any investment 
> products or other financial product or service, an official confirmation of 
> any transaction, or an official statement of Merrill Lynch. Subject to 
> applicable law, Merrill Lynch may monitor, review and retain e-communications 
> (EC) traveling through its networks/systems. The laws of the country of each 
> sender/recipient may impact the handling of EC, and EC may be archived, 
> supervised and produced in countries other than the country in which you are 
> located. This message cannot be guaranteed to be secure or error-free. This 
> message is subject to terms available at the following link: 
> http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch 
> you consent to the foregoing.
> 
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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

2008-01-10 Thread Gang Chen
I'm running a categorical data analysis with a two-way design of  
nominal by ordinal structure like the Political Ideology Example  
(Table 9.5) in Agresti's book Categorical Data Analysis. The nominal  
variable is Method while the ordinal variable is Quality (Bad,  
Moderate, Good, Excellent). I rank/quantify Quality with another  
variable QualityR (1, 2, 3, 4), and run the following:

fm <- glm(Count ~  Quality + Method * QualityR, family=poisson, MyData)

I'm pretty happy with the significance testing of the main effects  
and contrasts. However after examining the following deviances, I'm  
concerned about the Poisson fitting of the data:

=
 Null deviance: 426.36  on 35  degrees of freedom
Residual deviance: 171.71  on 16  degrees of freedom
AIC: 369.78

Number of Fisher Scoring iterations: 6
=

If I interpret the deviances correctly, it seems the Poisson fitting  
only explains (426.36-171.71)/426.36 ~ 60% of the total variability  
in the data. Also with a residual deviance of 171.71  on 16  degrees  
of freedom, the p value is 3.83738e-28. So does it indicate Poisson  
is not a good model for the data? If not, how can I improve the  
fitting? Change the ranking numbers or switch to a different model?  
Sorry this seems more like a statistical question than R-related.

Thanks,
Gang





[[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] Extracting last time value

2008-01-10 Thread Kondamani, Arjun (GMI - NY Corporate Bonds)
I have a dataframe as follows:

Datetimevalue
2011062011:18:007
2011062011:39:009
2011062111:41:008
2011062111:40:006
2011062214:05:008
2011062214:06:006

For every date, I want to extract the row that has the greatest time.
Therefore, ending up like:
2011062011:39:009
2011062111:41:008
2011062214:07:006

I am using for loops (for every date, find largest time value) to do
this determination, but I am sure there is a simpler way in "R". Has
anyone run into this before?


This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.


[[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] Plotting a smooth curve through points

2008-01-10 Thread Anderson, Walter
I have a set of Monte Carlo simulation results for a Quick Response
Freight Model that I am currently preparing summary graphs. I want to
show three things on the graphs; the model forecast, an approximate
exponential best fit line, and a smooth line through mean+sd and mean-sd
data points.
 
As you can see I can get the first two, but all I can find when
searching the help are references to fitting spline models to the data
points.  I'm old school, so I was used to using a french curve to draw
the smooth lines I'm interested in.  The problem is that I don't
understand how/why of fitting a model to the data points.  
 
Here is an example of the data I am graphing:
year   mean sd
1  2010   6738 1721
2  2015   8793 2326
3  2020   11699   
4  2025   15951   5232
5  2030   22492   9768
6  2035   33289   24431
7  2040   52917   82341
 
And here is the R code I am currently using:
gr = function (yr,rate,trk)  trk*rate^(yr-2006)
 
plot.results <- function(dfn) {
  dt <- read.table(dfn)
  res.g = nls(dt$mean ~ gr(dt$year, R, T), start=c(R=1.08, T=3700),
data=dt)
  R <- as.numeric(coef(res.g)[1])
  T <- as.numeric(coef(res.g)[2])
  plot(dt$year,dt$mean, pch=1, col="green", main="Truck Forecast",
xlab="Year", ylab="Truck Volume", ylim=c(0,max(dt$year+dt$sd)))
  curve(gr(x, R, T), add=TRUE, col="green")
}

Any help is appreciated!
 

Walter Anderson, GISP
PBS&J
6504 Bridge Point Pkwy, Ste. 200
Austin, TX. 78730
P:512.342.3237
F:512.327.2453
M:512.364.8318

 

[[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] Omnibus main effects in summary.lme?

2008-01-10 Thread Adam D. I. Kramer
Hello,

I've been running some HLMs using the lme function quite happily; it
does what I want and I'm pretty sure I understand it.

The issue is that I'm currently trying to estimate a model with a
14-level "nusiance" factor as an independent variable...which makes the
output quite ugly. All I'm really interested in is the question of whether
these factor as a whole (and its interactions with other factors) are
significant.

The summary.aov function provides this sort of aggregation for lm
objects, but does not run on lme objects. I've also tried estimating the
full model and restricted model, leaving out a main effect or interaction
term and then using anova.lme to compare the models, but these models appear
to be being fit differently. Say I have l2, and then

l3 <- update(l2, .~.-useful:nusience)
anova.lme(l3,l2)

...to see whether the interaction term is significant, produces the error,
"Fitted objects with different fixed effects. REML comparisons are not
meaningful." Upon examination using summary(l3), it seems that the fixed
factors are indeed different.

So, my question is this: How do I estimate omnibus main effects for
multi-level factors and multi-level factor interactions in lme models?

Many thanks,
Adam D. I. Kramer
Ph.D. Student, Social and Personality Psychology
University of Oregon

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

2008-01-10 Thread Carson Farmer
Hello R community,

Does anyone know of a package that will perform cycle regression 
analysis? I have searched the R-help archives etc. but have come up with 
nothing so far.
If I am unable to find an existing R package to do so, is there anyone 
familiar with fitting sine functions to data.  My problem is this:
I have a long time-series of daily SWE estimates (SWE = snow water 
equivalence, or the amount of water stored in a snowpack) which follows 
a sinusoidal pattern, and I need to estimate the parameters of the sine 
function that best fits this data. While there may be many contributing 
sine functions and/or linear trends, I am only interested in a single 
sine function that most closely fits the data (trends can be removed 
separately if need be).  Perhaps some sort of non-linear least squares 
method would be best?

Any help, or suggestions to get me on the right track are greatly 
appreciated.

Carson

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


Re: [R] A Contrast Question

2008-01-10 Thread Peter Dalgaard
(Ted Harding) wrote:
> Hi Folks,
> This should have been simple to answer,
> but despite much chasing I don't seem able
> to catch this particular mouse!
>
> Basically (somewhat simplified): I have a
> binary response variable Y (0/1) and a
> 2-level factor A (0/1).
>
> I want to assign a contrast to A such that,
> when I run
>
> summary(glm(Y~A, family=binomial))$coef
>
> the Intercept coefficient is the result that
> I would get from running glm(Y ~ 1), and
> the "A" coefficient is the log(odds ratio)
> of the "A=1" results relative to all the data.
>
> Explicitly: if p = sum(Y==1)/length(Y),
> and p1 = sum(Y[A==1]==1)/length(Y[A==1])
> then:
>
> Intercept:  log(p/(1-p))
>
> Coeff of A: log((p1/(1-p1))/(p/(1-p)))
>
> (The objective is to assess whether a covariate
> that may result in only observing a subset of
> the data would produce a significant selection
> bias in the result).
>
> I know I could derive the result from manipulation
> of the output from a standard contrast function,
> but I would prefer to delegate it all (including
> calculation of SE and P-value) to a run of glm()
I don't think that is possible. The contrasts would have to depend on p, 
p0, and p1, and if they do, then you can't base SE calculations on the 
usual formulas. Can't you just use the delta method and begone with it?

--  
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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

2008-01-10 Thread Ted Harding
Hi Folks,
This should have been simple to answer,
but despite much chasing I don't seem able
to catch this particular mouse!

Basically (somewhat simplified): I have a
binary response variable Y (0/1) and a
2-level factor A (0/1).

I want to assign a contrast to A such that,
when I run

summary(glm(Y~A, family=binomial))$coef

the Intercept coefficient is the result that
I would get from running glm(Y ~ 1), and
the "A" coefficient is the log(odds ratio)
of the "A=1" results relative to all the data.

Explicitly: if p = sum(Y==1)/length(Y),
and p1 = sum(Y[A==1]==1)/length(Y[A==1])
then:

Intercept:  log(p/(1-p))

Coeff of A: log((p1/(1-p1))/(p/(1-p)))

(The objective is to assess whether a covariate
that may result in only observing a subset of
the data would produce a significant selection
bias in the result).

I know I could derive the result from manipulation
of the output from a standard contrast function,
but I would prefer to delegate it all (including
calculation of SE and P-value) to a run of glm().

With thanks,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 10-Jan-08   Time: 21:33:53
-- 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] pairwise cross tabulation tables

2008-01-10 Thread AndyZon

Thank you so much, Chuck!

This is brilliant, I just tried some dichotomous variables, it was really
fast.

Most categorical variables I am interested in are 3 levels, they are
actually SNPs, I want to look at their interactions. My question is: after
generating 0-1 codings, like 00, 01, 10, how should I use "crossprod()"?
Should I just apply this function on these 2*n columns (originally I have n
variables), and then operate on the generated cell counts?  I am confused
about this.

Your input will be greatly appreciated.

Andy



Charles C. Berry wrote:
> 
> On Wed, 9 Jan 2008, AndyZon wrote:
> 
>>
>> Hi,
>>
>> I have a huge number of categorical variables, say at least 1, and I
>> put
>> them into a matrix, each column is one variable. The question is: how can
>> I
>> make all of the pairwise cross tabulation tables efficiently? The
>> straightforward solution is to use for-loops by looping two indexes on
>> the
>> table() function, but it was just too slow. Is there a more efficient way
>> to
>> do that? Any guidance will be greatly appreciated.
> 
> The totals are merely the crossproducts of a suitably constructed binary 
> (zero-one) matrix is used to encode the categories. See '?contr.treatment' 
> if you cannot grok 'suitably constructed'.
> 
> If the categories are all dichotomies coded as 0:1, you can use
> 
>   res <- crossprod( dat )
> 
> to find the totals for the (1,1) cells
> 
> If you need the full tables, you can get them from the marginal totals 
> using
> 
>   diag( res )
> 
> to get the number in each '1' margin and
> 
>   nrow(dat)
> 
> to get the table total from which the numbers in each '0' margin by 
> subtracting the corresponding '1' margin.
> 
> With dichotomous variables, dat has 1 columns and you will only need 
> 1^2 integers or about 0.75 Gigabytes to store the 'res'. And it takes 
> about 20 seconds to run 1000 rows on my MacBook. Of course, 'res' has a 
> redundant triangle
> 
> This approach generalizes to any number of categories:
> 
> To extend this to more than two categories, you will need to do for each 
> such column what model.matrix(~factor( dat[,i] ) ) does by default
> ( using 'contr.treatment' ) - construct zero-one codes for all but one 
> (reference) category.
> 
> Note that with 1 trichotomies, you will have a result with
> 
>   1^2 * ( 3-1 )^2
> 
> integers needing about 3 Gigabytes, and so on.
> 
> HTH,
> 
> Chuck
> 
> p.s. Why on Earth are you doing this
> 
> 
>>
>> Andy
>> -- 
>> View this message in context:
>> http://www.nabble.com/pairwise-cross-tabulation-tables-tp14723520p14723520.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.
>>
> 
> Charles C. Berry(858) 534-2098
>  Dept of Family/Preventive
> Medicine
> E mailto:[EMAIL PROTECTED]UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/pairwise-cross-tabulation-tables-tp14723520p14744086.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] question regarding kpss tests from urca, uroot and tseries packages

2008-01-10 Thread markleeds
>From: eugen pircalabelu <[EMAIL PROTECTED]>
>Date: 2008/01/10 Thu PM 02:48:32 CST
>To: R-help <[EMAIL PROTECTED]>
>Subject: [R] question regarding kpss tests from urca,  uroot and tseries 
>packages

Schwert has an algorithm for deciding on the
number of lags to use in an adf test but i
can't say if you can apply the same algorithm
to kpss ? google for schwert's algorithm
and mnaybe he will mention some useful reference. 
this hypothesis testing in time series stuff 
is art rather than science
so there maybe an algorithm out there but
there is no hard and fast perfect rule
that's going to be correct all the time.

just to give you some short background
in term of adf: 

generally speaking to
decide on whether there is a unit root using adf, the lagged residuals need to
be not serially correlated under the null
hypothesis. so, when you choose a lag
basically you are deciding how many lags of
x do i use in my null model so that there
is no serial correlation in the residuals.

if you put too few lags in, then you end up
with correlated residuals and  the test
is wrong. if you put too many in, you
lose power ( the ability to reject the null )
and that's not good either.

i'm not sure if all of the above applied
to KPSS because i forget the detials of
how it's done but it's probably related.

to get some background in time series,
you should read hamilton if you're brave
or enders if you just want to get a quick
( pretty non mathematical ) idea but great 
intution. good luck. i replied privately
because others may say stuff more useful
so why not see that also. plus
i didn't answer your question.

mark


 
   














>Hi R users!
>
>I've come across using kpss tests for time series analysis and i have a 
>question that troubles me since i don't have much experience with time series 
>and the mathematical part underlining it.
>
>x<-c(253, 252, 275, 275, 272, 254, 272, 252, 249, 300, 244, 
>258, 255, 285, 301, 278, 279, 304, 275, 276, 313, 292, 302, 
>322, 281, 298, 305, 295, 286, 327, 286, 270, 289, 293, 287, 
>267, 267, 288, 304, 273, 264, 254, 263, 265, 278)
>x <- ts(x, frequency = 12)
>library (urca)
>library (uroot)
>library (tseries) 
> 
>Now, doing an ur.kpss test (mu, lag=3) i cannot reject the null  hypothesis of 
> level stationarity.
>Doing a kpss.test (mu, lag=1 by default ) the p value becomes smaller than 
>0.05 thus rejecting the null of stationarity. Same with KPSS.test (lag=1)
>
>So, as i have noticed that increasing the number of lags on each of the tests 
>rejecting the null becomes harder and harder. I saw that books always cite use 
>of Bartlett window but the lags determination is left to the analyst. My 
>question: which is the "proper" number of lags, so i don't make any false 
>statements on the data? 
>
>Thank you and have a great day!
> 
>
>   
>-
>
>   [[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] question regarding kpss tests from urca, uroot and tseries packages

2008-01-10 Thread eugen pircalabelu
Hi R users!

I've come across using kpss tests for time series analysis and i have a 
question that troubles me since i don't have much experience with time series 
and the mathematical part underlining it.

x<-c(253, 252, 275, 275, 272, 254, 272, 252, 249, 300, 244, 
258, 255, 285, 301, 278, 279, 304, 275, 276, 313, 292, 302, 
322, 281, 298, 305, 295, 286, 327, 286, 270, 289, 293, 287, 
267, 267, 288, 304, 273, 264, 254, 263, 265, 278)
x <- ts(x, frequency = 12)
library (urca)
library (uroot)
library (tseries) 
 
Now, doing an ur.kpss test (mu, lag=3) i cannot reject the null  hypothesis of  
level stationarity.
Doing a kpss.test (mu, lag=1 by default ) the p value becomes smaller than 0.05 
thus rejecting the null of stationarity. Same with KPSS.test (lag=1)

So, as i have noticed that increasing the number of lags on each of the tests 
rejecting the null becomes harder and harder. I saw that books always cite use 
of Bartlett window but the lags determination is left to the analyst. My 
question: which is the "proper" number of lags, so i don't make any false 
statements on the data? 

Thank you and have a great day!
 

   
-

[[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] general linear hypothesis glht() to work with lme()

2008-01-10 Thread array chip
Hi I updated my R version to 2.6.1, now glht() worked
with lme() from nlmn package. thanks for responding.

Now I have a questions: can I use the contrast() from
contrast package to do the comparison that I am
interested in?

The comparison that I am intersted is to test the
linear relationship among the 3 levels ('b','m','t')
of the fixed effect "type"? how to specify that
comparison? Using glht(), it is easy to specify by:

batch<-as.factor(rep(1:4,3,each=20))
type<-as.factor(rep(c('b','m','t'),each=80))
y<-2*(type=='m')+4*(type=='t')+rnorm(240,100,20)
dat<-cbind(as.data.frame(y),type=type,batch=batch)
rm(batch,type,y)

library(nlme)
dat.lme<-lme(y~type, random=~1|batch/type, data=dat)

library(multcomp)
summary(glht(dat.lme, linfct = mcp(type
=c("b+t-2*m=0"))),test=Chisqtest())

However, after looking at the examples from the help
page of contrast(), I still couldn't figure out how to
specify that comparison.

Thanks for any suggestions.




--- Dieter Menne <[EMAIL PROTECTED]> wrote:

> array chip  yahoo.com> writes:
> 
> (Real names are prefered here)
> 
> > I am trying to test some contrasts, using glht()
> in
> > multcomp package on fixed effects in a linear
> mixed
> > model fitted with lme() in nlme package. The
> command I
> > used is:
> > data=dat)
> > glht(dat.lme, linfct = mcp(type =c("b+t-2*m=0")))
> > 
> > The lme model fit is ok, but I got an error
> message
> > with glht():
> > Error in eval(expr, envir, enclos) : object
> > "info.index" not found
> > Error in factor_contrasts(model) : no
> 'model.matrix'
> > method for 'model' found!
> > 
> > according to help page of glht(), it should work
> with
> > linear mixed model, what is the problem here?
> 
> 
> Here an example from Torsten Hothorn (author of
> multcomp), both for lme 
> and lmer :
> To get a better answer, please  provide the
> (simulated?) data for your example
> as required by the posting guide,
> 
> # multcomplme.r
> nlmeOK <- require("nlme")
> lme4OK <- require("lme4")
> library("multcomp")
> K <- rbind(c(0,1,-1,0),c(0,1,0,-1),c(0,0,1,-1))
> data("ergoStool", package = "nlme")
> stool.lmer <- lmer(effort ~ Type + (1 | Subject),
> data = ergoStool)
> glme4 <- glht(stool.lmer,K)
> summary(glme4)
> 
> 
> #Linear Hypotheses:
> #Estimate Std. Error z value p value
> #1 == 0   1.6667 0.5187   3.213 0.00376 **
> #2 == 0   3. 0.5187   6.212 < 0.001 ***
> #3 == 0   1.5556 0.5187   2.999 0.00761 **
> stool.lme <- lme(effort ~ Type, data = ergoStool,
>  random = ~ 1 | Subject)
> gnlme <- glht(stool.lme,K)
> summary(gnlme)
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



  

Looking for last minute shopping deals?

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


Re: [R] `[.data.frame`(df3, , -2) and NA columns

2008-01-10 Thread Tony Plate
Assigning a name vector to a dataframe that is shorter than the number of 
columns results in some columns having NA values for their names.

"[.data.frame" has the following code in it:

 cols <- names(x)
 ...
 if (any(is.na(cols)))
 stop("undefined columns selected")

so, if a dataframe x has NA values for column names, you should expect 
x[...] to *sometimes* stop with that error (with a bit of reading and 
testing you could probably work out exactly when that error will occur).

-- Tony Plate

Dieter Menne wrote:
> Dear baseRs,
> 
> I recently made a mistake when renaming data frame columns, accidentally
> creating an NA column. I found the following strange behavior when negative
> indexes are used.
> 
> Can anyone explain what happens here.  No "workarounds" required, just  
> curious.
> 
> Dieter
> 
> Version: Windows, R version 2.6.1 (2007-11-26)
> 
> #-
> df = data.frame(a=0:10,b=10:20)
> df[,-2] #ok
> names(df)=c("A") # implicitly creates an NA column
> df[,-2] 
> df[,-2,drop=FALSE]   # has nothing to do with drop
> 
> df3 = data.frame(a=0:10,b=10:20,c=20:30)
> df3[,-2] #ok
> names(df3)=c("A","B") #creates an NA column
> df3[,-2] # error
> # Error in `[.data.frame`(df3, , -2) : undefined columns selected
> 
> names(df3)[3]="NaN" # another reserved word
> df3[,-2] # no problem
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Writing custom functions for rpart

2008-01-10 Thread R Help
I'm having a similar problem, and after looking through the test
directory I believe I have it down pat, but would someone mind telling
me if I have it correctly, and if not, what I need to fix?

eval: this seems to be the evaluation of a node, used for for labeling
it with whatever decision method is being used.

split: this seems to be the split decision itself.  I have a small
problem here, because I don't understand exactly how this function
will be called.  I assume that, for each covariate in the problem this
will be called ONCE, and then among all the returned "goodness"
values, the largest is chosen and a decision is made.

init: I don't understand the purpose of this function at all, and I
was going to just try and copy the one from anovatest.s, but if
someone can explain it to me it would be appreciated.

I'm also wondering: overall, do my three functions need to accept the
exact same variables that temp1, temp2 and temp3 do?  It seems to me
that they would have to for them to be called by another program, but
if this is the case then I don't know what to do with wt or parms?

Thanks,
Sam Stewart

On May 9, 2007 10:38 AM, hadley wickham <[EMAIL PROTECTED]> wrote:
> On 5/9/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> > On Wed, 9 May 2007, hadley wickham wrote:
> >
> > > Hi everyone,
> > >
> > > Does anyone has experience with (or documentation for) writing custom
> > > methods with rpart? The documentation hints: "Alternatively, 'method'
> > > can be a list of functions 'init', 'split' and 'eval'", but doesn't
> > > provide any details as to what those methods should do or what
> > > arguments they should take etc.
> > >
> > > I've tried looking at the package source (and the source for the S
> > > code it came from) but I can't follow what's going on in C vs R, and
> > > as the default methods are coded in a different way, there are no
> > > examples to follow.
> >
> > But there are, in the tests directory.
>
> Thanks, I had missed those.  Perhaps a pointer from the documentation
> would be appropriate?
>
> Hadley
>
>
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/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] OS X binary: 32 or 64-bit?

2008-01-10 Thread Charles C. Berry

Robert,

If you downloaded the binary from CRAN, it uses a 32-bit address space.

Here are some links that may help with getting a 64-bit build:

http://article.gmane.org/gmane.comp.lang.r.mac/2226
http://r.research.att.com/

Also, there is a list for MACs

https://stat.ethz.ch/mailman/listinfo/r-sig-mac

HTH,

Chuck

On Thu, 10 Jan 2008, Robert Terwilliger wrote:

> Dear R Experts,
>
> I am using R.app (the Mac OS X binary) for neuroimage analysis, so I
> am loading in some large image files. I get the following error in the
> middle of my script:
>
>> source("3dLME.R")
> Read 1 record
> Read 1 record
> Read 1 record
> Read 1 record
> Read 1 record
> Error: cannot allocate vector of size 3.1 Gb
> R(2081,0xa000d000) malloc: *** vm_allocate(size=3321675776) failed
> (error code=3)
> R(2081,0xa000d000) malloc: *** error: can't allocate region
> R(2081,0xa000d000) malloc: *** set a breakpoint in szone_error to debug
> R(2081,0xa000d000) malloc: *** vm_allocate(size=3321675776) failed
> (error code=3)
> R(2081,0xa000d000) malloc: *** error: can't allocate region
> R(2081,0xa000d000) malloc: *** set a breakpoint in szone_error to debug
>
> My Mac is 64-bit, however, I'm wondering if R is compiled as a 32-bit app?
>
> Many thanks,
>
> Robert Terwilliger
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2008-01-10 Thread Vishal Belsare
I have some time series data which I am interested in plotting. The
standard function for plotting ts, or zoo objects work fine, however,
I am curious about plotting long time series with a dynamic aspect
ratio. My point is this, say I have a time series of 4000
observations, so the image width is x units and height is y units. Now
after updating my data, my time series has 6000 observations. The way
plots happen are, the image fits to the screen, or a standard aspect
ratio I assume. Can I have the plot then change to 1.5x units wide and
y units high?

Perhaps a visual analogy would be: a electrocardiogram which prints
out of an ecg machine. the pulses are plotting on one damn long paper
:)


Vishal

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


Re: [R] diff in a dataframe

2008-01-10 Thread Gabor Grothendieck
This is consistent with how matrices and ts series in R work: they all
use x[,j] only.

On Jan 10, 2008 1:08 PM, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> Thanks Henrique, Don and Gabor. I did come around to solving it by
> using the zoo library. Very useful stuff that one for handling a bunch
> of long irregular time series.
>
> Gabor, thanks for your present and previous responses. The quickref
> was indeed helpful. I do have another question regarding zoo however.
> Say I have a zoo object named X and say it has 200 time series within
> it. Each has a unique column name. I tried to retrieve merely one
> column (time series) from X, trying variously: X$columnname, or
> X["columnname"] or X[["columnname"]] in the hope that I would be able
> to get that one time series, but the only way which seemed to work is
> X[,"columnname"]
>
> Is that the 'correct' way to retrieve a single time series from a zoo
> of multiple time series? I would think that it'd be cooler if we could
> merely do a : X$columnname sort of thing. Please enlighten. Thanks
> much!
>
> Cheers,
>
> Vishal
>
>
>
> On Jan 10, 2008 10:40 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > Represent this as a time series.  Using
> > the zoo package:
> >
> > > library(zoo)
> > > z <- zoo(cbind(price_g = c(0.34, 0.36), price_s = c(0.56, 0.76)), 
> > > as.Date(c("2000-01-01", "2000-01-05")))
> > > diff(log(z))
> >   price_g   price_s
> > 2000-01-05 0.05715841 0.3053816
> > > diff(log(z), na.pad = TRUE)
> >   price_g   price_s
> > 2000-01-01 NANA
> > 2000-01-05 0.05715841 0.3053816
> >
> >
> > See the two zoo vignettes:
> > vignette("zoo")
> > vignette("zoo-quickref")
> >
> >
> > On Jan 10, 2008 2:16 AM, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> > > I have a dataframe say:
> > >
> > > date   price_g   price_s
> > > 0.340.56
> > > 0.360.76
> > >   .  .
> > >   .  .
> > >   .  .
> > >
> > > and so on. say, 1000 rows.
> > >
> > > Is it possible to add two columns to this dataframe, by computing say
> > > diff(log(price_g) and diff(log(price_s)) ?
> > >
> > > The elements in the first row of these columns cannot be computed, but
> > > can I coerce this to happen and assign a missing value there? It would
> > > be really great if I could do that, because in this case I don't have
> > > to re-index my transformed series to the dates again in a new
> > > dataframe.
> > >
> > > Thanks in anticipation.
> > >
> > >
> > > Vishal Belsare
> > >
> >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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] diff in a dataframe

2008-01-10 Thread Vishal Belsare
Thanks Henrique, Don and Gabor. I did come around to solving it by
using the zoo library. Very useful stuff that one for handling a bunch
of long irregular time series.

Gabor, thanks for your present and previous responses. The quickref
was indeed helpful. I do have another question regarding zoo however.
Say I have a zoo object named X and say it has 200 time series within
it. Each has a unique column name. I tried to retrieve merely one
column (time series) from X, trying variously: X$columnname, or
X["columnname"] or X[["columnname"]] in the hope that I would be able
to get that one time series, but the only way which seemed to work is
X[,"columnname"]

Is that the 'correct' way to retrieve a single time series from a zoo
of multiple time series? I would think that it'd be cooler if we could
merely do a : X$columnname sort of thing. Please enlighten. Thanks
much!

Cheers,

Vishal


On Jan 10, 2008 10:40 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Represent this as a time series.  Using
> the zoo package:
>
> > library(zoo)
> > z <- zoo(cbind(price_g = c(0.34, 0.36), price_s = c(0.56, 0.76)), 
> > as.Date(c("2000-01-01", "2000-01-05")))
> > diff(log(z))
>   price_g   price_s
> 2000-01-05 0.05715841 0.3053816
> > diff(log(z), na.pad = TRUE)
>   price_g   price_s
> 2000-01-01 NANA
> 2000-01-05 0.05715841 0.3053816
>
>
> See the two zoo vignettes:
> vignette("zoo")
> vignette("zoo-quickref")
>
>
> On Jan 10, 2008 2:16 AM, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> > I have a dataframe say:
> >
> > date   price_g   price_s
> > 0.340.56
> > 0.360.76
> >   .  .
> >   .  .
> >   .  .
> >
> > and so on. say, 1000 rows.
> >
> > Is it possible to add two columns to this dataframe, by computing say
> > diff(log(price_g) and diff(log(price_s)) ?
> >
> > The elements in the first row of these columns cannot be computed, but
> > can I coerce this to happen and assign a missing value there? It would
> > be really great if I could do that, because in this case I don't have
> > to re-index my transformed series to the dates again in a new
> > dataframe.
> >
> > Thanks in anticipation.
> >
> >
> > Vishal Belsare
> >
>
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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 calculate time offset between timezones?

2008-01-10 Thread dankelley

Since designations such as "AST" are used in the data files that I'm parsing,
I guess I'll make up a list of my own conversions, perhaps based on 

http://www.timeanddate.com/library/abbreviations/timezones/

(I cite this website not because I know it to be authoritative, but just in
case it provides a good start for someone else who has similar needs, and
happens upon this thread.)

Thanks, Whit and Brian, for the kind advice.


-- 
View this message in context: 
http://www.nabble.com/how-to-calculate-time-offset-between-timezones--tp14736453p14740042.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] leave one out cross validation

2008-01-10 Thread Prof Brian Ripley
Please look at ?lm.influence -- this does all the work for you.

On Thu, 10 Jan 2008, Anu Swatantran wrote:

> Hi
>
> I am trying to validate my regression results using the leave one out crosss
> validation method. Is any script available in R to use this method for a
> linear regression equation?
> Both R or SPLUS would do. any clues on how to write the script will also
> help.
>
> Thanks a lot,
> A
>
>   [[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.
>

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

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


[R] OS X binary: 32 or 64-bit?

2008-01-10 Thread Robert Terwilliger
Dear R Experts,

I am using R.app (the Mac OS X binary) for neuroimage analysis, so I
am loading in some large image files. I get the following error in the
middle of my script:

> source("3dLME.R")
Read 1 record
Read 1 record
Read 1 record
Read 1 record
Read 1 record
Error: cannot allocate vector of size 3.1 Gb
R(2081,0xa000d000) malloc: *** vm_allocate(size=3321675776) failed
(error code=3)
R(2081,0xa000d000) malloc: *** error: can't allocate region
R(2081,0xa000d000) malloc: *** set a breakpoint in szone_error to debug
R(2081,0xa000d000) malloc: *** vm_allocate(size=3321675776) failed
(error code=3)
R(2081,0xa000d000) malloc: *** error: can't allocate region
R(2081,0xa000d000) malloc: *** set a breakpoint in szone_error to debug

My Mac is 64-bit, however, I'm wondering if R is compiled as a 32-bit app?

Many thanks,

Robert Terwilliger

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

2008-01-10 Thread eugen pircalabelu
Hi R-users!

I have the following example:
a<-data.frame(cat=c(5,10,15), dog=c(5,10, 15), mouse=c(10,10,20))
b<-data.frame(cat=c(15,10,5), dog=c(15, 10, 5), mouse=c(20,10,10))
rownames(b)<-c("scared", "happy", "sad")
rownames(a)<-c("scared", "happy", "sad")

Let's say that a and b are 2 contingency tables and 5,10, 15, 20 are 
proportions of the whole sample (eg there are 5% animals that are both dogs and 
scared in sample a). a and b are two different samples. Now, what i want is to 
test the  hypothesis that these two sample structures are  similar. I know that 
the chi square test, only handles one 2-dimensional contingency table, or a 
3-dimensional one (mantelhaen. test), but I haven't seen a test that handles 2 
separate 2-dimensional tables.  Is there such a test?
Another thing that i want to see , is which cells differ one from another? Eg 
is the 5 percent of scared dogs from sample a, different from  15% of scared 
dogs form sample b? I would like something like the "adjusted standardized 
reziduals" test from SPSS?
If i would compute by hand a z-statistic that tested the hypothesis that the 2 
proportions are equal, would that be correct, since I have a multinomial 
proportion and not a binomial one ? 
Could I construct a confidence interval for my multinomial proportions in R 
simultaneously ? If i would do it for each proportion by using the  binomial 
distribution would that affect the power of the test?

Thank you and have a great day!


   
-

[[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] leave one out cross validation

2008-01-10 Thread Anu Swatantran
Hi

I am trying to validate my regression results using the leave one out crosss
validation method. Is any script available in R to use this method for a
linear regression equation?
Both R or SPLUS would do. any clues on how to write the script will also
help.

Thanks a lot,
A

[[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] 4 dimensional graphics

2008-01-10 Thread jiho

On 2008-January-10  , at 17:41 , Petr PIKAL wrote:
> Thank you
>
> Basically I have a rectangular space (like an aquarium) in which I  
> made
> some analysis.
> I can make
>
> image(lat, long, value) for each height but what I dream about is to  
> make
> something like scatterplot3d(lat, long, height) with points set  
> according
> to a value.
>
> Up to now i can do
>
> scatterplot3d(sloupecn, radan, vrstvan, color=as.numeric(cut(value,  
> c(0,
> 100, 400, 1000
>
> which will give you green and red points in upper right corner. I  
> started
> to try to make cex.symbols scaled according to value too but up to  
> now I
> did not manage to work correctly.
>
> in
>
> scatterplot3d(sloupecn, radan, vrstvan, cex.symbols = value/ 
> max(value)+2,
> color=as.numeric(cut(value, c(0, 100, 400, 1000
>
> the biggest points are at other places then I expected.

so you have measures at x,y,z points basically. and your measures  
appear to be on z layers so you can probably make several x,y plots  
with point size according to value, stacked on top of each other or  
side by side. one liner ggplots:

A=read.table("petr.txt",header=T)
library("ggplot2")
# stacked
ggplot(A,aes(x=x,y=y)) + geom_point(aes(size=value, colour=factor(z)))  
+ scale_size(to=c(0,10)) + scale_colour_hue(alpha=0.3)
# side by side
ggplot(A,aes(x=x,y=y)) + geom_point(aes(size=value)) +  
scale_size(to=c(0,10)) +facet_grid(z~.)

if you want 3d to explore your data, rgl (in which you can rotate  
plots etc) is probably the best choice

# 3D with rgl
library("rgl")
open3d()
spheres3d(A$x,A$y,A$z,A$value/1000) 
# NB. scaling your value is necessary since the values are so big  
compared to the coordinates
axes3d()

hope that helps.

petr.txt:

x y z value
1   4   1   73.8
1   4   9   54.9
1   4   17  72
1   1   1   96
1   1   9   52.1
1   1   17  53.3
4   4   1   58.4
4   4   9   93.5
4   4   17  140.2
4   1   1   90.3
4   1   9   36.5
4   1   17  55.1
7   4   1   169.1
7   4   9   718
7   4   17  813
7   1   1   73.4
7   1   9   46.5
7   1   17  205


JiHO
---
http://jo.irisson.free.fr/

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


Re: [R] unsupervised random forest classification

2008-01-10 Thread Liaw, Andy
Random Forests do not do clustering.  You need to take the proximity
matrix and feed it to algorithms of your choice for that.

Best,
Andy 

From: [EMAIL PROTECTED]
> 
> Friends,
> I would like to use Random Forest in unsupervised mode to 
> classify data that are
> from a mixture of categorical and continuous variables. The 
> examples I find
> online use only continuous data, followed by an mds plot. Is 
> it correct to use
> RF to obtain proximities for my mixed dataset and then 
> perform some other form
> of clustering (i.e. pam, clara, etc.) using the proximities 
> matrix? Or is there
> a way to perform unsupervised classification that will kick 
> out cluster
> membership on this dataset in RF itself?
> 
> Thanks,
> Helen Poulos
> Yale School of Forestry
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 


--
Notice:  This e-mail message, together with any attachme...{{dropped:15}}

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


Re: [R] 4 dimensional graphics

2008-01-10 Thread Greg Snow
Petr,

You may want to look at the rgl package for doing the 3d plot, then code
the points using different sizes/colors for your value.

However, when looking at a 3 dimensional plot that has been projected
onto 2 dimensions (computer screen or paper), the ability to really
understand what you are seeing is limited and often wrong due to various
optical illusions.  I would suggest that using lattice graphics may be
more informative (slice along height and do plots with lat and long as y
and x and points by value, or other combinations).  You may also find
relationships by using functions like stars, symbols, my.symbols
(TeachingDemos), or faces (TeachingDemos) to plot more than 2 dimensions
(though you still need to be very careful in how you assign variables to
features).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Petr PIKAL
> Sent: Thursday, January 10, 2008 9:42 AM
> To: hadley wickham
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] 4 dimensional graphics
> 
> Thank you
> 
> Basically I have a rectangular space (like an aquarium) in 
> which I made some analysis. I can make
> 
> image(lat, long, value) for each height but what I dream 
> about is to make something like scatterplot3d(lat, long, 
> height) with points set according to a value.
> 
> Up to now i can do
> 
> scatterplot3d(sloupecn, radan, vrstvan, 
> color=as.numeric(cut(value, c(0, 100, 400, 1000
> 
> which will give you green and red points in upper right 
> corner. I started to try to make cex.symbols scaled according 
> to value too but up to now I did not manage to work correctly. 
> 
> in
> 
> scatterplot3d(sloupecn, radan, vrstvan, cex.symbols = 
> value/max(value)+2, color=as.numeric(cut(value, c(0, 100, 
> 400, 1000
> 
> the biggest points are at other places then I expected. 
> 
> here are the data
> 
> vrstvan sloupecnradan   value
> 1   4   1   73.8
> 1   4   9   54.9
> 1   4   17  72
> 1   1   1   96
> 1   1   9   52.1
> 1   1   17  53.3
> 4   4   1   58.4
> 4   4   9   93.5
> 4   4   17  140.2
> 4   1   1   90.3
> 4   1   9   36.5
> 4   1   17  55.1
> 7   4   1   169.1
> 7   4   9   718
> 7   4   17  813
> 7   1   1   73.4
> 7   1   9   46.5
> 7   1   17  205
> 
> Petr
> [EMAIL PROTECTED]
> 
> "hadley wickham" <[EMAIL PROTECTED]> napsal dne 10.01.2008 16:07:31:
> 
> > On Jan 10, 2008 8:36 AM, Petr PIKAL <[EMAIL PROTECTED]> wrote:
> > > Dear all
> > >
> > > I want to display 4 dimensional space by some suitable way. I 
> > > searched CRAN and found miscellaneous 3 dim graphics 
> packages which 
> > > I maybe can modify but anyway I am open to any hint how to 
> > > efficiently display
> data
> > > like:
> > >
> > > longitude, latitude, height, value
> > 
> > What exactly are you interested in?  I'd start with plots of:
> > 
> >  * long, lat, height
> >  * long, lat, value
> >  * height, value
> > 
> > to give you a feel for what is going on.
> > 
> > Hadley
> > 
> > 
> > --
> > http://had.co.nz/
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


[R] Error: Bad value

2008-01-10 Thread Sven Garbade
Hi list,

from time to time I got an "Error: bad value" and must restart R. The
mail archives suggests memory corruption, but I do not run "special" C
code, only base R calls.  

I use R release 2.6.22 on a Debian GNU/Linux (version "testing") on a
i686 machine with 2 GB RAM. R was installed with deb-Packages from CRAN.
"memtest86+" (Version 3.3-2) doesn't find corrupted RAM.

Any suggestions? Thanks, Sven

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


Re: [R] diff in a dataframe

2008-01-10 Thread Gabor Grothendieck
Represent this as a time series.  Using
the zoo package:

> library(zoo)
> z <- zoo(cbind(price_g = c(0.34, 0.36), price_s = c(0.56, 0.76)), 
> as.Date(c("2000-01-01", "2000-01-05")))
> diff(log(z))
  price_g   price_s
2000-01-05 0.05715841 0.3053816
> diff(log(z), na.pad = TRUE)
  price_g   price_s
2000-01-01 NANA
2000-01-05 0.05715841 0.3053816


See the two zoo vignettes:
vignette("zoo")
vignette("zoo-quickref")

On Jan 10, 2008 2:16 AM, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> I have a dataframe say:
>
> date   price_g   price_s
> 0.340.56
> 0.360.76
>   .  .
>   .  .
>   .  .
>
> and so on. say, 1000 rows.
>
> Is it possible to add two columns to this dataframe, by computing say
> diff(log(price_g) and diff(log(price_s)) ?
>
> The elements in the first row of these columns cannot be computed, but
> can I coerce this to happen and assign a missing value there? It would
> be really great if I could do that, because in this case I don't have
> to re-index my transformed series to the dates again in a new
> dataframe.
>
> Thanks in anticipation.
>
>
> Vishal Belsare
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] diff in a dataframe

2008-01-10 Thread anna freni sterrantino
Hello Vishal 
Maybe this is what you want?

x<-c(0.34,0.36,3)
y<-c(0.56,0.76,4)
a<-data.frame(x,y)
>a
 xy
1 0.34 0.56
2 0.36 0.76
3 3.00 4.00

a$diff<-(log(a$x))
 a$diff2<-(log(a$y))
>a
 xy  diff  diff2
1 0.34 0.56 -1.078810 -0.5798185
2 0.36 0.76 -1.021651 -0.2744368
3 3.00 4.00  1.098612  1.3862944
 
and if you wnat to  coerce the first row to a whatever
value just type
a[1,]<-NA


Cheers 
A
 


- Messaggio originale -
Da: Vishal Belsare <[EMAIL PROTECTED]>
A: r-help@r-project.org
Inviato: Mercoledì 9 gennaio 2008, 23:16:38
Oggetto: [R] diff in a dataframe

I have a dataframe say:

date   price_g   price_s
 0.340.56
 0.360.76
   .  .
   .  .
   .  .

and so on. say, 1000 rows.

Is it possible to add two columns to this dataframe, by computing say
diff(log(price_g) and diff(log(price_s)) ?

The elements in the first row of these columns cannot be computed, but
can I coerce this to happen and assign a missing value there? It would
be really great if I could do that, because in this case I don't have
to re-index my transformed series to the dates again in a new
dataframe.

Thanks in anticipation.


Vishal Belsare

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






  ___ 

ttp://it.docs.yahoo.com/nowyoucan.html
[[alternative HTML version deleted]]

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


Re: [R] Error on distance matrix

2008-01-10 Thread Marc
Thanks for your help. It is working now.
Marc.

Gavin Simpson wrote:
> On Thu, 2008-01-10 at 10:48 +, Marc Moragues wrote:
>   
>> Hi,
>>
>> I am trying to calculate a distance matrix on a binary data frame using
>> dist.binary() {ade4}. This is the code I run and the error I get:
>>
>> 
>>> sjlc.dist <- dist.binary(as.data.frame(data), method=2) #D = (a+d) /
>>>   
>> (a+b+c+d)
>> Error in if (any(df < 0)) stop("non negative value expected in df") :
>>  missing value where TRUE/FALSE needed
>>
>> I don't know if the problem are the missing values in my data. If so how
>> can I handle them?
>> 
>
> Marc,
>
> Take a look at distance in package analogue and method = "mixed" which
> implements Gower's general dissimilarity coefficient for mixed data. It
> can deal quite happily with binary data and where there is missing-ness.
> Binary data are handled through a simple matching coefficient, 1 if
> variable i present in both samples, 0 otherwise, and then summed over
> all variables i. You should probably read up on how the missing-ness is
> handled with this method and what properties the resulting dissimilarity
> has.
>
> Note that distance() outputs full dissimilarity matrices. To get
> something to plug into functions that require a dist object, just use
> as.dist() on the output from distance().
>
> HTH
>
> G
>
>   
>> Thank you,
>> Marc. 
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>>
>> SCRI, Invergowrie, Dundee, DD2 5DA.  
>> The Scottish Crop Research Institute is a charitable company limited by 
>> guarantee. 
>> Registered in Scotland No: SC 29367.
>> Recognised by the Inland Revenue as a Scottish Charity No: SC 006662.
>>
>>
>> DISCLAIMER:
>>
>> This email is from the Scottish Crop Research Institute, but the views 
>> expressed by the sender are not necessarily the views of SCRI and its 
>> subsidiaries.  This email and any files transmitted with it are confidential 
>> to the intended recipient at the e-mail address to which it has been 
>> addressed.  It may not be disclosed or used by any other than that addressee.
>> If you are not the intended recipient you are requested to preserve this 
>> confidentiality and you must not use, disclose, copy, print or rely on this 
>> e-mail in any way. Please notify [EMAIL PROTECTED] quoting the 
>> name of the sender and delete the email from your system.
>>
>> Although SCRI has taken reasonable precautions to ensure no viruses are 
>> present in this email, neither the Institute nor the sender accepts any 
>> responsibility for any viruses, and it is your responsibility to scan the 
>> email 
>> and the attachments (if any).
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] 4 dimensional graphics

2008-01-10 Thread Petr PIKAL
Thank you

Basically I have a rectangular space (like an aquarium) in which I made 
some analysis. I can make

image(lat, long, value) for each height but what I dream about is to make 
something like scatterplot3d(lat, long, height) with points set according 
to a value.

Up to now i can do

scatterplot3d(sloupecn, radan, vrstvan, color=as.numeric(cut(value, c(0, 
100, 400, 1000

which will give you green and red points in upper right corner. I started 
to try to make cex.symbols scaled according to value too but up to now I 
did not manage to work correctly. 

in

scatterplot3d(sloupecn, radan, vrstvan, cex.symbols = value/max(value)+2, 
color=as.numeric(cut(value, c(0, 100, 400, 1000

the biggest points are at other places then I expected. 

here are the data

vrstvan sloupecnradan   value
1   4   1   73.8
1   4   9   54.9
1   4   17  72
1   1   1   96
1   1   9   52.1
1   1   17  53.3
4   4   1   58.4
4   4   9   93.5
4   4   17  140.2
4   1   1   90.3
4   1   9   36.5
4   1   17  55.1
7   4   1   169.1
7   4   9   718
7   4   17  813
7   1   1   73.4
7   1   9   46.5
7   1   17  205

Petr
[EMAIL PROTECTED]

"hadley wickham" <[EMAIL PROTECTED]> napsal dne 10.01.2008 16:07:31:

> On Jan 10, 2008 8:36 AM, Petr PIKAL <[EMAIL PROTECTED]> wrote:
> > Dear all
> >
> > I want to display 4 dimensional space by some suitable way. I searched
> > CRAN and found miscellaneous 3 dim graphics packages which I maybe can
> > modify but anyway I am open to any hint how to efficiently display 
data
> > like:
> >
> > longitude, latitude, height, value
> 
> What exactly are you interested in?  I'd start with plots of:
> 
>  * long, lat, height
>  * long, lat, value
>  * height, value
> 
> to give you a feel for what is going on.
> 
> Hadley
> 
> 
> -- 
> http://had.co.nz/

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


Re: [R] 4 dimensional graphics

2008-01-10 Thread Alberto Monteiro
Petr PIKAL wrote:
> 
> I want to display 4 dimensional space by some suitable way.
>
You probably need an LSD monitor :-)

> I searched CRAN and found miscellaneous 3 dim graphics
> packages which I maybe can modify but anyway I am open
> to any hint how to 
> efficiently display data like:
> 
> longitude, latitude, height, value
>
I imagine you want to plot a function with domain R^2
and contradomain R^2?

Check this:
http://en.wikipedia.org/wiki/Image:WeierstrassP.png

It's the graphic of a function that takes complex numbers
and returns complex numbers (and it was done in R); 
the way to plot this was:

f: (x + y i) -> (x' + y' i)

x, y : normal (x,y) coordinates in the plot

x', y': converted to a color code, where the radius
  sqrt(x'^2 + y'^2) became the intensity ('value', in
  the hsv function) and the direction atan2(y',x') 
  became the hue

Probably you could do the same here, converting height and
value to colors?

OTOH, if it's a function from R^3 to R:

  f: (lat, lon, h) -> (value)

then I guess the best way is to replace one dimension to time,
and create animations.

Alberto Monteiro

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


Re: [R] Subsetting array (NA:s)

2008-01-10 Thread Marc Schwartz
Lauri Nikkinen wrote:
> Hi R-users,
> 
> I have an array similar to this:
> 
> tmp <- array(1:6, c(2,3,3))
> n1 <- c("one", "two")
> n2 <- c("three", "four", "five")
> n3 <- c("six", "seven", "eight")
> dimnames(tmp) <- list(n1, n2, n3)
> tmp[1,,1] <- NA
> tmp[1,3,2] <- NA
> tmp[2,,3] <- NA
> tmp
> 
> How to subset !is.na(x) rows resulting
> 
> , , six
> 
> three four five
> two 246
> 
> , , seven
> 
> three four five
> one 13   NA
> two 246
> 
> , , eight
> 
> three four five
> one 135
> 
> I have tried something like
> 
> tmp[!apply(is.na(tmp), 1, all),,]
> 
> with negative results.
> 
> Thanks
> -Lauri

There might be an easier way, but here is one approach.  The problem
that you will have is that you will not be returning an object with
"consistent dimensions". Thus, you will end up with a list, not an array.


> apply(tmp, 3,
function(i) i[apply(i, 1,
function(x) !all(is.na(x))), ,
  drop = FALSE])
$six
three four five
two 246

$seven
three four five
one 13   NA
two 246

$eight
three four five
one 135



HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Identifying x, y coordinates from periodogram generated by spec.pgram

2008-01-10 Thread stephen sefick
I would like to identify the x,y coordinates in a plot of the periodogram

spec.pgram(a, taper=0, log="no")

I have tried the identify() function to no avail

I have also tried to pass the periodogram over to rggobi

e<-plot.spec(spec.pgram(a, taper=0, log="no"))
ggobi(e)

to no avail

I need to identify the predominant frequencies so that I can work back
to the time of recurrence in minutes.  I don't necessarily need a interactive
graphical solution (although this may be easier).
thanks

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

-K. Mullis

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


Re: [R] question on how to extract values from atomic vector

2008-01-10 Thread Jack Luo
Thanks a lot! It works.

Jack

On Jan 9, 2008 10:35 PM, jim holtman <[EMAIL PROTECTED]> wrote:

> There are a couple of ways of getting the values:
>
> > x <- cbind(a=1:3, pi=pi) # simple matrix w/ dimnames
> > attributes(x)
> $dim
> [1] 3 2
>
> $dimnames
> $dimnames[[1]]
> NULL
>
> $dimnames[[2]]
> [1] "a"  "pi"
>
>
> > attributes(x)$dim
> [1] 3 2
> > attr(x, 'dim')
> [1] 3 2
> >
>
> So in your case,
>
> attr(Results, 'prob')
>
> or
>
> attributes(Results)$prob
>
>
>
> On Jan 9, 2008 10:12 PM, Jack Luo <[EMAIL PROTECTED]> wrote:
> > Dear List,
> >
> > I have an atomic vector named "Results"
> >
> > Results
> > [1] 1 1 1
> > attr(,"prob")
> > [1] 0.667 1.000 1.000
> > Levels: 0 1
> >
> > when I type
> >
> > attributes(Results)
> > $levels
> > [1] "0" "1"
> >
> > $class
> > [1] "factor"
> >
> > $prob
> > [1] 0.667 1.000 1.000
> >
> > However, when I type
> > Results$prob
> >
> > It has the following warning message:
> >
> > NULL
> > Warning message:
> > In Results$prob : $ operator is invalid for atomic vectors, returning
> NULL
> >
> > I've been doing some search and seems that this question was asked by
> > someone before and I can not seem to find a solution to extract the
> value
> > from the atomic vector, could somebody help me with this?
> >
> > Thanks a lot!
> >
> > Jack
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve?
>

[[alternative HTML version deleted]]

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


Re: [R] load tcltk

2008-01-10 Thread Lorenz Gabmann
Problem solved: X11 from Mac OS X Tiger CD has to be installed
then tcltk runs properly.

Thanks!
Lorenz


Am 10.01.2008 um 15:38 schrieb Alberto Monteiro:

>
> Lorenz Gabmann wrote:
>>
>> Can someone help me with the following problem?
>>
> Let me see if I can guess what are the error messages.
>
>> Lade nötiges Paket: tcltk
>>
> Load (???) package: tcltk
>
>> Loading Tcl/Tk interface ... Error in dyn.load(file, ...) :
>>kann shared library
>> '/Library/Frameworks/R.framework/Versions/2.6/
>> Resources/library/tcltk/libs/ppc/tcltk.so' nicht laden:
>>
> Cannot load shared library (?)
>
>> dlopen(/Library/Frameworks/R.framework/Versions/2.6/Resources/
>> library/tcltk/libs/ppc/tcltk.so, 10): Library not loaded:
>> /usr/X11R6/ lib/libX11.6.dylib   Referenced from:
>> /Library/Frameworks/R.framework/Versions/2.6/
> Resources/library/tcltk/libs/ppc/tcltk.so
>>Reason: image not found
>> Error : .onLoad in 'loadNamespace' für 'tcltk' fehlgeschlagen
>> Fehler: Paket 'tcltk' konnte nicht geladen werden
>>
> Packet 'tcltk' can't be loaded (?)
>
> My guess: check if the above mentioned libraries
> exist, and check if there is some file protection.
>
> Probably there's a problem with:
> /usr/X11R6/lib/libX11.6.dylib
>
> Alberto Monteiro
>
> PS: is there any way to temporarily change the error messages
>> from one language to another? When I get error messages
> in Portuguese it's a pain to translate them precisely to
> something that I can google or RSiteSearch to know what it means.

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


Re: [R] as.date - german date format

2008-01-10 Thread Konga

Hi Terry,

thanks for the information, I should know this in advance but I´m not used
to case sensitive syntax - thanks Delphi... 

regards,
Eric Will


Terry Therneau wrote:
> 
>>> Konga wrote:
 Hi,

 I have a data.frame with the following variable:
 $  xx  :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3
 3
 3

 now I?d like use "as.date" on it - if I comprehend the instructions on
 http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
 it should work like this:

 as.date(xx, "%d.%m.%Y") - but it doesn?t...
>>> What is the error message? 
>>> - Fehler in as.date(mydata$xx, "%d.%m.%Y") : 
>>>   Cannot coerce to date format
>  
>   You are invoking a function from the "date" library, but reading
> the documentation for "Date"; they are quite different.
> 
>   The 'date' library was written 8-10 years ago, and is used by some of
> the
> functions in the survival library (a dependence that I am currently
> removing).
> It works quite well, but has a much smaller scope of functionality than
> the 
> later 'Date' library, in particular there are no attempts at
> multi-language
> support.  So as.date + German format is nearly a contradiction.  
> 
>   > args(as.date)
>   function (x, order = "mdy", ...) 
>   
> So you see that the function does not even have a "format" argument.  If
> your
> delimiter were one of /,-  then order='dmy' would have worked, but as.date
> does 
> not accept '.'
> 
>   Terry Therneau
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/as.date---german-date-format-tp14734166p14737513.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to calculate time offset between timezones?

2008-01-10 Thread Prof Brian Ripley
On Thu, 10 Jan 2008, dankelley wrote:

>
> #QUESTION#
>
> Is there a way to calculate the offset between timezones, e.g. from "AST" to
> "GMT"?
>
> #DETAILS#
>
> I am working with data files that use local time, and that indicate the
> timezone by e.g. "AST" (Atlantic Standard Time, my local time) in a header.

The problem is that AST is not a valid timezone (at least on my Mac), so 
is being ignored.  I think you want "America/Halifax".  (Works for me on 
Leopard as well as on Linux.)

The documentation for R-devel may help here:

https://svn.r-project.org/R/trunk/src/library/base/man/timezones.Rd

But earlier versions do say things like

  If a timezone is needed and that specified is invalid on your
  system, what happens is system-specific but it will probably be
  ignored.

> I was guessing that
>
>> ISOdatetime(2008,1,1,1,0,0,tz="GMT") -
>> ISOdatetime(2008,1,1,1,0,0,tz="AST")
>
> would work, but it gives a difference of 0.  However, when I do
>
>> ISOdatetime(2008,1,1,1,0,0,tz="GMT") - ISOdatetime(2008,1,1,1,0,0)
>
> I get a -4h offset, which is correct.  The odd thing is, I am in AST time,
> as shown by the following.
>
>> ISOdatetime(2008,1,1,1,0,0)
> [1] "2008-01-01 01:00:00 AST"
>
> #SYSTEM#
>
> Mac OS X system, with R 2.6.1
>
> #PS#
>
> I am aware that this sort of thing is system dependent, and so there may not
> be a general solution.  But even if I can only get it working on my own
> particular system, I'd be happy!
>

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

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


Re: [R] how to calculate time offset between timezones?

2008-01-10 Thread Armstrong, Whit
well, strangely,  ISOdatetime(2008,1,1,1,0,0,tz="AST") creates a UTC
timezone date on my system:

> ISOdatetime(2008,1,1,1,0,0,tz="AST")
[1] "2008-01-01 01:00:00 UTC"
> 

and if you compare the numeric values of the UTC datetime and the GMT
datetime, the are definitely the same:

> as.numeric(ISOdatetime(2008,1,1,1,0,0,tz="AST"))
[1] 1199149200
> as.numeric(ISOdatetime(2008,1,1,1,0,0,tz="GMT"))
[1] 1199149200
> 

I think the failure to recognize AST may have something to with the
timzones listed in /usr/share/zoneinfo (on Ubuntu linux) where I found
AST4:

[EMAIL PROTECTED]:~$ find /usr/share/zoneinfo -name "AST*"
/usr/share/zoneinfo/SystemV/AST4
/usr/share/zoneinfo/SystemV/AST4ADT
/usr/share/zoneinfo/right/SystemV/AST4
/usr/share/zoneinfo/right/SystemV/AST4ADT
/usr/share/zoneinfo/posix/SystemV/AST4
/usr/share/zoneinfo/posix/SystemV/AST4ADT


and when I use it as the tz argument:

> ISOdatetime(2008,1,1,1,0,0,tz="AST4")
[1] "2008-01-01 01:00:00 AST"
> 

and

> ISOdatetime(2008,1,1,1,0,0,tz="AST4") -
ISOdatetime(2008,1,1,1,0,0,tz="GMT")
Time difference of 4 hours
> 


-Whit


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of dankelley
> Sent: Thursday, January 10, 2008 10:21 AM
> To: r-help@r-project.org
> Subject: [R] how to calculate time offset between timezones?
> 
> 
> #QUESTION#
> 
> Is there a way to calculate the offset between timezones, 
> e.g. from "AST" to "GMT"?
> 
> #DETAILS# 
> 
> I am working with data files that use local time, and that 
> indicate the timezone by e.g. "AST" (Atlantic Standard Time, 
> my local time) in a header. 
> I was guessing that
> 
> > ISOdatetime(2008,1,1,1,0,0,tz="GMT") -
> > ISOdatetime(2008,1,1,1,0,0,tz="AST")
> 
> would work, but it gives a difference of 0.  However, when I do
> 
> > ISOdatetime(2008,1,1,1,0,0,tz="GMT") - ISOdatetime(2008,1,1,1,0,0)
> 
> I get a -4h offset, which is correct.  The odd thing is, I am 
> in AST time, as shown by the following.
> 
> > ISOdatetime(2008,1,1,1,0,0)
> [1] "2008-01-01 01:00:00 AST"
> 
> #SYSTEM#
> 
> Mac OS X system, with R 2.6.1 
> 
> #PS#
> 
> I am aware that this sort of thing is system dependent, and 
> so there may not be a general solution.  But even if I can 
> only get it working on my own particular system, I'd be happy!
> --
> View this message in context: 
> http://www.nabble.com/how-to-calculate-time-offset-between-tim
> ezones--tp14736453p14736453.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.
> 




This e-mail message is intended only for the named recipient(s) above. It may 
contain confidential information. If you are not the intended recipient you are 
hereby notified that any dissemination, distribution or copying of this e-mail 
and any attachment(s) is strictly prohibited. If you have received this e-mail 
in error, please immediately notify the sender by replying to this e-mail and 
delete the message and any attachment(s) from your system. Thank you.

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


Re: [R] diff in a dataframe

2008-01-10 Thread Don MacQueen
So, what's the easiest way to add a column to a dataframe? Just do it.

Here is a really simple example to illustrate:

>  foo <- data.frame(x=1:4,y=2:5)
>  foo
   x y
1 1 2
2 2 3
3 3 4
4 4 5
>  foo$z <- c(NA,diff(foo$x))
>  foo
   x y  z
1 1 2 NA
2 2 3  1
3 3 4  1
4 4 5  1


Solutions using apply and sapply are overly complicated for what you requested.
If you had to do this for many, many columns a looping solution would 
be worth it, but for just two columns, it's not.

-Don



At 12:46 PM +0530 1/10/08, Vishal Belsare wrote:
>I have a dataframe say:
>
>date   price_g   price_s
>  0.340.56
>  0.360.76
>.  .
>.  .
>.  .
>
>and so on. say, 1000 rows.
>
>Is it possible to add two columns to this dataframe, by computing say
>diff(log(price_g) and diff(log(price_s)) ?
>
>The elements in the first row of these columns cannot be computed, but
>can I coerce this to happen and assign a missing value there? It would
>be really great if I could do that, because in this case I don't have
>to re-index my transformed series to the dates again in a new
>dataframe.
>
>Thanks in anticipation.
>
>
>Vishal Belsare
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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


Re: [R] Changing language of messages (was load tcltk)

2008-01-10 Thread Prof Brian Ripley
On Thu, 10 Jan 2008, Alberto Monteiro wrote:

[...]

> PS: is there any way to temporarily change the error messages
> from one language to another? When I get error messages
> in Portuguese it's a pain to translate them precisely to
> something that I can google or RSiteSearch to know what it means.

Usually Sys.setenv(LANGUAGE="en") works.  See the R-admin manual which 
tells you this and other ways.

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

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


Re: [R] plotting help needed

2008-01-10 Thread Don MacQueen
Try

plot(1:2,all,type="b",col="blue",xlim=c(1,4),ylim=c(20,150),xaxt='n',yaxt='n')
lines(2:3,all2,type='o',col='yellow')

I don't really know what you mean by "4 intersects, just named by characters".

By "no scale please" I assume you mean tick marks 
and tick mark labels on the axes, and that's what 
the xaxt='n' and yaxt='n' are for.

See help('par') for more options to control how plots appear.

-Don

At 8:24 PM +0100 1/8/08, bunny , lautloscrew.com wrote:
>Content-Type: text/plain
>Content-Disposition: inline
>Content-length: 772
>
>Dear all,
>
>i need some help with plotting.
>
>the specific problem is the following:
>
>#FYI
>a=100
>b=95
>d=94.5
>e=70
>
>all=c(a,b)
>all2=c(d,e)
>plot(all,type="b",col="blue",xlim=c(1,4),ylim=c(20,150))
>lines(all2,type="o",col="yellow")
>
>
>this does work so far, but ...
>i´d like to have 4 intersects, just named by characters.. no scale 
>please.
>the second problem is, i am trying to start the second vector where 
>the first vector stops (same point on the x-axis - y is different ;) )
>
>admittedly all this sounds quite basic, but i couldnt get a long with 
>it for  a while. if somebody knows a good manual about graphics in R, 
>i´d be happy if you let me know.
>
>thanks in advance !
>
>matthias
>   [[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.


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 about subset and join ts object(s)

2008-01-10 Thread tom soyer
Thanks Achim. Data manipulation in zoo and coerce back to ts. Sounds good!

On 1/10/08, Achim Zeileis <[EMAIL PROTECTED]> wrote:
>
> On Thu, 10 Jan 2008, tom soyer wrote:
>
> > Hi,
> >
> > I have two questions about ts.
> >
> > (1) How do I subset a ts object and still preserve the time index? for
> > example:
> >
> > > x=ts(1:10, frequency = 4, start = c(1959, 2)) # the ts object
> > > x
> >  Qtr1 Qtr2 Qtr3 Qtr4
> > 1959 123
> > 19604567
> > 196189   10
> > I don't want the 1st 2 elements, so I could subset like this:
> > > x[3:length(x)]
> > [1]  3  4  5  6  7  8  9 10
> >
> > But then the time index is lost. I could use window(), but then I have
> to
> > specify start and end manually. Is there a way to subset a ts object so
> that
> > the time index is preserved for the data extracted without specifying
> start
> > and end data by hand?
>
> I think window() is the way to go with "ts".
> "zoo"/"zooreg" additionally provide what you ask for:
>
> library("zoo")
> x <- ts(1:10, frequency = 4, start = c(1959, 2))
> z <- as.zoo(x)
> z[3:length(z)]
>
> The time formatting is somewhat nice when you declare explicitely that
> this is "yearqtr" data:
>
> time(z) <- as.yearqtr(time(z))
> z[3:length(z)]
>
> > (2) How do I join two ts objects together end to end? for example:
> > > x=ts(1:10, frequency = 4, start = c(1959, 2)) # the 1st ts object
> > > y=ts(11:15, frequency = 4, start = c(1961, 4)) # the 2nd ts object
> >
> > As you can see, y is just a continuation of x. I would like to add y to
> the
> > end of x while preserving the time index. I could use this:
> > > ts(c(x,y),start=start(x),frequency=4)
> >
> > But I am wondering if there is a more efficient way of doing this, i.e.,
> is
> > it really necessary to specify start and frequency again when they are
> > already a part of the original ts objects?
>
> "zoo" also provides this:
>
> x <- ts(1:10, frequency = 4, start = c(1959, 2))
> y <- ts(11:15, frequency = 4, start = c(1961, 4))
> c(as.zoo(x), as.zoo(y))
>
> or you can also coerce back to "ts"
>
> as.ts(c(as.zoo(x), as.zoo(y)))
>
> Personally, I tend to do my data manipulations in "zoo" (not very
> surprisingly ;-)) but might coerce the resulting series to "ts" if I want
> to use certain modeling functions.
> Z
>
>
>
>


-- 
Tom

[[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] An "R is slow"-article

2008-01-10 Thread Tom Backer Johnsen
Gustaf Rydevik wrote:
> Hi all,
> 
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
> 
> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?
> 
> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/0041.htm
>  While I don't agree (granted, I can't really write C), it was
> interesting to read something from a very different perspective than
> I'm used to.

The important aspect of R is not that it is less fast for a particular
kind of operation than a dedicated  program written in a compiled
language like C, Pascal, or Fortran for a particular kind of analysis.
  That is not really surprising, and not relevant for anything but the
most extreme situations given the speed (and low price) of modern
computers.

What is really relevant is (a) the context of any operation, R is a
well documented language where a very large number number of
operations may be combined in an extremely large number of ways where
the probability of errors is very low, and (b) all aspects of the
language is peer reviewed.

Both points are extremely important in any research context, where
everything, including the software used in computations, should be
possible to document.  These qualities are difficult to achieve in
homebrewed programs.  Therefore one should not resort to programming
anything on your own unless the operations you need are definitely not
present in the language you are using.  Apart from that, you have to
think about cost in respect to the time and resources used to develop
your own substitutes for something that already exists.

He also says that R encourages "fishing trips" in the data.  Well,
that may be somewhat true for R as well as any of the major
statistical packages.  But that is a problem that really is in a
different domain, one of attitudes on how to do research in the first
place.

Tom
> 
> Best regards,
> 
> Gustaf
> 
> _
> Department of Epidemiology,
> Swedish Institute for Infectious Disease Control
> work email: gustaf.rydevik at smi dot ki dot se
> skype:gustaf_rydevik
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

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

2008-01-10 Thread Lauri Nikkinen
Hi R-users,

I have an array similar to this:

tmp <- array(1:6, c(2,3,3))
n1 <- c("one", "two")
n2 <- c("three", "four", "five")
n3 <- c("six", "seven", "eight")
dimnames(tmp) <- list(n1, n2, n3)
tmp[1,,1] <- NA
tmp[1,3,2] <- NA
tmp[2,,3] <- NA
tmp

How to subset !is.na(x) rows resulting

, , six

three four five
two 246

, , seven

three four five
one 13   NA
two 246

, , eight

three four five
one 135

I have tried something like

tmp[!apply(is.na(tmp), 1, all),,]

with negative results.

Thanks
-Lauri

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

2008-01-10 Thread helen . mills
Friends,
I would like to use Random Forest in unsupervised mode to classify data that are
from a mixture of categorical and continuous variables. The examples I find
online use only continuous data, followed by an mds plot. Is it correct to use
RF to obtain proximities for my mixed dataset and then perform some other form
of clustering (i.e. pam, clara, etc.) using the proximities matrix? Or is there
a way to perform unsupervised classification that will kick out cluster
membership on this dataset in RF itself?

Thanks,
Helen Poulos
Yale School of Forestry

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

2008-01-10 Thread dankelley

#QUESTION#

Is there a way to calculate the offset between timezones, e.g. from "AST" to
"GMT"?

#DETAILS# 

I am working with data files that use local time, and that indicate the
timezone by e.g. "AST" (Atlantic Standard Time, my local time) in a header. 
I was guessing that

> ISOdatetime(2008,1,1,1,0,0,tz="GMT") -
> ISOdatetime(2008,1,1,1,0,0,tz="AST")

would work, but it gives a difference of 0.  However, when I do

> ISOdatetime(2008,1,1,1,0,0,tz="GMT") - ISOdatetime(2008,1,1,1,0,0)

I get a -4h offset, which is correct.  The odd thing is, I am in AST time,
as shown by the following.

> ISOdatetime(2008,1,1,1,0,0)
[1] "2008-01-01 01:00:00 AST"

#SYSTEM#

Mac OS X system, with R 2.6.1 

#PS#

I am aware that this sort of thing is system dependent, and so there may not
be a general solution.  But even if I can only get it working on my own
particular system, I'd be happy!
-- 
View this message in context: 
http://www.nabble.com/how-to-calculate-time-offset-between-timezones--tp14736453p14736453.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] 4 dimensional graphics

2008-01-10 Thread hadley wickham
On Jan 10, 2008 8:36 AM, Petr PIKAL <[EMAIL PROTECTED]> wrote:
> Dear all
>
> I want to display 4 dimensional space by some suitable way. I searched
> CRAN and found miscellaneous 3 dim graphics packages which I maybe can
> modify but anyway I am open to any hint how to efficiently display data
> like:
>
> longitude, latitude, height, value

What exactly are you interested in?  I'd start with plots of:

 * long, lat, height
 * long, lat, value
 * height, value

to give you a feel for what is going on.

Hadley


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

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


Re: [R] help with R

2008-01-10 Thread John Kane

--- [EMAIL PROTECTED] wrote:
 
> (2) Where do I get to see the complete library of
> packages offered by R? 
> In particular, I am interested in quantile
> regression and logistic 
> regression.

R webpage > CRAN > Packages link.
Also have a look at the Task Views on the CRAN page.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fwd: multinomial regression for clustered data

2008-01-10 Thread Niccolò Bassani
Hello dear R-users,
does any of you know a way to perform a multinomial regression with
clustered data (i.e. repeated measurements)? I made the first analysis with
Stata option vce cluster in the mlogit command but was looking for a similar
functionality in R too...
thanks all!
niccolò

[[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] distance between set of coordinates

2008-01-10 Thread Mafalda Viana
Hi!

 

I have a set of 800 coordinates pairs and need to find the distance
between each pair.

 

I am able to find the distance between one pair using:
<-geodist(LatStart,LongStart,LatEnd,LongEnd,units="km")) but doing one
by one is nor feasible.

 

Can you help me? 

 

Thanks, Mafalda

 

--

Mafalda Viana

Inshore Fisheries Group

FRS Marine Laboratory

375 Victoria Road

Torry, Aberdeen

AB11 9DB

UK

 

email: [EMAIL PROTECTED]

 

Phone: +44 (0) 1224 876544 (ext.5684)

Fax: +44 (0) 1224 295511

 


[[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] `[.data.frame`(df3, , -2) and NA columns

2008-01-10 Thread John Kane
I don't know why this is happening but it has nothing
to do with a negative index
df[,-2] has not changed df.  
--- Dieter Menne <[EMAIL PROTECTED]> wrote:

> Dear baseRs,
> 
> I recently made a mistake when renaming data frame
> columns, accidentally
> creating an NA column. I found the following strange
> behavior when negative
> indexes are used.
> 
> Can anyone explain what happens here.  No
> "workarounds" required, just  curious.
> 
> Dieter
> 
> Version: Windows, R version 2.6.1 (2007-11-26)
> 
> #-
> df = data.frame(a=0:10,b=10:20)
> df[,-2] #ok
> names(df)=c("A") # implicitly creates an NA column
> df[,-2] 
> df[,-2,drop=FALSE]   # has nothing to do with
> drop
> 
> df3 = data.frame(a=0:10,b=10:20,c=20:30)
> df3[,-2] #ok
> names(df3)=c("A","B") #creates an NA column
> df3[,-2] # error
> # Error in `[.data.frame`(df3, , -2) : undefined
> columns selected
> 
> names(df3)[3]="NaN" # another reserved word
> df3[,-2] # no problem
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



  Looking for the perfect gift? Give the gift of Flickr!

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


Re: [R] how can i add a package that i want to use permanent

2008-01-10 Thread Bos, Roger
Another option is to modify the Rprofile.site file in the etc folder of
your R installation.  Then you don't have to save the workspace. You add
as much startup scripting as you want to the Rprofile.site file.

HTH,

Roger
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Charles Annis, P.E.
Sent: Thursday, January 10, 2008 9:11 AM
To: '???'; [EMAIL PROTECTED]
Subject: Re: [R] how can i add a package that i want to use permanent

?.First
This will explain things.  


You make a hidden program called .First like this

.First <- function() { library(lattice) }

and then save your workspace.  The next time you open R, lattice will
load automatically.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of ???
Sent: Wednesday, January 09, 2008 10:28 PM
To: [EMAIL PROTECTED]
Subject: [R] how can i add a package that i want to use permanent

I want use a package(lattice) in R to do some work but everytime when i
open R program  ,this package is not loaded, so  everytime  i have to
load it , who can tell me  how to load this package permanent

thanks!!!
--
:zND2(
TEL:15918732631
E-MAIL:[EMAIL PROTECTED]
[EMAIL PROTECTED]

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] load tcltk

2008-01-10 Thread Alberto Monteiro

Lorenz Gabmann wrote:
>
> Can someone help me with the following problem?
> 
Let me see if I can guess what are the error messages.

> Lade nötiges Paket: tcltk
>
Load (???) package: tcltk

> Loading Tcl/Tk interface ... Error in dyn.load(file, ...) :
>kann shared library 
> '/Library/Frameworks/R.framework/Versions/2.6/ 
> Resources/library/tcltk/libs/ppc/tcltk.so' nicht laden:  
>
Cannot load shared library (?)

> dlopen(/Library/Frameworks/R.framework/Versions/2.6/Resources/ 
> library/tcltk/libs/ppc/tcltk.so, 10): Library not loaded: 
> /usr/X11R6/ lib/libX11.6.dylib   Referenced from: 
> /Library/Frameworks/R.framework/Versions/2.6/ 
Resources/library/tcltk/libs/ppc/tcltk.so
>Reason: image not found
> Error : .onLoad in 'loadNamespace' für 'tcltk' fehlgeschlagen
> Fehler: Paket 'tcltk' konnte nicht geladen werden
> 
Packet 'tcltk' can't be loaded (?)

My guess: check if the above mentioned libraries
exist, and check if there is some file protection.

Probably there's a problem with:
/usr/X11R6/lib/libX11.6.dylib

Alberto Monteiro

PS: is there any way to temporarily change the error messages
from one language to another? When I get error messages
in Portuguese it's a pain to translate them precisely to
something that I can google or RSiteSearch to know what it means.

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

2008-01-10 Thread Petr PIKAL
Dear all

I want to display 4 dimensional space by some suitable way. I searched 
CRAN and found miscellaneous 3 dim graphics packages which I maybe can 
modify but anyway I am open to any hint how to efficiently display data 
like:

longitude, latitude, height, value

Thank you

Petr Pikal
[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 about subset and join ts object(s)

2008-01-10 Thread Achim Zeileis
On Thu, 10 Jan 2008, tom soyer wrote:

> Hi,
>
> I have two questions about ts.
>
> (1) How do I subset a ts object and still preserve the time index? for
> example:
>
> > x=ts(1:10, frequency = 4, start = c(1959, 2)) # the ts object
> > x
>  Qtr1 Qtr2 Qtr3 Qtr4
> 1959 123
> 19604567
> 196189   10
> I don't want the 1st 2 elements, so I could subset like this:
> > x[3:length(x)]
> [1]  3  4  5  6  7  8  9 10
>
> But then the time index is lost. I could use window(), but then I have to
> specify start and end manually. Is there a way to subset a ts object so that
> the time index is preserved for the data extracted without specifying start
> and end data by hand?

I think window() is the way to go with "ts".
"zoo"/"zooreg" additionally provide what you ask for:

  library("zoo")
  x <- ts(1:10, frequency = 4, start = c(1959, 2))
  z <- as.zoo(x)
  z[3:length(z)]

The time formatting is somewhat nice when you declare explicitely that
this is "yearqtr" data:

  time(z) <- as.yearqtr(time(z))
  z[3:length(z)]

> (2) How do I join two ts objects together end to end? for example:
> > x=ts(1:10, frequency = 4, start = c(1959, 2)) # the 1st ts object
> > y=ts(11:15, frequency = 4, start = c(1961, 4)) # the 2nd ts object
>
> As you can see, y is just a continuation of x. I would like to add y to the
> end of x while preserving the time index. I could use this:
> > ts(c(x,y),start=start(x),frequency=4)
>
> But I am wondering if there is a more efficient way of doing this, i.e., is
> it really necessary to specify start and frequency again when they are
> already a part of the original ts objects?

"zoo" also provides this:

  x <- ts(1:10, frequency = 4, start = c(1959, 2))
  y <- ts(11:15, frequency = 4, start = c(1961, 4))
  c(as.zoo(x), as.zoo(y))

or you can also coerce back to "ts"

  as.ts(c(as.zoo(x), as.zoo(y)))

Personally, I tend to do my data manipulations in "zoo" (not very
surprisingly ;-)) but might coerce the resulting series to "ts" if I want
to use certain modeling functions.
Z

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

2008-01-10 Thread Lorenz Gabmann
Hi All!

Can someone help me with the following problem?

Lade nötiges Paket: tcltk
Loading Tcl/Tk interface ... Error in dyn.load(file, ...) :
   kann shared library '/Library/Frameworks/R.framework/Versions/2.6/ 
Resources/library/tcltk/libs/ppc/tcltk.so' nicht laden:
  dlopen(/Library/Frameworks/R.framework/Versions/2.6/Resources/ 
library/tcltk/libs/ppc/tcltk.so, 10): Library not loaded: /usr/X11R6/ 
lib/libX11.6.dylib
   Referenced from: /Library/Frameworks/R.framework/Versions/2.6/ 
Resources/library/tcltk/libs/ppc/tcltk.so
   Reason: image not found
Error : .onLoad in 'loadNamespace' für 'tcltk' fehlgeschlagen
Fehler: Paket 'tcltk' konnte nicht geladen werden


 > version
_
platform   powerpc-apple-darwin8.10.1
arch   powerpc
os darwin8.10.1
system powerpc, darwin8.10.1
status
major  2
minor  6.1
year   2007
month  11
day26
svn rev43537
language   R
version.string R version 2.6.1 (2007-11-26)


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

2008-01-10 Thread Gavin Simpson
On Thu, 2008-01-10 at 10:48 +, Marc Moragues wrote:
> Hi,
> 
> I am trying to calculate a distance matrix on a binary data frame using
> dist.binary() {ade4}. This is the code I run and the error I get:
> 
> > sjlc.dist <- dist.binary(as.data.frame(data), method=2) #D = (a+d) /
> (a+b+c+d)
> Error in if (any(df < 0)) stop("non negative value expected in df") :
>  missing value where TRUE/FALSE needed
> 
> I don't know if the problem are the missing values in my data. If so how
> can I handle them?

Marc,

Take a look at distance in package analogue and method = "mixed" which
implements Gower's general dissimilarity coefficient for mixed data. It
can deal quite happily with binary data and where there is missing-ness.
Binary data are handled through a simple matching coefficient, 1 if
variable i present in both samples, 0 otherwise, and then summed over
all variables i. You should probably read up on how the missing-ness is
handled with this method and what properties the resulting dissimilarity
has.

Note that distance() outputs full dissimilarity matrices. To get
something to plug into functions that require a dist object, just use
as.dist() on the output from distance().

HTH

G

> 
> Thank you,
> Marc. 
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> 
> SCRI, Invergowrie, Dundee, DD2 5DA.  
> The Scottish Crop Research Institute is a charitable company limited by 
> guarantee. 
> Registered in Scotland No: SC 29367.
> Recognised by the Inland Revenue as a Scottish Charity No: SC 006662.
> 
> 
> DISCLAIMER:
> 
> This email is from the Scottish Crop Research Institute, but the views 
> expressed by the sender are not necessarily the views of SCRI and its 
> subsidiaries.  This email and any files transmitted with it are confidential 
> to the intended recipient at the e-mail address to which it has been 
> addressed.  It may not be disclosed or used by any other than that addressee.
> If you are not the intended recipient you are requested to preserve this 
> confidentiality and you must not use, disclose, copy, print or rely on this 
> e-mail in any way. Please notify [EMAIL PROTECTED] quoting the 
> name of the sender and delete the email from your system.
> 
> Although SCRI has taken reasonable precautions to ensure no viruses are 
> present in this email, neither the Institute nor the sender accepts any 
> responsibility for any viruses, and it is your responsibility to scan the 
> email 
> and the attachments (if any).
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] how can i add a package that i want to use permanent

2008-01-10 Thread Charles Annis, P.E.
?.First
This will explain things.  


You make a hidden program called .First like this

.First <- function() { library(lattice) }

and then save your workspace.  The next time you open R, lattice will load
automatically.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of ???
Sent: Wednesday, January 09, 2008 10:28 PM
To: [EMAIL PROTECTED]
Subject: [R] how can i add a package that i want to use permanent

I want use a package(lattice) in R to do some work
but everytime when i open R program  ,this package is not loaded,
so  everytime  i have to load it ,
who can tell me  how to load this package permanent

thanks!!!
-- 
:zND2(
TEL:15918732631
E-MAIL:[EMAIL PROTECTED]
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

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


Re: [R] Error on distance matrix

2008-01-10 Thread Jari Oksanen
Jari Oksanen  oulu.fi> writes:

> 
> Marc Moragues  scri.ac.uk> writes:
> 
> > 
> > Hi,
> > 
> > I am trying to calculate a distance matrix on a binary data frame using
> > dist.binary() {ade4}. This is the code I run and the error I get:
> > 
> > > sjlc.dist <- dist.binary(as.data.frame(data), method=2) #D = (a+d) /
> > (a+b+c+d)
> > Error in if (any(df < 0)) stop("non negative value expected in df") :
> >  missing value where TRUE/FALSE needed
> > 
> > I don't know if the problem are the missing values in my data. If so how
> > can I handle them?
> > 
> Dear Marc Moragues,
> 
> At least adding NA to a data.frame gave the same error message as you report
> above. Odds are good for NA being responsible (but we cannot know: we only
> guess). 
...clip...
> One solution is to use function designdist in vegan where you can with some
> acrobary design your own dissimilarity indices. 

It is a bad habit to comment on yourself, but if you write stupid things, you
should tell so: that designdist() "handles" missing values is accidental,
unintentional and dangerous. Now you still should figure out *how* they are
handled, and the function should warn users if they supply data with missing
values. I hope that will be changed. 

>Function designdist uses
> different notations, because its author hates that misleading and dangerous 
> 2x2
> contingency table notation. The following, however, seems to define the same
> index as ade4:
> 
> designdist(data, "sqrt(1-(2*J+P-A-B)/P)")
> 
You can make this cuter:

designdist(data, "sqrt((A+B-2*J)/P)")

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] question about subset and join ts object(s)

2008-01-10 Thread tom soyer
Hi,

I have two questions about ts.

(1) How do I subset a ts object and still preserve the time index? for
example:

> x=ts(1:10, frequency = 4, start = c(1959, 2)) # the ts object
> x
 Qtr1 Qtr2 Qtr3 Qtr4
1959 123
19604567
196189   10
I don't want the 1st 2 elements, so I could subset like this:
> x[3:length(x)]
[1]  3  4  5  6  7  8  9 10

But then the time index is lost. I could use window(), but then I have to
specify start and end manually. Is there a way to subset a ts object so that
the time index is preserved for the data extracted without specifying start
and end data by hand?

(2) How do I join two ts objects together end to end? for example:
> x=ts(1:10, frequency = 4, start = c(1959, 2)) # the 1st ts object
> y=ts(11:15, frequency = 4, start = c(1961, 4)) # the 2nd ts object

As you can see, y is just a continuation of x. I would like to add y to the
end of x while preserving the time index. I could use this:
> ts(c(x,y),start=start(x),frequency=4)

But I am wondering if there is a more efficient way of doing this, i.e., is
it really necessary to specify start and frequency again when they are
already a part of the original ts objects?

Thanks!

-- 
Tom

[[alternative HTML version deleted]]

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


[R] [R-pkgs] PwrGSD

2008-01-10 Thread Grant Izmirlian
Hello List:

Please find uploaded to CRAN a new package, PwrGSD

The package is intended for the design and analysis of group sequential trials
There are two main functions, 
(1) GrpSeqBnds: computes group sequential stopping boundaries for interim
  analysis of a sequential trial based upon a normally distributed test 
  statistic. This can be done via the Lan-Demets procedure with 
  Obrien-Fleming, Pocock or Wang-Tsiatis spending. This can also be
  done via boundaries created to correspond with the stochastic 
  curtailment procedure.  

(2) PwrGSD (same as the package name) which computes operating 
  characteristics such as power, expected duration, weighted avergage 
  relative risks at the boundaries among other things, that correspond to 
  a user supplied hypothetical two arm trial under a user supplied choice
  of monitoring scheme and choice of test statistic within the weighted 
  log-rank class of test statistics. Computations are done either via 
  aysmptotic methods or via simulation.  Note:  another feature is the 
  flexible provision for time dependent non-compliance.  

  The function has a nice calling interface based upon the specification
  of boundary methods via functional forms.  There are alot of nice
  summarization methods which allow the user to explore the space of
  hypothetical trial scenarios and boundary construction methods, such as 
  a compound object class for linking individuals calls to PwrGSD to 
  components of a list that are linked to an indexing dataframe for 
  reference purpose.

  I appologize for a lengthy note, but attach a quite informative example 
  below.  

  Best Regards,

  Grant Izmirlian
  Mathematical Statistician
  Division of Cancer Prevention
  US National Cancer Institute
  1-(301)496-7519
  [EMAIL PROTECTED]
 Հրանտ Իզմիրլյան
-
   tlook <- c(7.14, 8.14, 9.14, 10.14, 10.64, 11.15, 12.14, 13.14,
  14.14, 15.14, 16.14, 17.14, 18.14, 19.14, 20.14)
   t0 <- 0:19  
   h0 <- c(rep(3.73e-04, 2), rep(7.45e-04, 3), rep(1.49e-03, 15))
   rhaz <-c(1, 0.9125, 0.8688, 0.7814, 0.6941, 0.6943, 0.6072, 0.5202,  
  0.4332, 0.652, 0.6524, 0.6527, 0.653, 0.6534, 0.6537, 
  0.6541, 0.6544, 0.6547, 0.6551, 0.6554)
hc <- c(rep(1.05e-02, 2), rep(2.09e-02, 3), rep(4.19e-02, 15))
hd1B <- c(0.1109, 0.1381, 0.1485, 0.1637, 0.2446, 0.2497, 0)


  test.example <- PwrGSD(
 EfficacyBoundary=LanDemets(alpha=0.05, spending= ObrienFleming),
 FutilityBoundary=LanDemets(alpha=0.1,spending=ObrienFleming),
 RR.Futility = 0.82, sided="<",method="A",accru =7.73, accrat=9818.65,
 tlook =tlook, tcut0 =t0, h0=h0, tcut1=t0, rhaz=rhaz, 
 tcutc0=t0, hc0=hc, tcutc1=t0, hc1=hc, 
 tcutd0B =c(0, 13), hd0B =c(0.04777, 0),
 tcutd1B =0:6, hd1B =hd1B,
 noncompliance =crossover, gradual =TRUE,
 WtFun =c("FH", "SFH", "Ramp"),
 ppar =c(0, 1, 0, 1, 10, 10))

 ## we will construct a variety of alternate hypotheses relative to the
 ## base case specified above

   max.effect <- 0.80 + 0.05*(0:8)
   n.me <- length(max.effect)

 ## we will also vary extent of censoring relative to the base case
 ## specified above

   cens.amt <- 0.75 + 0.25*(0:2)
   n.ca <- length(cens.amt)

 ## we may also wish to compare the Lan-Demets/O'Brien-Fleming efficacy
 ## boundary with a Pocock efficacy boundary

   Eff.bound.choice <- 1:2
   ebc.nms <- c("LanDemets(alpha=0.05, spending=ObrienFleming)",
"SC(alpha=0.05, crit=0.90)")
   n.ec <- length(Eff.bound.choice)

 ## The following line creates the indexing dataframe, `descr', with one
 ## line for each possible combination of the selection variables we've
 ## created.

   descr <- 
  as.data.frame(
 cbind(Eff.bound.choice=rep(Eff.bound.choice, each=n.ca*n.me),
  cens.amt=rep(rep(cens.amt, each=n.me), n.ec),
  max.effect=rep(max.effect, n.ec*n.ca)))

   descr$Eff.bound.choice <- ebc.nms[descr$Eff.bound.choice]

 ## Now descr contains one row for each combination of the levels of
 ## the user defined selection variables, `Eff.bound.choice',
 ## `max.effect' and `cens.amt'. Keep in mind that the names and number
 ## of these variables is arbitrary. Next we create a skeleton
 ## `cpd.PwrGSD' object with a call to the function `cpd.PwrGSD' with
 ## argument `descr'

   test.example.set <- cpd.PwrGSD(descr)

 ## Now, the newly created object, of class `cpd.PwrGSD', contains
 ## an element `descr', a component `date', the date created
 ## and a component `Elements', an empty list of length equal
 ## to the number of 

[R] [R-pkgs] prob package: elementary probability on finite sample spaces

2008-01-10 Thread G. Jay Kerns
Dear R Community,

I am pleased to announce the beta-release of the prob package.  The
source code is now on CRAN, and binaries should be generated there
before long. In the meantime, you can get it with

install.packages("prob", repos = "http://r-forge.r-project.org";)

The prob package gives a framework for doing elementary probability on
finite sample spaces in R.  The primary notion of "probability space"
has been built around the data frame structure, both for simplicity
and to maximize compatibility with the R Commander by John Fox.

The package addresses an ample proportion of material in a typical
undergraduate course in elementary probability, or the probability
material in an introductory statistics course. For details, see
vignette("prob").

Since the focus is on sample/probability spaces, the prob package
could be used as a precursor to the more sophisticated distrxxx-family
of packages.

Topics:

* construction of sample spaces (in the sense of 'prob' ) of various
kinds.  Some standard sample spaces are included (toss a coin, roll a
die, sample from an urn, draw cards, roulette, etc.)
* counting and the Multiplication Principle,
* subsets and events including methods for intersect, union, and
setdiff extending those in the base package,
* the prob function for finding probability and conditional
probability of events,
* simulation and relative frequencies,
* random variables, marginal distributions,
* extensions for more general sample spaces,
* discrete multivariate distributions with finite support,
* more...

Some discussion and examples can be found at the R-Forge prob project web page:

http://prob.r-forge.r-project.org/

There are many avenues for future development/improvement;  all
suggestions and comments are welcomed.  I would appreciate hearing
about your experiences with it in the classroom and elsewhere.

The audience for this package would include teachers and students of
elementary probability, or simply anyone wanting to dabble with
probability on a finite sample space.

Regards,
Jay




***
G. Jay Kerns, Ph.D.
Assistant Professor / Statistics Coordinator
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
E-mail: [EMAIL PROTECTED]
http://www.cc.ysu.edu/~gjkerns/

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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


[R] formatting ftable

2008-01-10 Thread Monica Pisica

Hi all, I am using ftable and xtabs to get total counts of species per location 
per hight category (understory, midstory and overstory). i can save the data in 
almost the format i would like it to be - but not quite. Here it is an example 
of what i get: x - is a dataframe with the following columns: LocationID, 
Species, PercentCover, Categorywhere Category tells if the Species belongs to 
understory, midstory or overstory  
y1 <- ftable(xtabs(PercentCover ~ LocationID + Species + Category, data=x))y2 
<- format(y1, quote = FALSE, sep = “,”)write.table(y2, “test1.csv”, row.names = 
FALSE, col.names = FALSE, sep = “,”)If i read the test1.csv it will look like 
that: Category  
  Midstory Overstory   Understory
LocationID Species
Loc1   A
   0 0 10
   B
   10   20   0
   C
   55   0 10
   ….   
  …   …   …
Loc2   A
   0 0 0
   B
   5 60   0
   C
   35   0 25
   …
  …   …   …
What i would like: (1) eliminate the column (Category) because it is empty 
anyway (i suppose i can create a new data.frame from y2 in which i skip column 
"Category"); (2) have LocationID, Species, Midstory, Overstory, and Understory 
on the same row; (3) have the column LocationIDfilled in between Loc1 and Loc2 
with Loc1 and not an empty string, and so on for each location.Any suggestions 
will be very greatly appreciated, thanks,Monica
_


PC_MediaCtr_bigscreen_012008
[[alternative HTML version deleted]]

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


Re: [R] Error on distance matrix

2008-01-10 Thread Jari Oksanen
Marc Moragues  scri.ac.uk> writes:

> 
> Hi,
> 
> I am trying to calculate a distance matrix on a binary data frame using
> dist.binary() {ade4}. This is the code I run and the error I get:
> 
> > sjlc.dist <- dist.binary(as.data.frame(data), method=2) #D = (a+d) /
> (a+b+c+d)
> Error in if (any(df < 0)) stop("non negative value expected in df") :
>  missing value where TRUE/FALSE needed
> 
> I don't know if the problem are the missing values in my data. If so how
> can I handle them?
> 
Dear Marc Moragues,

At least adding NA to a data.frame gave the same error message as you report
above. Odds are good for NA being responsible (but we cannot know: we only
guess). Further, it seems that ade4:::dist.binary does not have an option to
handle NA input. Problem here is that what do you think should be done with NA?
Should you get a NA result? Should the whole observation be removed because of
NA? Or should the comparisons be based on pairwise omissions of NA meaning that
index entries are based on different data in the same matrix? Or should you
impute some values for missing entries (which is fun but tricky)?

One solution is to use function designdist in vegan where you can with some
acrobary design your own dissimilarity indices. Function designdist uses
different notations, because its author hates that misleading and dangerous 2x2
contingency table notation. The following, however, seems to define the same
index as ade4:

designdist(data, "sqrt(1-(2*J+P-A-B)/P)")

See the documentation of vegan:::designdist to see how to define things there
(and the sqrt(1-x) part comes from the way ade4 changes similarities to
dissimilarities).

BTW, don't call your data 'data'. R wisdom (see fortunes) tells you that you do
not call your dog dog, but I'm not quite sure of this. At least in yesterdays
horse races in national betting, one of the winner horses was called 'Animal',
so why not...

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] as.date - german date format

2008-01-10 Thread Terry Therneau
>> Konga wrote:
>>> Hi,
>>>
>>> I have a data.frame with the following variable:
>>> $  xx  :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3
>>> 3
>>>
>>> now I?d like use "as.date" on it - if I comprehend the instructions on
>>> http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
>>> it should work like this:
>>>
>>> as.date(xx, "%d.%m.%Y") - but it doesn?t...
>> What is the error message? 
>> - Fehler in as.date(mydata$xx, "%d.%m.%Y") : 
>>   Cannot coerce to date format
 
  You are invoking a function from the "date" library, but reading
the documentation for "Date"; they are quite different.

  The 'date' library was written 8-10 years ago, and is used by some of the
functions in the survival library (a dependence that I am currently removing).
It works quite well, but has a much smaller scope of functionality than the 
later 'Date' library, in particular there are no attempts at multi-language
support.  So as.date + German format is nearly a contradiction.  

  > args(as.date)
  function (x, order = "mdy", ...) 
  
So you see that the function does not even have a "format" argument.  If your
delimiter were one of /,-  then order='dmy' would have worked, but as.date does 
not accept '.'

Terry Therneau

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


Re: [R] data.frame manipulation: Unbinding strings in a row

2008-01-10 Thread jim holtman
here is a quick hack:

> x <- read.table(textConnection("ID  ShopItems
+ ID1 A1  item1,item2,item3
+ ID2 A2  item4,item5
+ ID3 A1  item1,item3,item4"), header=TRUE)
> y <- lapply(1:nrow(x), function(.row){
+ .items <- strsplit(as.character(x$Items[.row]), ',')[[1]]
+ data.frame(ID=rep(x$ID[.row], length(.items)),
Shop=rep(x$Shop[.row], length(.items)),
+ Item=.items)
+ })
> do.call(rbind,y)
   ID Shop  Item
1 ID1   A1 item1
2 ID1   A1 item2
3 ID1   A1 item3
4 ID2   A2 item4
5 ID2   A2 item5
6 ID3   A1 item1
7 ID3   A1 item3
8 ID3   A1 item4


On Jan 10, 2008 6:40 AM, francogrex <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I have a data.frame I received with data that look like this (comma
> separated strings in last row):
>
> ID  ShopItems
> ID1 A1  item1, item2, item3
> ID2 A2  item4, item5
> ID3 A1  item1, item3, item4
>
>
> But I would like to unbind the strings in col(2) items so that it will look
> like this:
>
> ID  ShopItems
> ID1 A1  item1
> ID1 A1  item2
> ID1 A1  item3
> ID2 A2  item4
> ID2 A2  item5
> ID3 A1  item1
> ID3 A1  item3
> ID3 A1  item4
>
> Meaning each item is on a different row but still maintain the ties with the
> IDs and the Shops.
> The final purpose is to count how many times a particular item has been
> bought in a particular shop, like:
>
> item1-A1= 2
> item2-A1=1
> item3-A1=2
>
>
> Any ideas? Thanks
>
>
> --
> View this message in context: 
> http://www.nabble.com/data.frame-manipulation%3A-Unbinding-strings-in-a-row-tp14731173p14731173.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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


Re: [R] labels to values

2008-01-10 Thread Matthias Wendel
 
Hello, Henrique,
thank you for the tip, but it was not quite what has been desired:
> d[, 'Y6']
  [1]  6  3  8 11  8  9  6  8  3  5 10 15 NA  9  8  3  8 16  6  6 NA 10  5  2  
7  7  6 16  7 15  7 10 12  8  7 12 12 16  7  6  8  8
15  6 NA  8 99  7 12  8  9 16  7 16  8  7  7  1 15
 [60] 12  8  7 10  7  8  7  8  9  8  6  6  8  6 16 11  5 11 11  1 11  3  7  7 
10 10 10  6 11 16 NA  1  3  2 10 99 10  3  3  9  7 16
99 16  1 10  2 13 13 13 13 13 13 13 13 13 13 13 13
[119] 13 13 13 13 13 NA 10 16 16 NA  6 10  5 11 11  1  1  1  1 16  1 16  1  1  
1  1  6  6  6 16  8 16 16 16 16  5  6 10 99 11 11 10
6  6  1  1  6  1 11 11 16  9 11 16  6  8  8 16 16
[178]  8  6 16 16 12 12 12 12 12 12 12 16  9 16 15 12 12 15 10 16 15  4  1  2 
14  4  4  2  5 NA  1  5  5  7  9  5 12 12 NA 16 12 12
12 12 12 12 12 12 12 99 NA 12 12 NA  1 16  1  7 11
[237]  5  6  7  1 13  6  8 16  2  1  5 16 16  9  8  8  8  7 16  8  8  2  8  5  
4  6 14  5 14  8  8 14  4  4  8 14  8 14  6  2  3 14
3 16  5 15 15 15 15 15 15 15 15 15 15 15 13 13 13
[296] 13 13 13 13 13 13 13 13 13 13 15  6 NA 12  3  9  9 NA 10 16
attr(,"value.labels")
n.a.   Verwaltung 
Servicegesellschaft Waldfriede (SKW)
Kurzzeitpflege Waldfriede 
  99   16   
15
14 
   Sozialstation  Krankenpflegeschule   
   Med. Technischer Dienst
Pflege OP 
  13   12   
11
10 
 Funktionsdienst   Pflege Gynäkologie   
  Pflege Chirurgie
Pflege Innere 
   98   
 7
6 
   Ärzte Anästhesie, RöntgenÄrzte Gynäkologie   
   Ärzte Chirurgie
Ärzte Innere 
   54   
 3
2 
Patientenberatung/-betreuung 
   1 
> x1 <- as.factor(d[,'Y6'])
> levels(x1)[levels(x1) %in% attributes(x1)[1]] <- 
> c(names(unlist(lapply(levels(x1),function(z)which(z==attributes(x1)[[1]])
Fehler in levels(x1)[levels(x1) %in% attributes(x1)[1]] <- 
c(names(unlist(lapply(levels(x1),  : 
  inkompatible Typen (von NULL nach character) in subassignment Typ fix
> 

Meanwhile, I solved the problem by takin another route: the data.frame d was 
imported my read.spss; read.spss imports the factors as
factors only if number of distinct labels is equal to number of distinct 
values. By assuring this (it was not the case for Y6), I've
got what I Want.
Regards,
Matthias

-Ursprüngliche Nachricht-
Von: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 9. Januar 2008 17:17
An: Matthias Wendel
Cc: [EMAIL PROTECTED]
Betreff: Re: [R] labels to values

If I understand your question, you can do:

x1 <- as.factor(d[,'Y6'])
levels(x1)[levels(x1) %in% attributes(x)[1]] <- 
c(names(unlist(lapply(levels(x1),function(z)which(z==attributes(x)[[1]])

On 09/01/2008, Matthias Wendel <[EMAIL PROTECTED]> wrote:
> I couldn't find out how the following to solve:
> There is a column in a data.frame:
>
> > d[, 'Y6']
>   [1]  6  3  8 11  8  9  6  8  3  5 10 15 NA  9  8  3  8 16  6  6 NA 
> 10  5  2  7  7  6 16  7 15  7 10 12  8  7 12 12 16  7  6  8  8
> 15  6  [45] NA  8 99  7 12  8  9 16  7 16  8  7  7  1 15 12  8  7 10  
> 7  8  7  8  9  8  6  6  8  6 16 11  5 11 11  1 11  3  7  7 10 10 10  6 
> 11  [89] 16 NA  1  3  2 10 99 10  3  3  9  7 16 99 16  1 10  2 13 13 
> 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 NA 10 16
> 16 NA  6 10  5 11 [133] 11  1  1  1  1 16  1 16  1  1  1  1  6  6  6 
> 16  8 16 16 16 16  5  6 10 99 11 11 10  6  6  1  1  6  1 11 11
> 16  9 11 16  6  8  8 16 [177] 16  8  6 16 16 12 12 12 12 12 12 12 16  
> 9 16 15 12 12 15 10 16 15  4  1  2 14  4  4  2  5 NA  1  5  5
> 7  9  5 12 12 NA 16 12 12 12 [221] 12 12 12 12 12 12 99 NA 12 12 NA  1 
> 16  1  7 11  5  6  7  1 13  6  8 16  2  1  5 16 16  9  8  8
> 8  7 16  8  8  2  8  5  4  6 14  5 [265] 14  8  8 14  4  4  8 14  8 14  
> 6  2  3 14  3 16  5 15 15 15 15 15 15 15 15 15 15 15 13 13
> 13 13 13 13 13 13 13 13 13 13 13 15  6 NA [309] 12  3  9  9 NA 10 16
> attr(,"value.labels")
>   Verwaltung Servicegesellschaft Waldfriede (SKW) 
>Kurzzeitpflege Waldfriede
>   16   15 
>   14
>Sozialstation  Krankenpflegeschule 
>  Med. Technischer Dienst
>   13   12 
>   11
>Pflege OP  Funktionsdienst 
>   Pflege Gynäkologie

[R] data.frame manipulation: Unbinding strings in a row

2008-01-10 Thread francogrex

Hi all,

I have a data.frame I received with data that look like this (comma
separated strings in last row):

ID  ShopItems
ID1 A1  item1, item2, item3
ID2 A2  item4, item5
ID3 A1  item1, item3, item4


But I would like to unbind the strings in col(2) items so that it will look
like this:

ID  ShopItems
ID1 A1  item1
ID1 A1  item2
ID1 A1  item3
ID2 A2  item4
ID2 A2  item5
ID3 A1  item1
ID3 A1  item3
ID3 A1  item4

Meaning each item is on a different row but still maintain the ties with the
IDs and the Shops. 
The final purpose is to count how many times a particular item has been
bought in a particular shop, like:

item1-A1= 2
item2-A1=1
item3-A1=2


Any ideas? Thanks


-- 
View this message in context: 
http://www.nabble.com/data.frame-manipulation%3A-Unbinding-strings-in-a-row-tp14731173p14731173.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] `[.data.frame`(df3, , -2) and NA col umns

2008-01-10 Thread Dieter Menne
Dear baseRs,

I recently made a mistake when renaming data frame columns, accidentally
creating an NA column. I found the following strange behavior when negative
indexes are used.

Can anyone explain what happens here.  No "workarounds" required, just  curious.

Dieter

Version: Windows, R version 2.6.1 (2007-11-26)

#-
df = data.frame(a=0:10,b=10:20)
df[,-2] #ok
names(df)=c("A") # implicitly creates an NA column
df[,-2] 
df[,-2,drop=FALSE]   # has nothing to do with drop

df3 = data.frame(a=0:10,b=10:20,c=20:30)
df3[,-2] #ok
names(df3)=c("A","B") #creates an NA column
df3[,-2] # error
# Error in `[.data.frame`(df3, , -2) : undefined columns selected

names(df3)[3]="NaN" # another reserved word
df3[,-2] # no problem

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