Re: [R] cum sums

2014-03-10 Thread Jim Lemon
In fact, I erred by summing both the year and the value, so i would 
recommend Peter's (much less messy) solution.


Jim

On 03/10/2014 02:57 PM, Peter Alspach wrote:

Tena koe Philip

An alternative to Jim's solution which seems to work and you may, or may not, 
find less messy:

df- read.table(text=id yr val
a 1950 1
b 1950 10
a 1951 2
b 1952 3
c 1952 4
a 1954 5
b 1954 2
c 1954 3,header=TRUE)
df1- df[order(df$id, df$yr),]
df1$valCS- unlist(by(df1$val, df1$id, cumsum))
df1

If you need to get back to the original order you can sort by row.names.

HTH 

Peter Alspach



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

2014-03-10 Thread Amer Bakkach
Dear R-help,
i am working on some research and want to do some comparison among
information criterion (e.g. AIC,BIC,..) and want to include (NML); i found
AICcmodavg , infotheo -for mutual information- and 'SpatialExtremes

however i couldn't find any R-package that provide (NML) calculus;

any idea?
best regards;
Amer.

[[alternative HTML version deleted]]

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


Re: [R] How to obtain a mean by more than one other variable

2014-03-10 Thread arun


Hi,
If `dat` is the dataset:

with(dat,ave(ABUNDHA,SITE,REP,FUN=mean))
#[1] 0.46 0.46 0.14 0.03 0.22 0.67 0.01

I am not sure how you got 0.45 when REP's are not the same.

A.K.

On Sunday, March 9, 2014 11:29 PM, Erynn Call erynn.c...@maine.edu wrote:
I'm trying to create a new variable (meanABUNDHA) by obtaining a mean value
*by* other variables.  I surveyed birds (multiple species) at multiple sites
and have multiple surveys within a REP (i.e. in example data below, SURVEY
55 and 57 are in REP 11).  I need the mean ABUNDHA (pooling SURVEY) for each
BIRD species by REP and by SITE. Below, I would average 0.77 and 0.15 for
MALL in REP 11 at SITE 1 to get 0.46 meanABUNDHA.

An example of my data are as follows, including the new variable I hope to
create meanABUNDHA:
SITE    REP     SURVEY  BIRD    ABUNDHA meanABUNDHA
1       11            57             MALL      0.77            0.46
1       11            55             MALL      0.15            0.46
1       12            58             MALL      0.14            0.14
1       2              58             BAEA     0.03            0.03
3       4              64             AMCR     0.22            0.45
3       5              65             AMCR     0.67            0.45
7       11             56             MALL      0.01            0.01

I'm not sure how to incorporate more than one by=?

data.all4[,mean(ABUNDHA),by=
REP]

#Add new column containing the by-REP mean of ABUNDHA
data.all5-data.all4[,ABUNDHAmean:=mean(ABUNDHA),by=REP]

Thank you for any guidance!!

    [[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] Help resolving issues with generating a chi-squared density plot from scratch

2014-03-10 Thread Rolf Turner


I am far too lazy to go through all your rather complicated code, but my 
basic impression is that you are re-inventing quite a few wheels.


Just to get a plot of the density function you can simply do, e.g.:

plot(function(x){dchisq(x,1)},0,qchisq(0.999,1))

I can't see why you are fooling about with the ylim values; just let the 
plot() function choose ylim.


As to why you can't get things to work when df=1 ... well don't try to 
set the upper y limit equal to infinity! You have a finite plotting 
region, after all.


I have no idea what you mean by The y-axis is numbered only 
relatively; this makes no sense at all.  What *do* you want?  The 
y-axis labelling that you get will be/is the appropriate labelling.


The arrows will go where you tell them to go, so if they are going 
diagonal you are telling them to go diagonal.


cheers,

Rolf Turner

On 10/03/14 13:30, Levi Robinson wrote:

I wrote the code to graph a chi-squared density function, shade the
percentile, and point to the CV, but it has a few issues I can't seem to
resolve

1. It won't work at all for DF = 1 due to ylim going to infinity, but I
haven't been able to resolve this still after hours of trying.
2) The y-axis is numbered only relatively; I'd prefer they were the actual
prob densities, but again, I fiddled with a few things, but it just
wouldn't get me what I wanted.
3) For low degrees of freedom and higher percentiles, the arrow pointing to
CV seems to end up going diagonal instead of straight down

Here's the code below and here's the URL for R fiddle for the code which
might make it easier to fix:
http://www.r-fiddle.org/#/fiddle?id=ChFi0dyJversion=4


chi.dens = function(x = NULL, df = NULL, cv = NULL) {

 # x = percentile/quantile
 # df = degrees of freedom
 # cv = critical value

 if(x1 ||x0) stop(Percentile must be between 0 and 1) #
Error-handling


 qend = qchisq(x, df)
 perc = x

 qt0=qchisq(0.5, df)   # Defining for arrows later
 dy0=dchisq(0.45, df)  # Defining for arrows later

 xrange = qchisq (0.999, df)
 x = seq(0, xrange)
 y = dchisq(x, df)
 yheight = max(dchisq(x, df))

 # Creating plot
 plot(x,y,type = l, ylim=c(0,yheight),axes=FALSE)

 title( Chi-squared Density Curve with)
 mtext(bquote(paste(DF = , .(df),  and Percentile = , .(perc))),
side = 3, line = 0) # Input information

 # Shading left tail-region

 qt = signif(qend,5)
 x0=seq(0, qt)
 y0=dchisq(x0, df)
 polygon(c(0, x0, qt), c(0, y0, 0), col = lightblue)
 xtks=signif(seq(0,xrange,length=10),3)
 axis(1, pos=0, at=xtks, labels=xtks)
 y.unit=max(dchisq(x, df))/5
 y.pos=seq(0,5*y.unit, length=5)
 y.lab=c(0, 1, 2, 3, 4) # Y axis numbers only reflect relative
densities to each other.
 axis(2,pos=0, at=y.pos, labels=y.lab)# set up y-axis

 # Normal CV less than the 99.9 Percentile:

   if(qt = xrange){
  if(length(cv)==0) text(0.75*xrange,3*y.unit, bquote(paste(CV = ,
.(qend))), cex=1.2, col = red,adj=0.5)
  #
  if(length(perc)==1)  text(0.35*xrange,3*y.unit, paste(Area = ,
perc), cex=1.2, col=darkblue, adj=0.5)
  if(perc0.5){
 arrows(0.35*xrange, 2.5*y.unit, qt0, 0.3*dy0,  length=0.1,
angle=20) # pointing to the shaded region
 }
  if(perc=0.5){
 arrows(0.35*xrange, 2.5*y.unit, qt/2, 0.3*dy0,  length=0.1,
angle=20) # pointing to the shaded region
   }
 arrows(0.75*xrange, 2.5*y.unit, qt, 0, length=0.1, angle=20)
 points(qt,0,pch=17, col=red)
}

 # When CV is greater than the 99.9 Percentile:

  if(qt  xrange){

  print(CV may be too far to the right to be shown on graph due to the
high percentile)

  if(length(cv)==0) text(0.75*xrange,3*y.unit, bquote(paste(CV = ,
.(qend))), cex=1.2, col = red,adj=0.5)

  if(length(perc)==1)  text(0.35*xrange,3*y.unit, paste(Area = ,
perc), cex=1.2, col=darkblue, adj=0.5)
  if(perc0.5){
 arrows(0.35*xrange, 2.5*y.unit, qt0, 0.3*dy0,  length=0.1,
angle=20) # pointing to the shaded region
 }
  if(perc=0.5){
 arrows(0.35*xrange, 2.5*y.unit, qt/2, 0.3*dy0,  length=0.1,
angle=20) # pointing to the shaded region
   }
 arrows(0.75*xrange, 2.5*y.unit, qt, 0, length=0.1, angle=20)
 points(qt,0,pch=17, col=red)
   }

}


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

2014-03-10 Thread Lietz, Haiko
Hi all,

I have dynamic large 2-mode networks (1st mode ~50k nodes, 2nd mode ~500k 
nodes, timepoints ~100).

I want to identify the number of new nodes and new edges per timepoint in 
folded 1-mode networks.

In other words, I want to do measure graph densification as proposed by 
Leskovec et al. 
(http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.262.3092rep=rep1type=pdf)

What package should I use?

Best wishes

Haiko


Haiko Lietz
GESIS - Leibniz Institute for the Social Sciences
Department of Computational Social Science
Unter Sachsenhausen 6-8, D-50667 Köln
Tel: + 49 (0) 221 / 476 94 -223
eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org
Web: http://www.gesis.orghttp://www.gesis.org/


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

2014-03-10 Thread Jon Nash
I have just installed R 3.0.3 on Windows 7.

I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
happens, Ive tried manuals, forums etc ...

An ex-student needs help using this program.  I spent 7 years as an IT
consultant before becoming a maths teacher so Im better than average with
IT and I cant get it to do anything at all.  What's up?  Any help greatly
appreciated.

Jon

[[alternative HTML version deleted]]

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


Re: [R] R Help

2014-03-10 Thread Pascal Oettli
Hello,

And what are you expecting the command setwd to do?

Regards,
Pascal

On Mon, Mar 10, 2014 at 5:59 PM, Jon Nash jon.n...@hvhs.school.nz wrote:
 I have just installed R 3.0.3 on Windows 7.

 I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
 happens, Ive tried manuals, forums etc ...

 An ex-student needs help using this program.  I spent 7 years as an IT
 consultant before becoming a maths teacher so Im better than average with
 IT and I cant get it to do anything at all.  What's up?  Any help greatly
 appreciated.

 Jon

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] R Help

2014-03-10 Thread Rui Barradas

Hello,

The function setwd returns the previous working directory invisibly so 
nothing happens might mean that there is no apparent feedback. You can 
see if it changed the wd with getwd().


Hope this helps,

Rui Barradas

Em 10-03-2014 10:58, Pascal Oettli escreveu:

Hello,

And what are you expecting the command setwd to do?

Regards,
Pascal

On Mon, Mar 10, 2014 at 5:59 PM, Jon Nash jon.n...@hvhs.school.nz wrote:

I have just installed R 3.0.3 on Windows 7.

I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
happens, Ive tried manuals, forums etc ...

An ex-student needs help using this program.  I spent 7 years as an IT
consultant before becoming a maths teacher so Im better than average with
IT and I cant get it to do anything at all.  What's up?  Any help greatly
appreciated.

Jon

 [[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] package environment versus namespace environment

2014-03-10 Thread Duncan Murdoch

On 14-03-09 1:59 PM, Benjamin Tyner wrote:

Duncan,

Thanks for the explanation and commentary. Starting to make more
sense...so, long story short, it seems the first thing one should check
is whether base imports utils:

 packageDescription(base)
Package: base
Version: 3.0.1
Priority: base
Title: The R Base Package
Author: R Core Team and contributors worldwide
Maintainer: R Core Team r-c...@r-project.org
Description: Base R functions
License: Part of R 3.0.1
Built: R 3.0.1; ; 2013-10-16 10:50:56 UTC; unix

-- File: /usr/lib/R/library/base/Meta/package.rds

I'll interpret the lack of an Imports: line to mean that base does not
import any packages. So then the next thing to check is the enclosing
environment:

 parent.env(.BaseNamespaceEnv)
environment: R_GlobalEnv

Ah-ha! Unlike the base package environment, the base namespace
environment has its enclosing environment already on the search path, so
eventually leads back to utils. (This is the piece of the puzzle
prompting my original question about ... machinery that allows ...)

So hypothetically, if I had attached utils ahead of .GlobalEnv on the
search path, then functions in the base namespace would no longer be
able to see objects in utils? (I realize the answer may be vacuous,
since library() does not honor pos=1).


I suspect in that alternate universe the base namespace would still be 
parented by the first entry in the search list.


Duncan Murdoch



Regards,
Ben


On 03/09/2014 09:09 AM, Duncan Murdoch wrote:

On 14-03-08 6:42 PM, Benjamin Tyner wrote:

Duncan,

Thank you for the informative link. So, do the loaded namespaces have an
ordering akin to the package search path that determines that
functions in the base namespace can see objects in the utils namespace?
(I noticed that loadedNamespaces() just comes back in alphabetical
order.)


No.  The article that Henrik cited gives a reasonable description up
until near the end, where (in my opinion) it makes things
unnecessarily complicated.  I'd recommend that you stop reading around
where he tries to explain the dotted lines.  In particular, ignore the
second version of the Map of the World; the first one is accurate,
the second is just misleading.

In answer to your question:  Gupta's article misses the possibility of
packages that are loaded but not in the search path.  In the notation
of the first part of that article, loading a namespace just puts it in
the middle two columns (i.e. creates the namespace and imports
environments) without putting it in the search list.  That happens
when you import or load a package without attaching it.  The search
path imposes an ordering, things that aren't in it aren't ordered.

Duncan Murdoch




Regards
Ben

On 03/07/2014 11:46 AM, Duncan Murdoch wrote:

On 07/03/2014 10:16 AM, Benjamin Tyner wrote:

Hello,

I realize that a function in environment: base (for example,
function
head1 below) is unable to see (without resorting to ::, anyway)
objects in utils (for example, head below), since package:base is
after package:utils on the search path.




However, I'm wondering what is the machinery that allows a function in
environment: namespace:base (for example, function head2 below) to
be able to see head just fine, without needing to resort to ::.



See Luke Tierney's article in R News,

Name space management for R. Luke Tierney, R News, 3(1):2-6, June 2003
http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf

There's a link to it from the R help system.  Run help.start(), then
look at Technical papers in the Miscellaneous Material section.

I believe most of what it says is still current; the only thing I can
see at a glance that is no longer correct is that in those days
namespaces were optional in packages.  Now all packages have
namespaces.

Duncan Murdoch



I'm also wondering more generally, why there is a need (practically
speaking) for a distinction between the environment associated with a
package and the environment associated with the namespace.

$ export R_PROFILE=/home/btyner/Rprofile.site

$ cat /home/btyner/Rprofile.site
sys.source(/home/btyner/head1.R, envir = baseenv())
sys.source(/home/btyner/head2.R, envir = .BaseNamespaceEnv)

$ cat /home/btyner/head1.R
head1 - function(x) head(x)

$ cat /home/btyner/head2.R
head2 - function(x) head(x)

$ Rscript -e head1(letters)
Error in head1(letters) : could not find function head
Execution halted

$ Rscript -e head2(letters)
[1] a b c d e f

$ Rscript -e sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)

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

attached 

[R] catering for rescaling

2014-03-10 Thread Geoffrey
My barplot has nicely left justified horizontal labels, the names of 
people. Written using text() . I use par(user)[1] - OFFSET to get the 
placed nicely.


Now of course if i manually rescale/zoom the plot the labels get redrawn 
at the 'wrong' location, including off the left of the plot.


I assume this is because the x-position is based off the size of a unit 
in the plot, which changes when i rescale.


Can i get some pointers on how to adjust for this?

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] cum sums

2014-03-10 Thread Ista Zahn
Another option is

library(plyr)
ddply(df, id, transform, valCS = cumsum(val))

Best,
Ista

On Mon, Mar 10, 2014 at 12:27 AM, Jim Lemon j...@bitwrit.com.au wrote:
 In fact, I erred by summing both the year and the value, so i would
 recommend Peter's (much less messy) solution.

 Jim


 On 03/10/2014 02:57 PM, Peter Alspach wrote:

 Tena koe Philip

 An alternative to Jim's solution which seems to work and you may, or may
 not, find less messy:

 df- read.table(text=id yr val
 a 1950 1
 b 1950 10
 a 1951 2
 b 1952 3
 c 1952 4
 a 1954 5
 b 1954 2
 c 1954 3,header=TRUE)
 df1- df[order(df$id, df$yr),]
 df1$valCS- unlist(by(df1$val, df1$id, cumsum))
 df1

 If you need to get back to the original order you can sort by row.names.

 HTH 

 Peter Alspach


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] format for as.Date and inserting missing rows in a data frame

2014-03-10 Thread Stefano Sofia
Thank you to Arun and Petr for the give hints, veru useful.
In order to get the date output in the required format, these are the commands 
that works:

dat1$Date - as.Date(paste(dat1$Y_init, dat1$M_init, dat1$D_init, sep= ), 
format=%Y %m %d)

dat1$Date1 - strptime(as.character(dat1$Date), %Y-%m-%d)
dat1$Date1txt - format(dat1$Date1, %Y%m%d)

Stefano




Da: arun [smartpink...@yahoo.com]
Inviato: martedì 4 marzo 2014 17.06
A: r-help@r-project.org
Cc: Stefano Sofia
Oggetto: Re: [R] format for as.Date and inserting missing rows in a data frame

Hi,
May be this helps:
dat - read.table(text=Raingouge_number Station_number Year Month Day Rainfall
2004 2230 1951 1 1 2.60
2004 2230 1951 1 2 0.40
2004 2230 1951 1 3 0.00
2004 2230 1951 1 4 0.00
2004 2230 1951 1 5 0.20
2004 2230 1951 1 6 0.00
2004 2230 1951 1 7 0.00
2004 2230 1951 1 9 0.00
2004 2230 1951 1 10 0.00
2004 2230 1951 1 11 0.20,sep=,header=TRUE)
dat -  within(dat,Date - as.Date(paste(Year,Month,Day),format=%Y %m %d))
dat2 - data.frame(Date=seq(dat$Date[1],dat$Date[length(dat$Date)],by=day))
 res - merge(dat,dat2,all=TRUE)
res$Rainfall[is.na(res$Rainfall)] - -999
res
A.K.




On Tuesday, March 4, 2014 5:58 AM, Stefano Sofia 
stefano.so...@regione.marche.it wrote:
Dear R users,
I have a very long data frame (50 years, more than 1.5 million rows) of daily 
rainfall data from about 80 raingouges.
The data frame that I have been given looks like

Raingouge_number Station_number Year Month Day Rainfall
2004 2230 1951 1 1 2.60
2004 2230 1951 1 2 0.40
2004 2230 1951 1 3 0.00
2004 2230 1951 1 4 0.00
2004 2230 1951 1 5 0.20
2004 2230 1951 1 6 0.00
2004 2230 1951 1 7 0.00
2004 2230 1951 1 8 0.00
2004 2230 1951 1 9 0.00
2004 2230 1951 1 10 0.00
...

There could be some missing days. I have two questions.
1st question:
In order to handle eventual missing days I think that I have to transform three 
separate numbers (Year, Month and Day) to Date.
Is there a format in as.Date suitable for this transformation or before all I 
have to set all the months and days to two digits, remove spaces and then apply
as.Date with format %Y%m%d?

2nd question
In case of missing day, the corresponding row will be missing and then I have 
to insert this new row and put -999.9 as Rainfall. Is there an easy way to do 
that?


Thank you for your help
Stefano



AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 resolving issues with generating a chi-squared density plot from scratch

2014-03-10 Thread David Winsemius
If you set range of x in  [0, something ] for for a function that goes to 
infinity for x=0, then what do you expect?

 On Mar 10, 2014, at 7:30 AM, Levi Robinson robin...@gmail.com wrote:
 
 I wrote the code to graph a chi-squared density function, shade the
 percentile, and point to the CV, but it has a few issues I can't seem to
 resolve
 
 1. It won't work at all for DF = 1 due to ylim going to infinity, but I
 haven't been able to resolve this still after hours of trying.
 2) The y-axis is numbered only relatively; I'd prefer they were the actual
 prob densities, but again, I fiddled with a few things, but it just
 wouldn't get me what I wanted.
 3) For low degrees of freedom and higher percentiles, the arrow pointing to
 CV seems to end up going diagonal instead of straight down
 
 Here's the code below and here's the URL for R fiddle for the code which
 might make it easier to fix:
 http://www.r-fiddle.org/#/fiddle?id=ChFi0dyJversion=4
 
 
 chi.dens = function(x = NULL, df = NULL, cv = NULL) {
 
# x = percentile/quantile
# df = degrees of freedom
# cv = critical value
 
if(x1 ||x0) stop(Percentile must be between 0 and 1) #
 Error-handling
 
 
qend = qchisq(x, df)
perc = x
 
qt0=qchisq(0.5, df)   # Defining for arrows later
dy0=dchisq(0.45, df)  # Defining for arrows later
 
xrange = qchisq (0.999, df)
x = seq(0, xrange)
y = dchisq(x, df)
yheight = max(dchisq(x, df))
 
# Creating plot
plot(x,y,type = l, ylim=c(0,yheight),axes=FALSE)
 
title( Chi-squared Density Curve with)
mtext(bquote(paste(DF = , .(df),  and Percentile = , .(perc))),
 side = 3, line = 0) # Input information
 
# Shading left tail-region
 
qt = signif(qend,5)
x0=seq(0, qt)
y0=dchisq(x0, df)
polygon(c(0, x0, qt), c(0, y0, 0), col = lightblue)
xtks=signif(seq(0,xrange,length=10),3)
axis(1, pos=0, at=xtks, labels=xtks)
y.unit=max(dchisq(x, df))/5
y.pos=seq(0,5*y.unit, length=5)
y.lab=c(0, 1, 2, 3, 4) # Y axis numbers only reflect relative
 densities to each other.
axis(2,pos=0, at=y.pos, labels=y.lab)# set up y-axis
 
# Normal CV less than the 99.9 Percentile:
 
  if(qt = xrange){
 if(length(cv)==0) text(0.75*xrange,3*y.unit, bquote(paste(CV = ,
 .(qend))), cex=1.2, col = red,adj=0.5)
 #
 if(length(perc)==1)  text(0.35*xrange,3*y.unit, paste(Area = ,
 perc), cex=1.2, col=darkblue, adj=0.5)
 if(perc0.5){
arrows(0.35*xrange, 2.5*y.unit, qt0, 0.3*dy0,  length=0.1,
 angle=20) # pointing to the shaded region
}
 if(perc=0.5){
arrows(0.35*xrange, 2.5*y.unit, qt/2, 0.3*dy0,  length=0.1,
 angle=20) # pointing to the shaded region
  }
arrows(0.75*xrange, 2.5*y.unit, qt, 0, length=0.1, angle=20)
points(qt,0,pch=17, col=red)
   }
 
# When CV is greater than the 99.9 Percentile:
 
 if(qt  xrange){
 
 print(CV may be too far to the right to be shown on graph due to the
 high percentile)
 
 if(length(cv)==0) text(0.75*xrange,3*y.unit, bquote(paste(CV = ,
 .(qend))), cex=1.2, col = red,adj=0.5)
 
 if(length(perc)==1)  text(0.35*xrange,3*y.unit, paste(Area = ,
 perc), cex=1.2, col=darkblue, adj=0.5)
 if(perc0.5){
arrows(0.35*xrange, 2.5*y.unit, qt0, 0.3*dy0,  length=0.1,
 angle=20) # pointing to the shaded region
}
 if(perc=0.5){
arrows(0.35*xrange, 2.5*y.unit, qt/2, 0.3*dy0,  length=0.1,
 angle=20) # pointing to the shaded region
  }
arrows(0.75*xrange, 2.5*y.unit, qt, 0, length=0.1, angle=20)
points(qt,0,pch=17, col=red)
  }
 
 }
 
[[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] catering for rescaling

2014-03-10 Thread David Winsemius
If you use axis instead of text the positions should get set in user 
coordinates.

-- 
David

 On Mar 10, 2014, at 6:34 PM, Geoffrey lordgeoff...@optusnet.com.au wrote:
 
 My barplot has nicely left justified horizontal labels, the names of people. 
 Written using text() . I use par(user)[1] - OFFSET to get the placed nicely.
 
 Now of course if i manually rescale/zoom the plot the labels get redrawn at 
 the 'wrong' location, including off the left of the plot.
 
 I assume this is because the x-position is based off the size of a unit in 
 the plot, which changes when i rescale.
 
 Can i get some pointers on how to adjust for this?
 
 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.

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


Re: [R] Graph densification in large networks

2014-03-10 Thread Lietz, Haiko
I didn't remember Leskovec et al.'s work correctly. They don't compute the 
number of new nodes and new edges per unit time but just the number of nodes 
and edges. This makes it a lot easier.

But nevertheless, if I wanted to compute the number of new edges - what package 
would I use for large (and not necessarily sparse) graphs?

Haiko
 

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von Lietz, Haiko
Gesendet: Montag, 10. März 2014 10:34
An: r-help@r-project.org
Betreff: [R] Graph densification in large networks

Hi all,

I have dynamic large 2-mode networks (1st mode ~50k nodes, 2nd mode ~500k 
nodes, timepoints ~100).

I want to identify the number of new nodes and new edges per timepoint in 
folded 1-mode networks.

In other words, I want to do measure graph densification as proposed by 
Leskovec et al. 
(http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.262.3092rep=rep1type=pdf)

What package should I use?

Best wishes

Haiko


Haiko Lietz
GESIS - Leibniz Institute for the Social Sciences
Department of Computational Social Science
Unter Sachsenhausen 6-8, D-50667 Köln
Tel: + 49 (0) 221 / 476 94 -223
eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org
Web: http://www.gesis.orghttp://www.gesis.org/


[[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] F10.1 and i3 format in R

2014-03-10 Thread Stefano Sofia
Dear list members,
I have to export (through 'write.table') a dataframe where two columns must be 
respectively F10.1 (floating with 10 digits, 1 of which for the decimal 
position) and i3 (integer of length 3).
I looked at the 'format' options, but I couldn't see what I need.
I also looked for some examples, with no success.
Is it possible to do it within R without external work?

Thank you for your help
Stefano





AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[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] F10.1 and i3 format in R

2014-03-10 Thread Duncan Murdoch

On 10/03/2014 9:22 AM, Stefano Sofia wrote:

Dear list members,
I have to export (through 'write.table')


Why restrict yourself to write.table?

a dataframe where two columns must be respectively F10.1 (floating with 10 
digits, 1 of which for the


That's not the usual meaning for F10.1: normally the 10 char width 
includes the decimal point, not just the digits.

decimal position) and i3 (integer of length 3).
I looked at the 'format' options, but I couldn't see what I need.


I'd suggest converting the numbers to character vectors in the right 
format, then writing those out (perhaps with write.table, but not 
necessarily).


sprintf() uses C-like format strings, where %10.1f is close to F10.1, 
and %3d is close to i3. You could convert all of the numbers at once 
and use writeLines, e.g.


writeLines(somefile, sprintf(%10.1f%3d, f, i))

will pack two numbers per line with no extra spaces between.

Duncan Murdoch

I also looked for some examples, with no success.
Is it possible to do it within R without external work?

Thank you for your help
Stefano





AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[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] F10.1 and i3 format in R

2014-03-10 Thread Rui Barradas

Hello,

Take a look at ?sprintf.


sprintf(%9.1f, 12.3)
sprintf( %3d, 123)

Hope this helps,

Rui Barradas

Em 10-03-2014 13:22, Stefano Sofia escreveu:

Dear list members,
I have to export (through 'write.table') a dataframe where two columns must be 
respectively F10.1 (floating with 10 digits, 1 of which for the decimal 
position) and i3 (integer of length 3).
I looked at the 'format' options, but I couldn't see what I need.
I also looked for some examples, with no success.
Is it possible to do it within R without external work?

Thank you for your help
Stefano





AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[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] Graph densification in large networks

2014-03-10 Thread Rui Barradas

Hello,

Take a look at package igraph.

Hope this helps,

Rui Barradas

Em 10-03-2014 12:30, Lietz, Haiko escreveu:

I didn't remember Leskovec et al.'s work correctly. They don't compute the 
number of new nodes and new edges per unit time but just the number of nodes 
and edges. This makes it a lot easier.

But nevertheless, if I wanted to compute the number of new edges - what package 
would I use for large (and not necessarily sparse) graphs?

Haiko


-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von Lietz, Haiko
Gesendet: Montag, 10. März 2014 10:34
An: r-help@r-project.org
Betreff: [R] Graph densification in large networks

Hi all,

I have dynamic large 2-mode networks (1st mode ~50k nodes, 2nd mode ~500k 
nodes, timepoints ~100).

I want to identify the number of new nodes and new edges per timepoint in 
folded 1-mode networks.

In other words, I want to do measure graph densification as proposed by Leskovec et al. 
(http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.262.3092rep=rep1type=pdf)

What package should I use?

Best wishes

Haiko


Haiko Lietz
GESIS - Leibniz Institute for the Social Sciences
Department of Computational Social Science
Unter Sachsenhausen 6-8, D-50667 Köln
Tel: + 49 (0) 221 / 476 94 -223
eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org
Web: http://www.gesis.orghttp://www.gesis.org/


[[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] R Help

2014-03-10 Thread William Dunlap
 I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
 happens

Does nothing happens mean that R does not even print  , prompting you
to enter more input?  

Did you get such a prompt before typing setwd(...)?

What does typing
   5:2
cause R to do?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Jon Nash
 Sent: Monday, March 10, 2014 1:59 AM
 To: r-help@r-project.org
 Subject: [R] R Help
 
 I have just installed R 3.0.3 on Windows 7.
 
 I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
 happens, Ive tried manuals, forums etc ...
 
 An ex-student needs help using this program.  I spent 7 years as an IT
 consultant before becoming a maths teacher so Im better than average with
 IT and I cant get it to do anything at all.  What's up?  Any help greatly
 appreciated.
 
 Jon
 
   [[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] 3.1.0 on April 10

2014-03-10 Thread Peter Dalgaard
We intend to release R 3.1.0 on April 10. Prerelease versions will appear 
starting March 13 (for the source version, binaries may come a little later). 
See developer.r-project.org for details.

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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

2014-03-10 Thread Jenny Williams
Hi all,

I am running Biomod with Albers Equal Area Conic Projection for Africa.
Within Biomod all seems to work:
I can generate a plot with the raster data and the presence and absence points 
plotted on top.

However, when I go to export this to a *.csv file and create a shapefile from 
the point data in ArcMap, the randomly generated absence point data no longer 
overlies the continent in the correct location. With a very obvious shift 
(north-west) over Madagascar
The original presence points are in the correct location, but the values for 
the raster data extracted per point are also incorrect.

It seems that at some point the projection is not recognised, but I can't work 
out which part of the process seems to fail.

The projection details for the raster layer were specified through the 
ArcCatalog projection chooser. If this projection is not supported, what 
projection is everything getting pushed to?

Thanks for any help or suggestions in the right direction.


Jenny



The Royal Botanic Gardens, Kew is a non-departmental public body with exempt 
charitable status, whose principal place of business is at Royal Botanic 
Gardens, Kew, Richmond, Surrey TW9 3AB, United Kingdom.

The information contained in this email and any attachments is intended solely 
for the addressee(s) and may contain confidential or legally privileged 
information. If you have received this message in error, please return it 
immediately and permanently delete it. Do not use, copy or disclose the 
information contained in this email or in any attachment.

Any views expressed in this email do not necessarily reflect the opinions of 
RBG Kew.

Any files attached to this email have been inspected with virus detection 
software by RBG Kew before transmission, however you should carry out your own 
virus checks before opening any attachments. RBG Kew accepts no liability for 
any loss or damage which may be caused by software viruses.

[[alternative HTML version deleted]]

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


Re: [R] R Help

2014-03-10 Thread William Dunlap
You probably want to read the Introduction to R that comes with R
(menu: HelpManuals (in PDF)Introduction to R).

If you have an function, f, and you type just 'f', then R prints the function,
just as it does for any other object.
   z - function(x)
  + {
  + if (missing(x)) missing x else x + 100
  + }
   z
  function (x)
  {
  if (missing(x)) missing x else x + 100
  }
If you want to evaluate a function you must supply the arguments in
parentheses (even if there are no arguments you need the parentheses).
   z(10:12)
  [1] 110 111 112
   z()
  [1] missing x

Bill Dunlap
TIBCO Software
wdunlap tibco.com

From: Jon Nash [mailto:jon.n...@hvhs.school.nz]
Sent: Monday, March 10, 2014 11:14 AM
To: William Dunlap
Subject: Re: [R] R Help

Hi Bill,
I start with a  prompt
I type the command in the syntax that appears to be correct
I immediately get a  prompt back
I type getwd and get no indication of any directory at all just the following:
 getwd
function ()
.Internal(getwd())
bytecode: 0x0cb0df80
environment: namespace:base

Jon

On 11 March 2014 03:42, William Dunlap 
wdun...@tibco.commailto:wdun...@tibco.com wrote:
 I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
 happens
Does nothing happens mean that R does not even print  , prompting you
to enter more input?

Did you get such a prompt before typing setwd(...)?

What does typing
   5:2
cause R to do?

Bill Dunlap
TIBCO Software
wdunlap tibco.comhttp://tibco.com


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Jon Nash
 Sent: Monday, March 10, 2014 1:59 AM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] R Help

 I have just installed R 3.0.3 on Windows 7.

 I open up the GUI and type setwd(c:/users/jon) and press return. Nothing
 happens, Ive tried manuals, forums etc ...

 An ex-student needs help using this program.  I spent 7 years as an IT
 consultant before becoming a maths teacher so Im better than average with
 IT and I cant get it to do anything at all.  What's up?  Any help greatly
 appreciated.

 Jon

   [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] strucchange w dummy variables

2014-03-10 Thread Geoffrey Smith
Hello, I am having trouble with the output from the strucchange package for
a dummy variable regression.  Why do I still get an intercept term in the
output of lm03, below?

library(lmtest)
library(strucchange)

data(GermanM1)

#regular dummy regression with intercept
lm01 - lm(m ~ as.factor(season), data=GermanM1)
coeftest(lm01)

#regular dummy regression without intercept
lm02 - lm(m ~ as.factor(season) - 01, data=GermanM1)
coeftest(lm02)

#segmented regression for which I would like no intercept, yet the output
includes an intercept, why?
lm03 - lm(m ~ breakfactor(breakpoints(m ~ as.factor(season) - 01,
data=GermanM1)) / as.factor(season) - 01, data=GermanM1)
coeftest(lm03)

Thank you.

[[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] strucchange w dummy variables

2014-03-10 Thread Achim Zeileis

On Mon, 10 Mar 2014, Geoffrey Smith wrote:


Hello, I am having trouble with the output from the strucchange package for
a dummy variable regression.  Why do I still get an intercept term in the
output of lm03, below?

library(lmtest)
library(strucchange)

data(GermanM1)

#regular dummy regression with intercept
lm01 - lm(m ~ as.factor(season), data=GermanM1)
coeftest(lm01)

#regular dummy regression without intercept
lm02 - lm(m ~ as.factor(season) - 01, data=GermanM1)
coeftest(lm02)

#segmented regression for which I would like no intercept, yet the output
includes an intercept, why?
lm03 - lm(m ~ breakfactor(breakpoints(m ~ as.factor(season) - 01,
data=GermanM1)) / as.factor(season) - 01, data=GermanM1)
coeftest(lm03)


This has nothing to do with strucchange. In general, regressions of type y 
~ f1/f2 behave like this. In y ~ f1/f2 you get the treatment contrasts of 
both f1 and f2. If you do y ~ f1/f2 - 1 then no treatment contrasts are 
applied for f1 but still for f2.


But strucchange provides dedicated tools to do what you want to do. You 
can simply use the coef() and coeftest() methods for breakpoints 
objects:


bp - breakpoints(m ~ season - 1, data = GermanM1)
coef(bp)
coeftest(bp)

which should be what you are looking for.


Thank you.

[[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] Shortest connected path in a matrix

2014-03-10 Thread MacQueen, Don
This might be done using GIS tools, where finding shortest paths between
locations is a common task. But I can't help with details.

-Don

-- 
Don MacQueen

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





On 3/5/14 9:44 AM, McCloskey, Bryan bmcclos...@usgs.gov wrote:

Here is some example data (hopefully the monospace formatting is
preserved):

a   b   c   d   e
-   -   -   -   -
1 | F | T | F | T | F |
-   -   -   -   -
2 | T | F | T | F | T |
-   -   -   -   -
3 | T | T | F | F | F |
-   -   -   -   -
4 | F | T | F | T | F |
-   -   -   -   -
5 | F | T | F | F | T |
-   -   -   -   -

So, for cell b1, the shortest possible path to a true value in row 5 is
b1-a2-a3-b4-b5 (distance: sqrt(2) + 1 + sqrt(2) + 1).

* Shortest paths are not necessarily unique, but I just need to find the
length.

* If it's computationally hard to guarantee the absolute shortest path, I
can probably live with nearly shortest paths.

* Paths can backtrack, so the shortest path from cell e2 to row 4 is
e2-d1-c2-b3-b4-b5.

I need to calculate the shortest path for all true cells to all rows
further down the matrix. I'm afraid I'm going to have to write some sort
of
recursive path-tracing algorithm, but I'm hoping there's a package already
in existence that accomplishes this already...

-bryan

On Tue, Mar 4, 2014 at 1:13 PM, McCloskey, Bryan
bmcclos...@usgs.govwrote:

 I have a binary rectangular T/F matrix; I need to be able to calculate
the
 shortest path (i.e., Pythagorean distance) between a populated cell in
row
 j and any populated cell in some row j+n.

 For instance, if I have a chessboard with random black/white square
 colors, I need the shortest distance (linear distance, not number of
steps)
 for a king to get from a specified black space on the first row, to
_any_
 black space in a specified further row, traveling only on black spaces.

 Any idea? Thanks,

 -bryan


   [[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] Raster projection shift Biomod

2014-03-10 Thread MacQueen, Don
Probably better to ask on r-sig-geo.

Wouldn't it make more sense to export in a raster format, rather than csv?

-Don

-- 
Don MacQueen

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





On 3/10/14 10:24 AM, Jenny Williams jenny.willi...@kew.org wrote:

Hi all,

I am running Biomod with Albers Equal Area Conic Projection for Africa.
Within Biomod all seems to work:
I can generate a plot with the raster data and the presence and absence
points plotted on top.

However, when I go to export this to a *.csv file and create a shapefile
from the point data in ArcMap, the randomly generated absence point data
no longer overlies the continent in the correct location. With a very
obvious shift (north-west) over Madagascar
The original presence points are in the correct location, but the values
for the raster data extracted per point are also incorrect.

It seems that at some point the projection is not recognised, but I can't
work out which part of the process seems to fail.

The projection details for the raster layer were specified through the
ArcCatalog projection chooser. If this projection is not supported, what
projection is everything getting pushed to?

Thanks for any help or suggestions in the right direction.


Jenny



The Royal Botanic Gardens, Kew is a non-departmental public body with
exempt charitable status, whose principal place of business is at Royal
Botanic Gardens, Kew, Richmond, Surrey TW9 3AB, United Kingdom.

The information contained in this email and any attachments is intended
solely for the addressee(s) and may contain confidential or legally
privileged information. If you have received this message in error,
please return it immediately and permanently delete it. Do not use, copy
or disclose the information contained in this email or in any attachment.

Any views expressed in this email do not necessarily reflect the opinions
of RBG Kew.

Any files attached to this email have been inspected with virus detection
software by RBG Kew before transmission, however you should carry out
your own virus checks before opening any attachments. RBG Kew accepts no
liability for any loss or damage which may be caused by software viruses.

   [[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] Change of sign with division by zero, i.e. -1/0 = Inf ??

2014-03-10 Thread Cesar Caballero
Hi R-users,

I am facing a strange behaviour that changes the sign of Inf with a division by 
zero.

In my script, I have defined the following 3 variables and the elementwise 
division:

 lambda_k[gamma_lambda]  # numeric vector
[1] -1  0
 del_lambda[gamma_lambda] # numeric vector
[1]  0 -1
 gamma_lambda  # integer vector with the indexes of the elements in lambda_k  
 del_lambda
[1] 74 11
 lambda_k[gamma_lambda] / del_lambda[gamma_lambda]
[1] Inf   0

The result is surprising instead of -Inf 0 which I would expect because the 
elementwise division of the elements with index 74 is -1/0.


Surprisingly, if I try to do the division with just newly defined numeric 
vectors with the same values, I obtain the correct result, i.e.
 c(-1,0) / c(0,-1)
[1] -Inf0 


How can this be explained? Any input would be really welcomed.

For your information, I'm using R version 3.0.2 (2013-09-25) and Rstudio 
Version 0.98.501 on Platform: x86_64-apple-darwin10.8.0 (64-bit).


Thanks very much for your help,

Cesar

--
Cesar Caballero
www.bcbl.eu 

Legal disclaimer/Aviso legal/Lege-oharra: www.bcbl.eu/legal-disclaimer

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

2014-03-10 Thread Mckinstry, Craig
I have been trying to process a data.frame (tr) on a grouping factor (Rmbr) 
using diff
to find differences between srv_dt (a date) by Rmbr and keep getting the 
following error message

 tmp - by(tr,tr$Rmbr, diff, tr$srv_dt, lag=1, difference=1)
Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] :
  non-numeric argument to binary operator
# the only two arguments I supply are both numeric
 mode(tr$srv_dt)
[1] numeric
 mode(tr$Rmbr)
[1] numeric


IMPORTANT NOTICE: This communication, including any attachment, contains 
information that may be confidential or privileged, and is intended solely for 
the entity or individual to whom it is addressed.  If you are not the intended 
recipient, you should delete this message and are hereby notified that any 
disclosure, copying, or distribution of this message is strictly prohibited.  
Nothing in this email, including any attachment, is intended to be a legally 
binding signature.

[[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] cum sums

2014-03-10 Thread David Winsemius
Df $cumval - ave(Df$val, Df$val, cumsum)
Df[-3]

-- 
David

 On Mar 10, 2014, at 1:57 AM, Philip A. Viton vito...@osu.edu wrote:
 
 
 Suppose I have a dataframe beginning:
 
 id  yr   val
 a  1950   1
 b  1950   10
 a  1951   2
 
 I'm trying to produce a table of cumulative sums
 of val, disaggregated by id and then yr, so the result
 should begin
 
 id yr   cumval
 a  1950  1
 a  1951  3
 b  1950  10
 
 I've been trying to do this using aggregate
 and passing the function cumsum, but I can't get
 it to work. Can someone tell me how to do this?
 Thanks!
 
 
 
 Philip A. Viton
 City Planning, Ohio State University
 275 West Woodruff Avenue, Columbus OH 43210
 vito...@osu.edu
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Building R for better performance

2014-03-10 Thread Anspach, Jonathan P
CE,

Sorry for the delay.  I haven't installed any additional packages, so I don't 
know the answer to your question.  Let me look into it and get back to you.

Regards,
Jonathan Anspach
Sr. Software Engineer
Intel Corp.
jonathan.p.ansp...@intel.com
713-751-9460


-Original Message-
From: ce [mailto:zadi...@excite.com] 
Sent: Wednesday, March 05, 2014 8:54 PM
To: r-help@r-project.org; Anspach, Jonathan P
Subject: Re: [R] Building R for better performance


Hi Jonathan,

I think most people would be interested in such a tool, because main complaint 
of R is its slowness for some operations and big data.
Even thought the intel software is paying , I could install it free since I am 
not selling any software and work for non-profit. 
I compiled successfully on my opensuse.. My question is : after make install , 
do I need to give special options to install.packages or they will be complied 
with icc automatically ?

Regards
CE


-Original Message-
From: Anspach, Jonathan P [jonathan.p.ansp...@intel.com]
Date: 03/05/2014 12:28 AM
To: r-help@r-project.org r-help@r-project.org
Subject: [R] Building R for better performance

Greetings,

I'm a software engineer with Intel.  Recently I've been investigating R 
performance on Intel Xeon and Xeon Phi processors and RH Linux.  I've also 
compared the performance of R built with the Intel compilers and Intel Math 
Kernel Library to a default build (no config options) that uses the GNU 
compilers.  To my dismay, I've found that the GNU build always runs on a single 
CPU core, even during matrix operations.  The Intel build runs matrix 
operations on multiple cores, so it is much faster on those operations.  
Running the benchmark-2.5 on a 24 core Xeon system, the Intel build is 13x 
faster than the GNU build (21 seconds vs 275 seconds).  Unfortunately, this 
advantage is not documented anywhere that I can see.

Building with the Intel tools is very easy.  Assuming the tools are installed 
in /opt/intel/composerxe, the process is simply (in bash shell):

$ . /opt/intel/composerxe/bin/compilervars.sh intel64 $ ./configure 
--with-blas=-L/opt/intel/composerxe/mkl/lib/intel64 -lmkl_intel_lp64 
-lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm --with-lapack CC=icc 
CFLAGS=-O2 CXX=icpc CXXFLAGS=-O2 F77=ifort FFLAGS=-O2 FC=ifort FCFLAGS=-O2 $ 
make $ make check

My questions are:
1) Do most system admins and/or R installers know about this performance 
difference, and use the Intel tools to build R?
2) Can we add information on the advantage of building with the Intel tools, 
and how to do it, to the installation instructions and FAQ?

I can post my data if anyone is interested.

Thanks,
Jonathan Anspach
Sr. Software Engineer
Intel Corp.
jonathan.p.ansp...@intel.com
713-751-9460

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] two maps with different color legends in spplot

2014-03-10 Thread Gianluca Filippa
Hi all,
I am using spplot to plot two maps in the same device. In my
case, I have a map of a certain variable and the same map of the standard
deviation of the same variable. The range of the second is much smaller
than the range of the first so my wish is to plot both but to have them on
different scales for the color legend (hence, to have two separated
legends). Is it
possible?

I have worked out a way to do that, which passes through stretching the
second variable to the range of the first, and then work hardly on the key
list  from within the trellis object structure.
I was wondering if there is a more straightforward way.

Thanks,

Gianluca

-- 
Gianluca Filippa
PhD
ARPA-VdA
Skype: gianluca.filippa

[[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] Subsetting between two values (into a range)????

2014-03-10 Thread arun
Hi,
If 'dat' is the dataset:
Try

subset(dat, Start  MapInfo  End  MapInfo)

A.K.


Dear All, 

I want to subset a column (MapInfo in the attached photo) in csv
 file if its values be ranged between values in two other columns (Start
 and End in the attached photo) using R 3.0.1. Thank you in advance for 
all nice guides. 

M.H. Banabazi

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


Re: [R] Change of sign with division by zero, i.e. -1/0 = Inf ??

2014-03-10 Thread Sarah Goslee
Hi,

Without a reproducible example (providing data with dput(), please)
it's hard to say for certain, but my suspicion is that this is a R FAQ
7.31 issue.

Sarah

On Mon, Mar 10, 2014 at 11:26 AM, Cesar Caballero c.caball...@bcbl.eu wrote:
 Hi R-users,

 I am facing a strange behaviour that changes the sign of Inf with a division 
 by zero.

 In my script, I have defined the following 3 variables and the elementwise 
 division:

 lambda_k[gamma_lambda]  # numeric vector
 [1] -1  0
 del_lambda[gamma_lambda] # numeric vector
 [1]  0 -1
 gamma_lambda  # integer vector with the indexes of the elements in lambda_k 
  del_lambda
 [1] 74 11
 lambda_k[gamma_lambda] / del_lambda[gamma_lambda]
 [1] Inf   0

 The result is surprising instead of -Inf 0 which I would expect because the 
 elementwise division of the elements with index 74 is -1/0.


 Surprisingly, if I try to do the division with just newly defined numeric 
 vectors with the same values, I obtain the correct result, i.e.
 c(-1,0) / c(0,-1)
 [1] -Inf0


 How can this be explained? Any input would be really welcomed.

 For your information, I'm using R version 3.0.2 (2013-09-25) and Rstudio 
 Version 0.98.501 on Platform: x86_64-apple-darwin10.8.0 (64-bit).


 Thanks very much for your help,

 Cesar



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

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


Re: [R] Change of sign with division by zero, i.e. -1/0 = Inf ??

2014-03-10 Thread Berend Hasselman

On 10-03-2014, at 16:26, Cesar Caballero c.caball...@bcbl.eu wrote:

 Hi R-users,
 
 I am facing a strange behaviour that changes the sign of Inf with a division 
 by zero.
 
 In my script, I have defined the following 3 variables and the elementwise 
 division:
 
 lambda_k[gamma_lambda]  # numeric vector
 [1] -1  0
 del_lambda[gamma_lambda] # numeric vector
 [1]  0 -1
 gamma_lambda  # integer vector with the indexes of the elements in lambda_k 
  del_lambda
 [1] 74 11
 lambda_k[gamma_lambda] / del_lambda[gamma_lambda]
 [1] Inf   0
 
 The result is surprising instead of -Inf 0 which I would expect because the 
 elementwise division of the elements with index 74 is -1/0.
 
 
 Surprisingly, if I try to do the division with just newly defined numeric 
 vectors with the same values, I obtain the correct result, i.e.
 c(-1,0) / c(0,-1)
 [1] -Inf0 
 
 
 How can this be explained? Any input would be really welcomed.
 

Most likely the 0 you show for del_lambda is not exactly 0.
Look at this

 c(-0.000,-1)
[1]  0 -1

 c(-1,0) / c(-0.000,-1)
[1] Inf   0

Berend


 For your information, I'm using R version 3.0.2 (2013-09-25) and Rstudio 
 Version 0.98.501 on Platform: x86_64-apple-darwin10.8.0 (64-bit).
 
 
 Thanks very much for your help,
 
 Cesar
 
 --
 Cesar Caballero
 www.bcbl.eu 
 
 Legal disclaimer/Aviso legal/Lege-oharra: www.bcbl.eu/legal-disclaimer
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R Help

2014-03-10 Thread Rui Barradas

Hello,

It's better to keep this on the list, the odds of getting more and 
better answers are greater.
You need to type getwd() with the parenthesis and no arguments. It 
always returns something (the current wd).


Rui Barradas

Em 10-03-2014 18:00, Jon Nash escreveu:

Hi Rui,
Nothing of value is returned by getwd either.

Jon


On 11 March 2014 00:10, Rui Barradas ruipbarra...@sapo.pt
mailto:ruipbarra...@sapo.pt wrote:

Hello,

The function setwd returns the previous working directory invisibly
so nothing happens might mean that there is no apparent feedback.
You can see if it changed the wd with getwd().

Hope this helps,

Rui Barradas

Em 10-03-2014 10:58, Pascal Oettli escreveu:

Hello,

And what are you expecting the command setwd to do?

Regards,
Pascal

On Mon, Mar 10, 2014 at 5:59 PM, Jon Nash
jon.n...@hvhs.school.nz mailto:jon.n...@hvhs.school.nz wrote:

I have just installed R 3.0.3 on Windows 7.

I open up the GUI and type setwd(c:/users/jon) and press
return. Nothing
happens, Ive tried manuals, forums etc ...

An ex-student needs help using this program.  I spent 7
years as an IT
consultant before becoming a maths teacher so Im better than
average with
IT and I cant get it to do anything at all.  What's up?  Any
help greatly
appreciated.

Jon

  [[alternative HTML version deleted]]


R-help@r-project.org mailto:R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/__listinfo/r-help
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/__posting-guide.html
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] using diff function with by function

2014-03-10 Thread Rui Barradas

Hello,

Maybe you want

by(tr$srv_dt, tr$Rmbr, diff, lag=1, difference=1)


Can't you ?dput a data example?

dput(head(tr, 30))  # paste the output of this in a post


Hope this helps,

Rui Barradas

Em 10-03-2014 16:10, Mckinstry, Craig escreveu:

I have been trying to process a data.frame (tr) on a grouping factor (Rmbr) 
using diff
to find differences between srv_dt (a date) by Rmbr and keep getting the 
following error message


tmp - by(tr,tr$Rmbr, diff, tr$srv_dt, lag=1, difference=1)

Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] :
   non-numeric argument to binary operator
# the only two arguments I supply are both numeric

mode(tr$srv_dt)

[1] numeric

mode(tr$Rmbr)

[1] numeric


IMPORTANT NOTICE: This communication, including any attachment, contains 
information that may be confidential or privileged, and is intended solely for 
the entity or individual to whom it is addressed.  If you are not the intended 
recipient, you should delete this message and are hereby notified that any 
disclosure, copying, or distribution of this message is strictly prohibited.  
Nothing in this email, including any attachment, is intended to be a legally 
binding signature.

[[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] Change of sign with division by zero, i.e. -1/0 = Inf ??

2014-03-10 Thread William Dunlap
The double precision number system (in the IEEE 754 format) includes
two zeroes, one of each sign.  They are hard to tell apart, but their 
reciprocals
are Inf's of the appropriate sign and, in R 3.0.2, sprintf(%g,...) 
distinguishes them.

 z - c(0.0, -0.0)
 z
[1] 0 0
 z[1] == z[2]
[1] TRUE
 identical(z[1], z[2])
[1] TRUE
 
 1/z
[1]  Inf -Inf
 sprintf(%g, z)
[1] 0  -0 

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Cesar Caballero
 Sent: Monday, March 10, 2014 8:27 AM
 To: r-help@r-project.org
 Subject: [R] Change of sign with division by zero, i.e. -1/0 = Inf ??
 
 Hi R-users,
 
 I am facing a strange behaviour that changes the sign of Inf with a division 
 by zero.
 
 In my script, I have defined the following 3 variables and the elementwise 
 division:
 
  lambda_k[gamma_lambda]  # numeric vector
 [1] -1  0
  del_lambda[gamma_lambda] # numeric vector
 [1]  0 -1
  gamma_lambda  # integer vector with the indexes of the elements in lambda_k 
  
 del_lambda
 [1] 74 11
  lambda_k[gamma_lambda] / del_lambda[gamma_lambda]
 [1] Inf   0
 
 The result is surprising instead of -Inf 0 which I would expect because the 
 elementwise
 division of the elements with index 74 is -1/0.
 
 
 Surprisingly, if I try to do the division with just newly defined numeric 
 vectors with the
 same values, I obtain the correct result, i.e.
  c(-1,0) / c(0,-1)
 [1] -Inf0
 
 
 How can this be explained? Any input would be really welcomed.
 
 For your information, I'm using R version 3.0.2 (2013-09-25) and Rstudio 
 Version
 0.98.501 on Platform: x86_64-apple-darwin10.8.0 (64-bit).
 
 
 Thanks very much for your help,
 
 Cesar
 
 --
 Cesar Caballero
 www.bcbl.eu
 
 Legal disclaimer/Aviso legal/Lege-oharra: www.bcbl.eu/legal-disclaimer
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Subsetting between two values (into a range)????

2014-03-10 Thread Duncan Murdoch

On 14-03-10 10:47 AM, arun wrote:

Hi,
If 'dat' is the dataset:
Try

subset(dat, Start  MapInfo  End  MapInfo)


A bit of advice I think I read in The Elements of Programming Style: 
try to make complex conjunctions look like their mathematical 
equivalents, and they'll be easier to read.  The mathematical way to 
write the test above would be Start  MapInfo  End, so the programmatic 
way to write it should be


Start  MapInfo  MapInfo  End

This makes the character of the interval completely obvious.

Duncan Murdoch



A.K.


Dear All,

I want to subset a column (MapInfo in the attached photo) in csv
  file if its values be ranged between values in two other columns (Start
  and End in the attached photo) using R 3.0.1. Thank you in advance for
all nice guides.

M.H. Banabazi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Course: Beginner's Guide to MCMC, mixed models and GLMM with R

2014-03-10 Thread Highland Statistics Ltd

We would like to announce the following stats course:

Course: Introduction to MCMC, Linear mixed effects models and GLMM with R
Where: CIMA Research Foundation, Savona, Italy
URL flyer:   http://www.highstat.com/Courses/Flyer2014_05CIMA.pdf
Course website: http://www.highstat.com/statscourse.htm


Kind regards,

Alain


--
Dr. Alain F. Zuur

First author of:
1. Beginner's Guide to GAMM with R (2014).
2. Beginner's Guide to GLM and GLMM with R (2013).
3. Begginner's Guide to GAM with R (2012).
4. Zero Inflated Models and GLMM with R (2012).
5. A Beginner's Guide to R (2009).
6. Mixed effects models and extensions in ecology with R (2009).
7. Analysing Ecological Data (2007).

Highland Statistics Ltd.
9 St Clair Wynd
UK - AB41 6DZ Newburgh
Tel:   0044 1358 788177
Email: highs...@highstat.com
URL:   www.highstat.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] catering for rescaling

2014-03-10 Thread Jim Lemon

On 03/10/2014 10:34 PM, Geoffrey wrote:

My barplot has nicely left justified horizontal labels, the names of
people. Written using text() . I use par(user)[1] - OFFSET to get the
placed nicely.

Now of course if i manually rescale/zoom the plot the labels get redrawn
at the 'wrong' location, including off the left of the plot.

I assume this is because the x-position is based off the size of a unit
in the plot, which changes when i rescale.

Can i get some pointers on how to adjust for this?


Hi Geoffrey,
This is a common problem when labels of arbitrary length are added to 
the axis of a plot. The gantt.chart function in the plotrix package 
works out the maximum length of the labels to be displayed and adjusts 
the margins of the plot to suit. gantt.chart uses the axis function to 
display the labels, and but you want left justification, so using mtext 
makes it a bit easier. I tried changing the size of the example in 
staircase.plot, which uses mtext, and it seemed to work okay.


Jim

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


Re: [R] Data Frame to list?

2014-03-10 Thread Brian Diggs

On 3/7/2014 7:41 PM, Keith S Weintraub wrote:

Folks,

I have a data frame as follows:


foo-structure(list(name = c(A, B, C), num = c(3L, 2L, 1L)), .Names = 
c(name,

num), row.names = c(NA, -3L), class = data.frame)


str(foo)

'data.frame':   3 obs. of  2 variables:
  $ name: chr  A B C
  $ num : int  3 2 1


foo

   name num
1A   3
2B   2
3C   1

I want to convert this to a list like so:


oof-list(A = 3, B = 2, C = 1)


You can do it as a one-liner as well:

oof - setNames(as.list(foo$num), foo$name)


str(oof)

List of 3
  $ A: num 3
  $ B: num 2
  $ C: num 1


oof

$A
[1] 3

$B
[1] 2

$C
[1] 1

Any Suggestions?

Thanks,
KW

--




--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health  Science University

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


[R] plotting tripgrid on PBSmapping

2014-03-10 Thread Trevor Davies
Hello,

Sorry for the lack of a complete example but this is more of a class type
question.

I have a map of the coast that I generated through PBSmapping:

xlims - c(292,303.5)
ylims - c(41.5,49.5)
plotMap(worldLLhigh, xlim=xlims, ylim=ylims, col=grey(0.1),bg=grey(0.9),
xlab=, ylab=, las=1, tck=-0.015, axes=F)

I want to add an intensity grid from an object that I created through the
excellent 'trip' package (results in an sp class object
(SpatialGridDataFrame)) and this is where I'm having difficulty.  I know
maptools allows you to change formats from sp to PBSmapping but I can't
seem to identify how to do it for a SpatialGridDataFrame.

I get the SpatialGridDataFrame object via:

x2009.grid - makeGridTopology(data2009.sp, cells.dim = c(cell.x1,
cell.y1), xlim=xlims, ylim=ylims,buffer = 0, cellsize = NULL,adjust2longlat
= FALSE)
x2009.final - tripGrid(data2009.sp, grid = x2009.grid, method =
pixellate)

For most of these maps I usually just add the grid layer using the image
function but what I currently have worked out is quite messy and I think
prone to error for other applications.

Of course, I can plot the SpatialGridDataFrame object
via: spplot(x2009.final) which would be great but I can't figure out how to
add my coastline via the PBSmapping plotMap call.

Could someone please suggest a more direct approach?
Thank you.

[[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] Why does ar.ols manual caution against intercept=T, demean=F

2014-03-10 Thread Bauer, Michael
The manual for ar.ols {stats} cautions against fitting a model with intercept 
to a time series that is not demeaned. From the manual:

Some care is needed if intercept is true and demean is false. Only use this is 
the series are roughly centred on zero. Otherwise the computations may be 
inaccurate or fail entirely.

I was surprised by this warning. If a series is not centered on zero/not 
demeaned by ar.ols, I would typically include an intercept in my AR/VAR model. 
This takes care of fitting the unconditional mean.

Is this a typo? It would make sense to warn against fitting a model with 
intercept=F, demean=F for a series that is not centered around zero.

I frequently fit AR/VAR models with intercept and without demeaning, couldn't 
find any more information on this aspect of ar.ols, and therefore am asking my 
first question on R-help (after several years as a very happy R user.)

Thank you,
Michael
---
Michael D. Bauer
Economist, Research Department
Federal Reserve Bank of San Francisco
101 Market Street MS 1130
San Francisco, CA 94105
415.974.3299 (w)   415.471.9136 (c)
michael.ba...@sf.frb.org
http://www.frbsf.org/economic-research/economists/michael-bauer/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 know the what functions have used datasets in loaded packages.

2014-03-10 Thread Xing Zhao
Hi all,

Once you start your R program, there are example data sets available
within R along with loaded packages. Command data() will list all the
datasets in loaded packages.

Is there a method to know what R functions have used one of the
datasets to present the function's utility, maybe at least for the
basic R distribution.


Thanks,
Xing

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

2014-03-10 Thread Michael Sumner
Hi, this doesn't have much to do with tripGrid, since the object to
plot is just a SpatialGridDataFrame.

I don't use PBSmapping, so I haven't looked at that - perhaps there is
an add = TRUE option to plotMap (?), so perhaps you could do this:

image(x2009.final)
plotMap(..., add = TRUE)

Your main issue may be that you are using the Pacific view (0, 360)
longitudes rather than (-180,180).  I don't know how/if plotMap deals
with that,

Otherwise, I would use a different data set and just use the sp plot functions.

image(x2009.final)
library(maptools)
data(wrld_simpl)
plot(elide(wrld_simpl, shift = c(360, 0)), add = TRUE)

You need to elide it to shift it 360 in longitude since your range
is c(292,303.5)
The same will work with other polygon data in longlat read with
rgdal::readOGR or maptools::readShapePoly. To actually crop wrld_simpl
you can use [ with matches on the data attributes, or use
rgeos::gIntersection.

You also could modify your input data to be in the range -180,180, or
use a map projection before using the trip* functions.

I know there's a lot of options listed above, but it really does
depend on which aspects matter to you.

HTH



On Tue, Mar 11, 2014 at 10:09 AM, Trevor Davies davies.tre...@gmail.com wrote:
 Hello,

 Sorry for the lack of a complete example but this is more of a class type
 question.

 I have a map of the coast that I generated through PBSmapping:

 xlims - c(292,303.5)
 ylims - c(41.5,49.5)
 plotMap(worldLLhigh, xlim=xlims, ylim=ylims, col=grey(0.1),bg=grey(0.9),
 xlab=, ylab=, las=1, tck=-0.015, axes=F)

 I want to add an intensity grid from an object that I created through the
 excellent 'trip' package (results in an sp class object
 (SpatialGridDataFrame)) and this is where I'm having difficulty.  I know
 maptools allows you to change formats from sp to PBSmapping but I can't
 seem to identify how to do it for a SpatialGridDataFrame.

 I get the SpatialGridDataFrame object via:

 x2009.grid - makeGridTopology(data2009.sp, cells.dim = c(cell.x1,
 cell.y1), xlim=xlims, ylim=ylims,buffer = 0, cellsize = NULL,adjust2longlat
 = FALSE)
 x2009.final - tripGrid(data2009.sp, grid = x2009.grid, method =
 pixellate)

 For most of these maps I usually just add the grid layer using the image
 function but what I currently have worked out is quite messy and I think
 prone to error for other applications.

 Of course, I can plot the SpatialGridDataFrame object
 via: spplot(x2009.final) which would be great but I can't figure out how to
 add my coastline via the PBSmapping plotMap call.

 Could someone please suggest a more direct approach?
 Thank you.

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



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsum...@gmail.com

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


[R] Rare Association Rule Mining

2014-03-10 Thread Alexander Kruse

   Hello:

   I´m  searching  for  some  Example  R  Code  on  Rare Association Rule
   Mining/Infrequent Itemset Mining.

   Thanks in advance for any help.
   Alex
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ts instead of xts object

2014-03-10 Thread Bill
Hello. I have a dataframe that has a date column. The intervals between
dates vary. I want to convert this to a ts object. I was able to convert it
to an xts object but the package I want to analyse this data with (called
'changepoint') does not seem to want to deal with xts. In the example they
give they use the following:

data(discoveries)
dis.pelt=cpt.meanvar(discoveries,test.stat='Poisson',method='PELT')
plot(dis.pelt,cpt.width=3)
cpts.ts(dis.pelt)

and if I check:
str(discoveries)
 Time-Series [1:100] from 1860 to 1959: 5 3 0 2 0 3 2 3 6 1 ...

If I try with my data
str(testTSRad)
An 'xts' object on 2011-07-16 07:08:02/2013-09-20 01:25:48 containing:
  Data: num [1:501, 1] 76 77 79 86 79 79 85 86 89 88 ...
  Indexed by objects of class: [POSIXct,POSIXt] TZ:
  xts Attributes:
 NULL

where I used this:

testTSRad=xts(radSampPerRegion[[2]][
,2],order.by=as.POSIXct(radSampPerRegion[[2]][
,1]))

I get this:

testt=cpt.mean(testTSRad)
Error in single.mean.norm(data, penalty, pen.value, class, param.estimates)
:
  Data must have atleast 2 observations to fit a changepoint model.

My data is below. Is there a way to convert it to ts?

head(testTSRad)
[,1]
2011-07-16 07:08:02   76
2011-07-16 07:08:06   77
2011-07-16 07:08:12   79
2011-07-16 07:08:16   86
2011-07-16 07:08:22   79
2011-07-16 07:08:26   79

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