[R] R-3.0.2 on September 25

2013-08-21 Thread peter dalgaard
Just a quick note, mainly to warn off maintainers of the recommended packages, 
that we intend to release R-3.0.2 on Wednesday, September 25.

We'll be following the usual schedule from
http://developer.r-project.org/release-checklist.html

Notice in particular that new versions of recommended packages should be 
finalized 14 days before release.

For the R Core Team
Peter Dalgaard

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


Re: [R] Windows "The system cannot find the path specified" error when submitting R in batch mode

2013-08-21 Thread Tal Galili
Hello James,
Does this answer your question:
http://stackoverflow.com/questions/14956887/problems-executing-script-from-command-line-in-r-error-message-cannot-find-pat
?





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--



On Mon, Aug 19, 2013 at 10:06 PM, James Hackett
wrote:

> This is an R and operating system related question. I am not able to
> submit an R program to be executed in batch mode by Windows. I have
> confirmed the location of the R.exe file. I am following the directions I
> found in Quick-R, but neither of the following work from a DOS prompt ...
>
> D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS
> FM\biostat\programs\R\024-CL-01 - BRASS FM - Manuscript>"C:\Program
> Files\R\R-2.15.2\bin\R.exe" CMD BATCH "boxplotByMBDAAndCRP.R"
> The system cannot find the path specified.
>
> D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS
> FM\biostat\programs\R\024-CL-01 - BRASS FM - Manuscript>"C:\Program
> Files\R\R-2.15.2\bin\R.exe" CMD BATCH "D:\chip\Projects\Crescendo
> Bioscience\Studies\024-CL-01 - BRASS FM\biostat\programs\R\024-CL-01 -
> BRASS FM - Manuscript\boxplotByMBDAAndCRP.R"
> The system cannot find the path specified.
>
>
>
> Thank you for any help you can provide,
> Chip
>
> James "Chip" Hackett, Ph.D. | Statistical Consultant | Hackett &
> Associates, Inc. | c...@hackettassociates.net | 408.416.3747 (Office) |
> 805.509.0741 (Mobile)
>
> The material in this transmission may contain confidential information
> intended only for the  addressee. If you are not the addressee, any
> disclosure or use of this information by you is strictly prohibited. If you
> have received this transmission in error, please delete it, destroy all
> copies, and notify the sender immediately by reply or by calling
> 1-408-416-3747.
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] italic(mu)

2013-08-21 Thread David Winsemius

On Aug 20, 2013, at 3:04 PM, David Winsemius wrote:

> 
> On Aug 20, 2013, at 12:06 PM, Beaulieu, Jake wrote:
> 
>> Hi,
>> 
>> I would like to include the greek letter mu, in italics, in an axis title.  
>> The following gets close, but the mu isn't italicized.
>> 
>> x <- 1:10
>> y <- 1:10
>> plot(y ~x, ylab = expression(paste('Greek ', italic(mu
>> 
> 
> The Symbol font does not accept the italic() function. I'm pretty sure this 
> is mentioned in the help page:
> 
> ?plotmath
> 
> You may need to use mtext with a font that does have an italic mu.

Also this from the Archives:

https://stat.ethz.ch/pipermail/r-help/2011-June/281506.html

-- 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-21 Thread Tal Galili
Dear Uwe,
My apologies - my original code had mode="wb", which also *does not* work
and produce the errors I've mentioned in the previous e-mail.

The code I pasted had mode ="w", since that is one of the versions I've
played with (which also does not work).

 With regards,
Tal





On Wed, Aug 21, 2013 at 11:45 PM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

> Uwe





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


[R] cross-sectional analysis of a financial time series

2013-08-21 Thread Brijesh Gulati
Hi:

I have a financial series data. For instance, one can take YHOO from the
quantmod package.

>library("quantmod")

>getSymbols("YHOO")

 

As you can see this series has date along with close prices. I want to do a
cross-sectional analysis of the time series and want to see if there are any
seasonal patterns in this. For instance, I want to see how the on average
close price behaves a few days prior to last business day of the month. So,
I want to see a cross sectional time series of average prices for the past
12-months. In other words, the resulting dataset would give me a series such
as following 

Days_Prior_To_Month_End Avg_Price

10   25

9  24.3

8  22

7  21

6  23

5  24

4  22.2

3  24.8

2  24.9

1  25

0  26

 

In the above series, "0"would indicate the last day of the month. And the 26
would correspond to average price on the last day of the month for the past
12-month.

 

Some issues with this kind of series:

1)  Number of business day in a month is not fixed. Some months have 22
working day and others may have 23 or 21. So, the weekend data is not
available. 

2)  Normally, one is interested in returns behavior, but for the sake of
simplicity I used the example of just seeing average. Once I know the
methodology, I can extend it to the returns.  

Any help would be greatly appreciated. 

 


[[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 will not find certain entries in an array created by an interval

2013-08-21 Thread arun
Hi,
Please check:
?FAQ 7.31
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

 intervalloweredge[3]-3.845
#[1] -4.440892e-16


which(as.character(intervalloweredge)=="3.845")
#[1] 3
which(as.character(intervalloweredge)=="3.86")
#[1] 4

#or
which(round(intervalloweredge,3)==3.845)
#[1] 3


A.K.

Greetings 

I am trying to create an interval list as follows: 

interval <- 0.015 
intervalloweredge <- 3.815+interval*seq(0,5, by=1) 
intervalupperedge <- intervalloweredge + interval 

Here is the output when I type intervalloweredge: 

[1] 3.815 3.830 3.845 3.860 3.875 3.890 

All seems well... 

but then R won't find intervalloweredge[3]: 

which(intervalloweredge==3.815) 
[1] 1 
> which(intervalloweredge==3.83) 
[1] 2 
> which(intervalloweredge==3.845) 
integer(0) 
> which(intervalloweredge==3.86) 
[1] 4 
> which(intervalloweredge==3.875) 
[1] 5 
> which(intervalloweredge==3.89) 
[1] 6 


Likewise 
Here is the output when I type intervalupperedge: 

[1] 3.830 3.845 3.860 3.875 3.890 3.905 

but then R won't find intervalupperedge[6]: 

> which(intervalupperedge==3.83) 
[1] 1 
> which(intervalupperedge==3.845) 
[1] 2 
> which(intervalupperedge==3.86) 
[1] 3 
> which(intervalupperedge==3.875) 
[1] 4 
> which(intervalupperedge==3.89) 
[1] 5 
> which(intervalupperedge==3.905) 
integer(0) 



Instead, I have to define the intervals by hand, like this: 

alt <- 0.015 
altlower <- c(3.815, 3.83, 3.845, 3.86, 3.875, 3.89) 
altupper <- c(3.83, 3.845, 3.86, 3.875, 3.89, 3.905) 

Then R will find each entry in both arrays fine. 


What's going on? Why can't I use the "interval" variables in the way that I've 
set them up? 




Also, 

I received a message saying that I needed to subscribe, before my post would be 
accepted. 

I tried clicking on the Subscribe button and was taken to a page where I was 
asked to check my email for a subscription confirm. 

But I never received the email. 

Did my post get accepted? How do I know? Because I have posts in other threads 
from months back that have yet to be accepted.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replacing data values from ref table

2013-08-21 Thread arun
Hi,
You may try ?merge() or ?join() from library(plyr)
dat1<- read.table(text="
Col1 Col2
red 1.23
blu 4.56
",sep="",header=TRUE,stringsAsFactors=FALSE) 
dat2<- read.table(text="
Col1 Col2
red SQU
blu CIR
",sep="",header=TRUE,stringsAsFactors=FALSE) 


library(plyr)
res1<-join(dat2,dat1,by="Col1")[,-1]
 colnames(res1)<- colnames(dat1)
 res1
#  Col1 Col2
#1  SQU 1.23
#2  CIR 4.56


#or
res2<-merge(dat2,dat1,by="Col1")[,-1]
 colnames(res2)<-colnames(dat1)
 res2
#  Col1 Col2
#1  CIR 4.56
#2  SQU 1.23


A.K.



Hi R wizards, 

Thanks in advance for your patience. 
I can't figure out how to replace values in one column with their 
equivalent values that are stored in another table. Any ideas? 

Data table 
Col1 Col 2 
red 1.23 
blu 4.56 

Reference table 
Col1 Col2 
red SQU 
blu CIR 

Desired Output 
Col1 Col2 
SQU 1.23 
CIR 4.56

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Lag selection in Unit Root Test

2013-08-21 Thread jpm miao
Hi,

   I attempt to conduct the unit root test with the two functions

unitrootTest(x, lags = 1, type = c("nc", "c", "ct"), title = NULL,
description = NULL)

adfTest(x, lags = 1, type = c("nc", "c", "ct"), title = NULL,
description = NULL)

According to the document,
"lagsis the maximum number of lags used for error term correction."

   However, it seems that lags is the number of lags used, NOT the
MAXIMUM number of lags used. For example, if I write lags =12, I
expect a lag between 1 and 12, but it always gives lags =12. Could the
function choose the lags from a range (say, 1-12) based on information
criteria (AIC or BIC)?

Thanks,

Miao

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Interpreting the result of 'cutree' from hclust/heatmap.2

2013-08-21 Thread Gundala Viswanath
I have the following code that perform hiearchical clustering and plot
them in heatmap.


__
library(gplots)
set.seed(538)
# generate data
y <- matrix(rnorm(50), 10, 5, dimnames=list(paste("g", 1:10, sep=""),
paste("t", 1:5, sep="")))
# the actual data is much larger that the above

# perform hiearchical clustering and plot heatmap
test <- heatmap.2(y)
__

What I want to do is to print the cluster member from each hierarchy
of in the plot. I'm not sure what's the good way to do it.

I tried this:

cutree(as.hclust(test$rowDendrogram), 1:dim(y)[1])

But having problem in interpreting the result.
What's the meaning of each value in the matrix?
For example g9-9=8 . What does 8 mean here?


1 2 3 4 5 6 7 8 9 10
g1  1 1 1 1 1 1 1 1 1  1
g2  1 2 2 2 2 2 2 2 2  2
g3  1 2 2 3 3 3 3 3 3  3
g4  1 2 2 2 2 2 2 2 2  4
g5  1 1 1 1 1 1 1 4 4  5
g6  1 2 3 4 4 4 4 5 5  6
g7  1 2 2 2 2 5 5 6 6  7
g8  1 2 3 4 5 6 6 7 7  8
g9  1 2 3 4 4 4 7 8 8  9
g10 1 2 3 4 5 6 6 7 9 10



Your expert advice will be greatly appreciated.

- G.V.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 code y~x/(x+a) in lm() function

2013-08-21 Thread Ben Bolker
On 13-08-21 05:17 PM, Rolf Turner wrote:
> 
> 
> Thott about this a bit more and have now decided that I don't understand
> after all.
> 
> Doesn't
> 
> glm(1/y~x,family=gaussian(link="inverse"))
> 
> fit the model
> 
> 1/y ~ N(1/(a+bx), sigma^2)
> 
> whereas what the OP wanted was
> 
> y ~ N(x/(a+x),sigma^2)  ???

  I goofed slightly.

y ~ 1/x with inverse link gives

1/y = a + b*(1/x)
y = 1/(a+b*(1/x))
  = x/(a*x+b)

  Hmmm. Is there an offset trick we can use?

  y = x/(a+x)
1/y = (a+x)/x
1/y = (a/x) + 1
1/y = a*(1/x) + 1

  So I *think* we want

glm(y~1/x+0+offset(1),family=gaussian(link="inverse"))

  I'm forwarding this back to r-help.



> 
> I can't see how these models can be equivalent.  What am I missing?
> 
> cheers,
> 
> Rolf
> 
> 
> 
> On 22/08/13 03:49, Ben Bolker wrote:
>> Rolf Turner  xtra.co.nz> writes:
>>
>>> On 21/08/13 11:23, Ye Lin wrote:
 T
 hanks for your insights Rolf! The model I want to fit is y=x/a+x with
 no intercept, so I transformed it to 1/y=1+a/x as they are the same.
>>> For crying out loud, they are ***NOT*** the same.  The equations y =
>>> x/(a+x) and
>>> 1/y = 1 + a/x are indeed algebraically identical, but if an "error" or
>>> "noise" term is added
>>> to each then then the nature of the error term is vastly different. It
>>> is the error or
>>> noise term that is of central concern in a statistical context.
>>>
>>>   cheers,
>>>
>>>   Rolf
>>
>>For what it's worth this model can also be fitted (without messing
>> up the error structure) via
>>
>>   glm(1/y~x,family=gaussian(link="inverse"))
>>
>> Although you may not get the parameters in exactly the form you
>> want.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] X axis label as months

2013-08-21 Thread Jim Lemon

On 08/22/2013 09:04 AM, Prof J C Nash (U30A) wrote:

Thanks. The staxlab works with the plot generated by

plot(tt, data,)

but not with

plot(tsdata, ...)

i.e., it seems to be the tsplot that somehow changes something and the
axis commands have no effect.

I probably should have pointed out that my main concern is that I'm not
getting any error msg. Just no axis label. And it seems I need to make
sure the labels vector is the same length as I need -- no recycling.

JN


Hi JN,
This is an interesting problem for me as it affords an opportunity to 
learn about time series. I can hack a quick solution like this:


plotlim<-par("usr")
xlim<-c(plotlim[1]+(plotlim[2]-plotlim[1])*0.04,plotlim[2]-
 (plotlim[2]-plotlim[1])*0.04)
xlim
[1] 2011.007 2013.243
nint<-length(yt)-1
labpos<-cumsum(c(xlim[1],rep(diff(xlim)/nint,nint)))
staxlab(1, at=labpos, label=months)

This works, but it is not a very elegant way to get the x positions of a 
time series. It does allow one to calculate the x positions of any 
equally spaced series of plotted values (using par("xaxt") to work out 
the space at the edges).


The "ts" function seems to infer that a "start=c(2011,1),frequency=12" 
time series refers to years and months, but assigns the x positions as 
decimal years. I cannot find a way to extract the x positions from the 
time series and could only offer a really ugly function that tried to 
guess the intervals using the "start" and "frequency" arguments and then 
calculated the x positions from these. However, I can see that this 
would be a useful thing to have, so I'll think about it.


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] Narrowing values collected from .txt file

2013-08-21 Thread Morway, Eric
Hello John,

I tried the dput function a couple of different ways, with some different
arguments set, and it dumped the following (or less):

"structure(3L, class = c("textConnection", "connection"), conn_id =
)"

Concerned that I miscopied some of the reproducible example to my original
post, I just tried it again, and everything worked fine.

If, as you say, my email was somehow sent out as HTML, a good alternative
is to see the post on the Nabble forum here:

http://r.789695.n4.nabble.com/Narrowing-values-collected-from-txt-file-td4674220.html

Here again, I copied and pasted my reproducible example into RGui and it
worked great.  So, I'm not sure what the issue is?  Are you able to grab
the reproducible example from Nabble?  If so, I'm still stuck on the
problem I laid out in my original post.  -Eric

[[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.oo in R-3.0.1

2013-08-21 Thread Anamika Chaudhuri
Hi All:

I am getting some warnings trying to run the following code and I am not
sure what they mean.
> set.seed(111)
> k<-63
> n<-60
> x<-NULL
> p<-rbeta(k,3,3)# so that the mean nausea rate is alpha/(alpha+beta)
> #min<-10
> #max<-60
> #n<-as.integer(runif(k,min,max))
> for(i in 1:k)
+ x<-cbind(x,rbinom(300,n,p[i]))
> x<-t(x)
> rate<-t(t(x)/n)
> se_rate<-sqrt(rate*(1-rate)/n)
>
>
>
> # Exact Confidence Interval
>
> l_cl_exact<-qbeta(.025,x,n-x+1)
There were 50 or more warnings (use warnings() to see the first 50)
> u_cl_exact<-qbeta(.975,x+1,n-x)
>
> for (i in 1:63){
+
+ for (j in 1:300)
+ {
+
+ if (x[i,j]==0)
+ {
+ l_cl_exact[i,j]<-0
+ u_cl_exact[i,j]<-u_cl_exact[i,j]
+ }
+ else if (x[i,j]==n[i])
+ {
+ l_cl_exact[i,j]<-l_cl_exact[i,j]
+ u_cl_exact[i,j]<-1
+ }
+ else
+ l_cl_exact[i,j]<-l_cl_exact[i,j]
+ u_cl_exact[i,j]<-u_cl_exact[i,j]
+
+ #print(c(i,j))
+
+ }
+ }
Error in if (x[i, j] == n[i]) { : missing value where TRUE/FALSE needed
>
>
>
>
>
>
> rate_t<-t(rate)
>
> l_cl_exact_t<-t(l_cl_exact)
> u_cl_exact_t<-t(u_cl_exact)
>
> coverage<-matrix(data=0,nrow=300,ncol=63)
> int_width<-matrix(data=0,nrow=300,ncol=63)
> sqr_err<-matrix(data=0,nrow=300,ncol=63)
> abs_bias<-matrix(data=0,nrow=300,ncol=63)
>
> for (i in 1:300){
+
+ for (j in 1:63)
+ {
+
+
+ if ((p[j]>l_cl_exact_t[i,j]) & (p[j] avg_cov<-apply(coverage,1,mean)
> cov_prob<-mean(avg_cov)
> 1-cov_prob# Non-Coverage Probability
[1] 0.03433862
>
> avg_int<-apply(int_width,1,mean)
> mean(avg_int)# Average Interval width
[1] 0.2408541
>
> avg_sqr_err<-apply(sqr_err,1,mean)
> mean(avg_sqr_err)# Average Squared Error Loss
[1] 0.007104948
>
> avg_abs_bias<-apply(abs_bias,1,mean)
> mean(abs_bias)
[1] 0.04738646
> warnings()
Warning messages:
1: In qbeta(0.025, x, n - x + 1) : pbeta_raw() -> bratio() gave error code 6
2: In qbeta(0.025, x, n - x + 1) : pbeta_raw() -> bratio() gave error code 6
3: In qbeta(0.025, x, n - x + 1) : pbeta_raw() -> bratio() gave error code 6
4: In qbeta(0.025, x, n - x + 1) : pbeta_raw() -> bratio() gave error code 6
5: In qbeta(0.025, x, n - x + 1) : pbeta_raw() -> bratio() gave error code 6
Thanks
Anamika

[[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] X axis label as months

2013-08-21 Thread Prof J C Nash (U30A)

Thanks. The staxlab works with the plot generated by

plot(tt, data,)

but not with

plot(tsdata, ...)

i.e., it seems to be the tsplot that somehow changes something and the 
axis commands have no effect.


I probably should have pointed out that my main concern is that I'm not 
getting any error msg. Just no axis label. And it seems I need to make 
sure the labels vector is the same length as I need -- no recycling.


JN


On 13-08-21 06:37 PM, Jim Lemon wrote:

On 08/22/2013 07:56 AM, Prof J C Nash (U30A) wrote:

There are several items on the web about putting month names as tick
labels on x axis of time plots, but I found when I tried them they did
not work for me. After an hour or so of driving myself silly looking for
a bug in my code, I've prepared a reproducible example below, where I
did find a workaround, but would prefer to be able to plot a ts object.

Perhaps someone can spot the error in this. I'm sure it's something
silly or fumble-fingered.

JN


Hi,
Try this:

library(plotrix)
staxlab(1, at=1:28, label=months)

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] X axis label as months

2013-08-21 Thread Jim Lemon

On 08/22/2013 07:56 AM, Prof J C Nash (U30A) wrote:

There are several items on the web about putting month names as tick
labels on x axis of time plots, but I found when I tried them they did
not work for me. After an hour or so of driving myself silly looking for
a bug in my code, I've prepared a reproducible example below, where I
did find a workaround, but would prefer to be able to plot a ts object.

Perhaps someone can spot the error in this. I'm sure it's something
silly or fumble-fingered.

JN


Hi,
Try this:

library(plotrix)
staxlab(1, at=1:28, label=months)

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] X axis label as months

2013-08-21 Thread Gabor Grothendieck
On Wed, Aug 21, 2013 at 5:56 PM, Prof J C Nash (U30A)  wrote:
> There are several items on the web about putting month names as tick labels
> on x axis of time plots, but I found when I tried them they did not work for
> me. After an hour or so of driving myself silly looking for a bug in my
> code, I've prepared a reproducible example below, where I did find a
> workaround, but would prefer to be able to plot a ts object.
>
> Perhaps someone can spot the error in  this. I'm sure it's something silly
> or fumble-fingered.
>
> JN
>
> yy<-rnorm(28, 5, 1)
> yy
> yt<-ts(yy, frequency=12, start=c(2011, 1))
> yt
> plot(yt, xaxt="n", xlab="month")
> axis(1, at=1:28, label=month.abb) # fails  28 != 12
> axis(1, at=1:12, label=month.abb) # fails -- no axis labels
> X11()
> tt<-1:28
> plot(tt, yy, type='l', xaxt="n")
> axis(1, at=1:12, label=month.abb) # too short on axis
> axis(1, at=1:28, label=month.abb) # fails 28 != 12
> months<-c(month.abb, month.abb, month.abb[1:4])
> length(months)
> axis(1, at=1:28, label=months) # works! But why not the others?
>


In the zoo package see the example in ?plot.zoo labelled

## plot a mulitple ts series with nice x-axis using panel function


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] X axis label as months

2013-08-21 Thread Prof J C Nash (U30A)
There are several items on the web about putting month names as tick 
labels on x axis of time plots, but I found when I tried them they did 
not work for me. After an hour or so of driving myself silly looking for 
a bug in my code, I've prepared a reproducible example below, where I 
did find a workaround, but would prefer to be able to plot a ts object.


Perhaps someone can spot the error in  this. I'm sure it's something 
silly or fumble-fingered.


JN

yy<-rnorm(28, 5, 1)
yy
yt<-ts(yy, frequency=12, start=c(2011, 1))
yt
plot(yt, xaxt="n", xlab="month")
axis(1, at=1:28, label=month.abb) # fails  28 != 12
axis(1, at=1:12, label=month.abb) # fails -- no axis labels
X11()
tt<-1:28
plot(tt, yy, type='l', xaxt="n")
axis(1, at=1:12, label=month.abb) # too short on axis
axis(1, at=1:28, label=month.abb) # fails 28 != 12
months<-c(month.abb, month.abb, month.abb[1:4])
length(months)
axis(1, at=1:28, label=months) # works! But why not the others?

##  > sessionInfo()
##  R version 3.0.1 (2013-05-16)
##  Platform: x86_64-pc-linux-gnu (64-bit)
##
##  locale:
##   [1] LC_CTYPE=en_CA.UTF-8   LC_NUMERIC=C
##   [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8
##   [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8
##   [7] LC_PAPER=C LC_NAME=C
##   [9] LC_ADDRESS=C   LC_TELEPHONE=C
##  [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
##
##  attached base packages:
##  [1] stats graphics  grDevices utils datasets  methods   base 


##
##  loaded via a namespace (and not attached):
##  [1] tools_3.0.1
##  >

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

2013-08-21 Thread Grach, Alexander
Fellow R users, 

I'm trying to upgrade from 2.11 to 3.0.1. I have a legacy S3 class
defining method "DAILY" within one of our "in-house" packages using
R.oo. This method does not seem to  get 'resolved' under 3.0.1,
specifically the following does not work:

CODE WITHIN PACKAGE (e.g. MyPackage)-
setConstructorS3("MyTestClass", function(name = NULL, ...) {
this <- extend(RObject(), "MyTestClass", .units = NULL, .numUnits =
NULL, .name = name)#RObject extends Object and adds couple of simple
methods
return(this)
})

setMethodS3("DAILY", "MyTestClass", function(this, ...) {
print("In DAILY.MyTestClass")
})

setMethodS3("DAILY2", "MyTestClass", function(this, ...) {
print("In DAILY2.MyTestClass")
})

setMethodS3("Daily", "MyTestClass", function(this, ...) {
print("In Daily.MyTestClass")
})

CONSOLE---
> library(MyPackage)
> MyTestClass$DAILY()
Error in MyTestClass$DAILY() : could not find function "DAILY"
> DAILY.MyTestClass()
[1] "In DAILY.MyTestClass"
> MyTestClass$DAILY2()
[1] "In DAILY2.MyTestClass"
> MyTestClass$Daily()
[1] "In Daily.MyTestClass"


Any ideas as to why MyTestClass$DAILY() fails under 3.0.1 and what is
the best way to fix this?? I can always change the method name, yet I
wouldn't know what other methods might have similar issues..  This all
worked fine in 2.11. 
Also - if I "source" this code it works  fine. 

Many thanks, 
Alex



=
 
This material has been prepared by individual sales and/or trading personnel 
and does not 
constitute investment research.  Please follow the attached hyperlink to an 
important disclaimer: 
http://www.credit-suisse.com/americas/legal/salestrading 
=
 


=== 
Please access the attached hyperlink for an important el...{{dropped:4}}

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

2013-08-21 Thread arun
Hi Robert,


source("shareB101")
##Clean is the dataset
 res1<-with(Clean,aggregate(GRADE,list(TERM,INST_NUM),FUN=function(x) 
cbind(shapiro.test(x)$p.value,shapiro.test(x)$statistic)) )
 head(res1)
#  Group.1 Group.2  x.1  x.2
#1  201001  689809 1.720329e-07 9.307362e-01
#2  201201  689809 2.029761e-11 9.139405e-01
#3  201301  689809 4.709662e-14 8.791063e-01
#4  200701  994474 3.695317e-14 7.939902e-01
#5  200710  994474 4.560275e-13 8.849943e-01
#6  201203 1105752 4.434649e-15 9.220643e-01


#Regarding the lapply() error, it was the same problem as I thought:

lapply(split(Clean,list(Clean$TERM,Clean$INST_NUM)),function(x) 
shapiro.test(x$GRADE))
#Error in shapiro.test(x$GRADE) : sample size must be between 3 and 5000


lst1<-split(Clean,list(Clean$TERM,Clean$INST_NUM))
lst2<- lapply(lst1[lapply(lst1,nrow)>0], function(x) shapiro.test(x$GRADE))
 lst2[[1]]

#    Shapiro-Wilk normality test
#
#data:  x$GRADE
#W = 0.9307, p-value = 1.72e-07


library(plyr)
 res2<- ldply(dlply(Clean,.(TERM,INST_NUM), function(x) shapiro.test(x$GRADE)), 
summarize, pval=p.value,stat1=statistic)
 head(res2)
#    TERM INST_NUM pval stat1
#1 200610  1106842 1.420787e-11 0.9192428
#2 200610  1324438 2.345177e-12 0.9048394
#3 200610  1557630 4.618117e-10 0.8968445
#4 200701   994474 3.695317e-14 0.7939902
#5 200701  1106842 2.745429e-08 0.9292158
#6 200701  1107019 6.887642e-10 0.9213602


A.K.







From: Robert Lynch 
To: arun  
Sent: Wednesday, August 21, 2013 4:49 PM
Subject: Re: [R] ave function



Arun--

Thanks I had no idea about dput.  I really appreciate your help.  I have 
attached an example data set from dput.  Not to worry the ID#s have been 
changed but I wanted to include them just in case they were part of the issue ( 
though i doubt it).



On Tue, Aug 20, 2013 at 7:27 PM, arun  wrote:

HI,
>
>
>I guess your original dataset would have some list elements as empty.
>
>Clean<- structure(list(GRADE = c(1, 2, 3, 1.5, 1.75, 2, 0.5, 2, 3.5,
>3.5, 3.75, 4), TERM = c(9L, 9L, 9L, 8L, 8L, 8L, 9L, 9L, 9L, 8L,
>8L, 8L), INST_NUM = c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
>1L, 1L)), .Names = c("GRADE", "TERM", "INST_NUM"), class = "data.frame", 
>row.names = c(NA,
>-12L))
>
>  lapply(split(Clean,list(Clean$TERM,Clean$INST_NUM)),function(x) 
>shapiro.test(x$GRADE))
>#$`8.1`
>
>#    Shapiro-Wilk normality test
>#
>#data:  x$GRADE
>#W = 1, p-value = 1
>#
>
>#$`9.1`
>#
> #   Shapiro-Wilk normality test
>#
>#data:  x$GRADE
>#W = 1, p-value = 1
>
>-
>  sapply(split(Clean,list(Clean$TERM,Clean$INST_NUM)),function(x) 
>shapiro.test(x$GRADE)$p.value)
>#8.1 9.1 8.2 9.2
> # 1   1   1   1
>with(Clean, aggregate(GRADE,list(TERM,INST_NUM),FUN=shapiro.test)) #the output 
>is a list,
>#  Group.1 Group.2 x
>#1   8   1 1
>#2   9   1 1
>#3   8   2 1
>#4   9   2 1
>#Warning message:
>#In format.data.frame(x, digits = digits, na.encode = FALSE) :
> # corrupt data frame: columns will be truncated or padded with NAs
>
>
>
>library(plyr)
>ldply(dlply(Clean,.(TERM,INST_NUM), function(x) shapiro.test(x$GRADE)), 
>summarize, pval=p.value)
>#  TERM INST_NUM pval
>#1    8    1    1
>#2    8    2    1
>#3    9    1    1
>#4    9    2    1
>
>
>
>Now, consider this example:
>
>Clean1<- structure(list(GRADE = c(1, 2, 3, 1.5, 1.75, 2, 0.5, 2, 3.5,
>3.5, 3.75, 4, 4.5, 4.25, 4.32), TERM = c(9L, 9L, 9L, 8L, 8L,
>8L, 9L, 9L, 9L, 8L, 8L, 8L, 10L, 10L, 10L), INST_NUM = c(1L,
>1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("GRADE",
>"TERM", "INST_NUM"), class = "data.frame", row.names = c(NA,
>-15L))
>lapply(split(Clean1,list(Clean1$TERM,Clean1$INST_NUM)),function(x) 
>shapiro.test(x$GRADE))
>#Error in shapiro.test(x$GRADE) : sample size must be between 3 and 5000
>
> split(Clean1,list(Clean1$TERM,Clean1$INST_NUM))[[6]] ###0 rows
>#[1] GRADE    TERM INST_NUM
>#<0 rows> (or 0-length row.names)
>
>
>lst1<-split(Clean1,list(Clean1$TERM,Clean1$INST_NUM))
>lapply(lst1[lapply(lst1,nrow)>0], function(x) shapiro.test(x$GRADE))
>#$`8.1`
>#
> #   Shapiro-Wilk normality test
>#
>#data:  x$GRADE
>#W = 1, p-value = 1
>
>
>You could do this directly with:
> ldply(dlply(Clean1,.(TERM,INST_NUM), function(x) shapiro.test(x$GRADE)), 
>summarize, pval=p.value)
>#  TERM INST_NUM  pval
>#1    8    1 1.000
>#2    8    2 1.000
>#3    9    1 1.000
>#4    9    2 1.000
>#5   10    1 0.5248807
> ldply(dlply(Clean1,.(TERM,INST_NUM), function(x) shapiro.test(x$GRADE)), 
>summarize, pval=p.value,stat1=statistic)
>#  TERM INST_NUM  pval stat1
>#1    8    1 1.000 1.000
>#2    8    2 1.000 1.000
>#3    9    1 1.000 1.000
>#4    9    2 1.000 1.000
>#5   10    1 0.5248807 0.9393788
>
>
>
>#or
> with(Clean1, aggregate(GRADE,list(TERM,INST_NUM),FUN=function(x) 
>shapiro.test(x)$p.value))
>  Group.1 Group.2 x
>

Re: [R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-21 Thread Uwe Ligges



On 21.08.2013 22:35, Tal Galili wrote:

Dear R-help mailing list memebers,

I encountered the following error, and I'd be happy for ideas on how to fix
it:


# using R 3.0.1 on Windows 7:
exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
exe_filename <- file.path(tempdir(), file.name.from.url(exe_URL))
download.file(exe_URL, destfile = exe_filename, mode = "w", method=
"internal")

### output error :
trying URL 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
Content type 'Composite Document File V2 Document, corrupt: Can't read SAT;
charset=binary' length 5799936 bytes (5.5 Mb)
opened URL
downloaded 5.5 Mb

### another error:
And then when I try to execute the file (it is a windows installer), I get
the error:
"This installation package could not be opened. Contact the application
vendor to verify that this is a valid Windows installer package."

Downloading the file manually and running it does work.


Any suggestions?




Use mode="wb", it is a binary file!

Uwe Ligges


Thanks.





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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



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


[R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-21 Thread Tal Galili
Dear R-help mailing list memebers,

I encountered the following error, and I'd be happy for ideas on how to fix
it:


# using R 3.0.1 on Windows 7:
exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
exe_filename <- file.path(tempdir(), file.name.from.url(exe_URL))
download.file(exe_URL, destfile = exe_filename, mode = "w", method=
"internal")

### output error :
trying URL 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi'
Content type 'Composite Document File V2 Document, corrupt: Can't read SAT;
charset=binary' length 5799936 bytes (5.5 Mb)
opened URL
downloaded 5.5 Mb

### another error:
And then when I try to execute the file (it is a windows installer), I get
the error:
"This installation package could not be opened. Contact the application
vendor to verify that this is a valid Windows installer package."

Downloading the file manually and running it does work.


Any suggestions?

Thanks.





Contact
Details:---
Contact me: tal.gal...@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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


Re: [R] Coordinate scales for pairs plot

2013-08-21 Thread Ted Harding
On 21-Aug-2013 19:08:29 David Winsemius wrote:
> 
> On Aug 21, 2013, at 10:30 AM, (Ted Harding) wrote:
> 
>> Greetings all.
>> 
>> I suspect this question has already been asked. Apologies
>> for not having taced it ...
>> 
>> In the default pairs plot produces by the function pairs(),
>> the coordinate scales alternate between top and bottom and
>> right and left sides.
>> 
>> For example, in a 5x5 plot for variables X1, X2, X3, X4, X5
>> the coordinate scales for X2, X4 appear beside rows 2 and 4
>> on the left, and the scales for X1, X3, X5 appear beside rows
>> 1, 3, 5 on the right.
>> 
>> Similarly, the scales for X2 and X4 appear above columns 2 and 4,
>> and the scales for X1, X3, X5 appear below columns 1, 3, 5.
>> 
>> Is there a parameter lurking somewhere in the depths of this
>> function which can be set so that the scales for all the variables
>> X1,X2,X3,X4,X5 appear both above and below  columns 1,2,3,4,5;
>> and both to the left and to the right of rows 1,2,3,4,5?
> 
> I've searched for a parameter and come up empty; Hacking the code for
> pairs.default is not that difficult. I stripped out the conditionals that
> were driving the Axis calls to alternating "sides": 
> Search for `box()` to start this surgery and replace everything to the 'mfg'
> assignment to get uniform axis locations on sides 1 and 2.
> 
> pairs.12 <- function(x, ... arglist same as pairs.default)
>{upper portion of code
> box()
> if (i == nc ) 
> localAxis(1L , x[, j], x[, i], 
>   ...)
> if (j == 1 ) 
> localAxis(2L, x[, j], x[, i], ...)
> 
> mfg <- par("mfg")
>lower portion of code }
> 
> Oooops,  that wasn't what you asked for ... Use this instead:
> 
> 
> box()  # begin surgery
> if (i == 1 ) 
> localAxis(3, x[, j], x[, i],  ...)
> if (i == nc ) 
> localAxis(1, x[, j], x[, i],  ...)
> if (j == 1 ) 
> localAxis(2L, x[, j], x[, i], ...)
> if (j == nc ) 
> localAxis(4L, x[, j], x[, i], ...)
> # end anastomosis
>  mfg <- par("mfg")
> ..
> --
> David Winsemius
> Alameda, CA, USA

Thanks very much, David! I'll give it a try. It looks promising.

Good surgery, steady hand!
Ted.

-
E-Mail: (Ted Harding) 
Date: 21-Aug-2013  Time: 21:23:39
This message was sent by 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] lattice: bwplot: getting two plots into one.

2013-08-21 Thread Anna Zakrisson Braeunlich
Dear Mr. Heiberger,

thank you for your reply. I think that you may have misunderstood my question. 
What I want is to superpose the two panels into one.
Lets take this simplified code:
bwplot(var1 ~ factor1|factor2, data=mydata, panel=panel.bwplot.intermediate.hh)

What I want is this:
bwplot(var1 ~ factor1, data=mydata, panel=panel.bwplot.intermediate.hh)
But with two factors in the same panel.

I know that this will look extremely bad with this dummy data, but I need ito 
be able to do this with my data.

What I also want is to not have any "jitter", but to have them exactly on top 
of each other - again, this will look terribel on this data, but will be OK for 
mine.
Is this possible in lattice? Maybe using different data frames and make 
different plots and superpose them on top of each other? Ideas?

ggplot2?
with kind regards

Anna Zakrisson Braeunlich
PhD student

Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• `•. .><º>`•. . • `•. .• 
>`•. .><º>

From: Richard M. Heiberger [r...@temple.edu]
Sent: 21 August 2013 17:21
To: Anna Zakrisson Braeunlich
Cc: r-help@r-project.org
Subject: Re: [R] lattice: bwplot: getting two plots into one.

This is the fundamentals

bwplot(var1 ~ factor1 | factor2, data=mydata,
  panel=function(...) {
panel.abline(h=0, lty=2, col="gray90")
panel.bwplot(...)
})

You can add the font control if you need to.  The major change I made was to 
put the
panel.abline first.  It is part of the background and I don't want it to 
overwrite the graph.
Also, I made it in a light gray so it wouldn't take attention away from the 
data.

Rich


On Wed, Aug 21, 2013 at 4:42 AM, Anna Zakrisson Braeunlich 
mailto:anna.zakris...@su.se>> wrote:
Dear all,

I have problems gettting the following as one graph instead of the two created 
by this script. I know that with this dummy data, the resulting graph will look 
like a catastrophy. I have other data I wish to apply this too. Just wanted to 
supply some dummy data to work with.
There may be unnecessary code below. I am still learning.

Is it possible to do two different bwplots from different dataframes and then 
superpose them on to each other?
with kind regards

A. Zakrisson

mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)), #Dummy data
factor2 = factor(rep(c(1:2), each = 16)),
var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
 sd = rep(c(1, 2, 3), each = 20)))

font.settings <- list( font = 1, cex = 1.3, fontfamily = "serif")

my.theme <- list(
  box.umbrella = list(col = "black"), #Color of deviation lines (95%)
  box.rectangle = list(col="black"),  #Color of the line around the box
  box.dot = list(col = "black", pch = 3, lty=2, lwd=5, cex=1.3),
  plot.symbol   = list(cex = 1, col = 1, pch= 0), #outlier size and color
  par.xlab.text = font.settings,
  mfrow=c(2,2),
  par.ylab.text = font.settings,
  axis.line=list(col="black"), #Set "transparent if no axes
  axis.text = font.settings,
  strip.shingle=list(col=c("white","white")),
  superpose.symbol=list(fill=c("white","white")), # boxplots
  superpose.fill=list(col=c("white","white")),
  superpose.polygon=list(col=c("white","white")), # legend
  par.sub=font.settings)

bgColors <- c("white", "white", "white")
txtColors <- c("black", "black", "black")
myStripStyle <- function(which.panel, factor.levels, par.strip.text,
 custBgCol=par.strip.text$custBgCol,
 custTxtCol=par.strip.text$custTxtCol,...) {
  par.settings = list(layout.heights=list(strip=3))
  panel.rect(0, 0, 1, 1,
 col = custBgCol[which.panel],
 border = 1.2)
  panel.text(x = 0.5, y = 0.5,
 font=1,
 fontfamily = "serif",
 cex=1.4,
 lab = factor.levels[which.panel],
 col = custTxtCol[which.panel])
}

bwplot(var1 ~ factor1|factor2, data = mydata,
   groups=factor2,
   box.width = 1/3,#width of the boxes
   panel=panel.superpose,
   ylab = expression(paste("",delta^{15}, "N")),
   xlab="Station",
   par.settings = my.theme,
   par.strip.text=list(custBgCol=bgColors,
   custTxtCol=txtColors),
   strip=myStripStyle,
   scales = list(alternating = TRUE,
 x = list(relation = "same", rot=45),
 y = list(relation = "same")),
   panel.groups = function(x, y, ..., group.number) {
 panel.bwplot(x + (group.number-1.8)/3, y, ...)
   })
trellis.focus("panel", 1, 1)
panel

Re: [R] rcode problem

2013-08-21 Thread John Kane
Your data arrived but no code. The R help list is fussy about what type of 
files you can attache.  

For an alternative approach have a look at 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

John Kane
Kingston ON Canada


> -Original Message-
> From: nuru.garkuwa...@aberdeen.ac.uk
> Sent: Tue, 20 Aug 2013 17:52:42 +
> To: r-help@r-project.org
> Subject: [R] rcode problem
> 
> Hi,
> 
> 
> 
> Please find attached rcode and my data.There seems to be a problem in the
> following rcodes:
> 
> plot(diet~class.f, data=nuru)
> points(pred.mod1~midpoints,type="b")
> 
> 
> 
> please I need your help.
> 
> 
> 
> Kind Regards,
> 
> Nuru
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Narrowing values collected from .txt file

2013-08-21 Thread John Kane
I am not sure what happened but it may be that you accidentally sent your 
message in html but the text connection data seems unuseable.

It is much better to use ?dput to supply sample data.

Have a look at 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

John Kane
Kingston ON Canada


> -Original Message-
> From: emor...@usgs.gov
> Sent: Wed, 21 Aug 2013 06:50:07 -0700
> To: r-help@r-project.org
> Subject: [R] Narrowing values collected from .txt file
> 
> useRs-
> 
> The output generated from a groundwater model post-processor contains
> millions of lines of text.  Using the custom R function shown below, I
> can
> quickly gather values from this file.
> 
> As you can see in the textConnection provided below (which is only a
> small
> snippet from the file), the output is repetitive but does have some
> header
> lines I hope to make use of to narrow the collected output.  The header
> lines I'm speaking of are:
> 1) " Flow Budget for Zone  1 at Time Step   1 of Stress Period   2"
> 2) " Flow Budget for Zone  2 at Time Step   1 of Stress Period   2"
> 3) " Flow Budget for Zone  3 at Time Step   1 of Stress Period   2"
> 4) " Flow Budget for Zone  1 at Time Step   1 of Stress Period   3"
> ...
> 
> and so on for 111 different "zones" as well as 575 distinct "stress
> periods".  In the custom function that follows, currently named "g", I
> can
> collect all values of "Recharge".  If instead I want to restrict the
> collected "Recharge" values to "Zone 2" for all 575 stress periods, is
> there a way to first look for the header "Flow Budget for Zone  2",
> collect
> only the next two values of Recharge, and then skip down to the next
> header
> containing "Zone 2", collect 2 more values of "Recharge", and on like
> this
> to the end?  'Peeling' out targeted flow budget terms will facilitate
> generation of budget-specific plots through time.
> 
> The "edm" variable at the end of the R code that follows currently looks
> like this:
> edm
> # [1] 1.28980e+05 0.0e+00 *2.74161e-01* 0.0e+00 8.10840e+04
> 0.0e+00
> # [7] 1.28980e+05 0.0e+00 *2.74165e-01* 0.0e+00 8.10840e+04
> 0.0e+00
> 
> but with the proposed revision, which only collects Recharge values from
> Zone 2, it would look like:
> edm
> # [1] *2.74161e-01* 0.0e+00 *2.74165e-01* 0.0e+00
> 
> 
> txt_con<-textConnection(" mark_zone
> 
> 
>  Flow Budget for Zone  1 at Time Step   1 of Stress Period   2
>  -
> 
>Budget Term Flow (L**3/T)
>-
> 
>  IN:
>  ---
>STORAGE =   0.37855E-02
>  CONSTANT HEAD =0.
>   RECHARGE =   0.12898E+06
> STREAM LEAKAGE =0.
>  LAKE  SEEPAGE =0.
> UZF ET =0.
>  GW ET =0.
>   UZF INFILTR. =0.
>   SFR-DIV. INFLTR. =0.
>   UZF RECHARGE =0.
>SURFACE LEAKAGE =0.
>Zone  16 to   1 =0.
>Zone  31 to   1 =0.
>Zone  40 to   1 =0.
>Zone  91 to   1 =0.
> 
>   Total IN =   0.12898E+06
> 
>  OUT:
>  
>STORAGE =   0.58275E-04
>  CONSTANT HEAD =0.
>   RECHARGE =0.
> STREAM LEAKAGE =0.
>  LAKE  SEEPAGE =0.
> UZF ET =0.
>  GW ET =0.
>   UZF INFILTR. =0.
>   SFR-DIV. INFLTR. =0.
>   UZF RECHARGE =0.
>SURFACE LEAKAGE =0.
>Zone   1 to  16 =399.88
>Zone   1 to  31 =85204.
>Zone   1 to  40 =12404.
>Zone   1 to  91 =30968.
> 
>  Total OUT =   0.12898E+06
> 
>   IN - OUT =   0.14138E-03
> 
>Percent Discrepancy =0.00
> 1
>  mark_zone
> 
> 
>  Flow Budget for Zone  2 at Time Step   1 of Stress Period   2
>  -
> 
>Budget Term Flow (L**3/T)
>-
> 
>  IN:
>  ---
>STORAGE =   0.18833E-05
>  CONSTANT HEAD =0.
>   RECHARGE =   0.274161E+06
> STREAM LEAKAGE =0.
>  

Re: [R] Coordinate scales for pairs plot

2013-08-21 Thread David Winsemius

On Aug 21, 2013, at 10:30 AM, (Ted Harding) wrote:

> Greetings all.
> 
> I suspect this question has already been asked. Apologies
> for not having taced it ...
> 
> In the default pairs plot produces by the function pairs(),
> the coordinate scales alternate between top and bottom and
> right and left sides.
> 
> For example, in a 5x5 plot for variables X1, X2, X3, X4, X5
> the coordinate scales for X2, X4 appear beside rows 2 and 4
> on the left, and the scales for X1, X3, X5 appear beside rows
> 1, 3, 5 on the right.
> 
> Similarly, the scales for X2 and X4 appear above columns 2 and 4,
> and the scales for X1, X3, X5 appear below columns 1, 3, 5.
> 
> Is there a parameter lurking somewhere in the depths of this
> function which can be set so that the scales for all the variables
> X1,X2,X3,X4,X5 appear both above and below  columns 1,2,3,4,5;
> and both to the left and to the right of rows 1,2,3,4,5?

I've searched for a parameter and come up empty; Hacking the code for 
pairs.default is not that difficult. I stripped out the conditionals that were 
driving the Axis calls to alternating "sides": 
Search for `box()` to start this surgery and replace everything to the 'mfg' 
assignment to get uniform axis locations on sides 1 and 2.

pairs.12 <- function(x, ... arglist same as pairs.default)
   {upper portion of code
box()
if (i == nc ) 
localAxis(1L , x[, j], x[, i], 
  ...)
if (j == 1 ) 
localAxis(2L, x[, j], x[, i], ...)

mfg <- par("mfg")
   lower portion of code }

Oooops,  that wasn't what you asked for ... Use this instead:


box()  # begin surgery
if (i == 1 ) 
localAxis(3, x[, j], x[, i],  ...)
if (i == nc ) 
localAxis(1, x[, j], x[, i],  ...)
if (j == 1 ) 
localAxis(2L, x[, j], x[, i], ...)
if (j == nc ) 
localAxis(4L, x[, j], x[, i], ...)
# end anastomosis
 mfg <- par("mfg")
..
--
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: bwplot: getting two plots into one.

2013-08-21 Thread Richard M. Heiberger
That is also easy.  See the

## install.packages("HH")  ## if you don't yet have it.
library(HH)

demo("bwplot.examples", package="HH")

These examples show how to use the tools based on
panel=panel.bwplot.intermediate.hh
and you will easily be able to modify the code
for your specific case.

Rich



On Wed, Aug 21, 2013 at 1:32 PM, Anna Zakrisson Braeunlich <
anna.zakris...@su.se> wrote:

>  Dear Mr. Heiberger,
>
>  thank you for your reply. I think that you may have misunderstood my
> question. What I want is to superpose the two panels into one.
> Lets take this simplified code:
> bwplot(var1 ~ factor1|factor2, data=mydata,
> panel=panel.bwplot.intermediate.hh)
>
>  What I want is this:
> bwplot(var1 ~ factor1, data=mydata, panel=panel.bwplot.intermediate.hh)
> But with two factors in the same panel.
>
>  I know that this will look extremely bad with this dummy data, but I
> need ito be able to do this with my data.
>
>  What I also want is to not have any "jitter", but to have them exactly
> on top of each other - again, this will look terribel on this data, but
> will be OK for mine.
> Is this possible in lattice? Maybe using different data frames and make
> different plots and superpose them on top of each other? Ideas?
>
> ggplot2?
> with kind regards
>
>
>  Anna Zakrisson Braeunlich
> PhD student
>
> Department of Ecology, Environment and Plant Sciences
> Stockholm University
> Svante Arrheniusv. 21A
> SE-106 91 Stockholm
> Sweden/Sverige
>
>  Lives in Berlin.
> For paper mail:
> Katzbachstr. 21
> D-10965, Berlin - Kreuzberg
> Germany/Deutschland
>
> E-mail: anna.zakris...@su.se
> Tel work: +49-(0)3091541281
> Mobile: +49-(0)15777374888
> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
>
> ><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• `•. .><º>`•. . •
> `•. .• `•. .><º>
>   --
> *From:* Richard M. Heiberger [r...@temple.edu]
> *Sent:* 21 August 2013 17:21
> *To:* Anna Zakrisson Braeunlich
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] lattice: bwplot: getting two plots into one.
>
>   This is the fundamentals
>
> bwplot(var1 ~ factor1 | factor2, data=mydata,
>   panel=function(...) {
>  panel.abline(h=0, lty=2, col="gray90")
> panel.bwplot(...)
> })
>
>  You can add the font control if you need to.  The major change I made
> was to put the
> panel.abline first.  It is part of the background and I don't want it to
> overwrite the graph.
> Also, I made it in a light gray so it wouldn't take attention away from
> the data.
>
>  Rich
>
>
> On Wed, Aug 21, 2013 at 4:42 AM, Anna Zakrisson Braeunlich <
> anna.zakris...@su.se> wrote:
>
>> Dear all,
>>
>> I have problems gettting the following as one graph instead of the two
>> created by this script. I know that with this dummy data, the resulting
>> graph will look like a catastrophy. I have other data I wish to apply this
>> too. Just wanted to supply some dummy data to work with.
>> There may be unnecessary code below. I am still learning.
>>
>> Is it possible to do two different bwplots from different dataframes and
>> then superpose them on to each other?
>> with kind regards
>>
>> A. Zakrisson
>>
>> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
>> #Dummy data
>> factor2 = factor(rep(c(1:2), each = 16)),
>> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
>>  sd = rep(c(1, 2, 3), each = 20)))
>>
>> font.settings <- list( font = 1, cex = 1.3, fontfamily = "serif")
>>
>> my.theme <- list(
>>   box.umbrella = list(col = "black"), #Color of deviation lines (95%)
>>   box.rectangle = list(col="black"),  #Color of the line around the box
>>   box.dot = list(col = "black", pch = 3, lty=2, lwd=5, cex=1.3),
>>   plot.symbol   = list(cex = 1, col = 1, pch= 0), #outlier size and color
>>   par.xlab.text = font.settings,
>>   mfrow=c(2,2),
>>   par.ylab.text = font.settings,
>>   axis.line=list(col="black"), #Set "transparent if no axes
>>   axis.text = font.settings,
>>   strip.shingle=list(col=c("white","white")),
>>   superpose.symbol=list(fill=c("white","white")), # boxplots
>>   superpose.fill=list(col=c("white","white")),
>>   superpose.polygon=list(col=c("white","white")), # legend
>>   par.sub=font.settings)
>>
>> bgColors <- c("white", "white", "white")
>> txtColors <- c("black", "black", "black")
>> myStripStyle <- function(which.panel, factor.levels, par.strip.text,
>>  custBgCol=par.strip.text$custBgCol,
>>  custTxtCol=par.strip.text$custTxtCol,...) {
>>   par.settings = list(layout.heights=list(strip=3))
>>   panel.rect(0, 0, 1, 1,
>>  col = custBgCol[which.panel],
>>  border = 1.2)
>>   panel.text(x = 0.5, y = 0.5,
>>  font=1,
>>  fontfamily = "serif",
>>  cex=1.4,
>>  lab = factor.levels[which.panel],
>>  col = custTxtCol[which.panel])
>> }
>>
>

[R] Coordinate scales for pairs plot

2013-08-21 Thread Ted Harding
Greetings all.

I suspect this question has already been asked. Apologies
for not having taced it ...

In the default pairs plot produces by the function pairs(),
the coordinate scales alternate between top and bottom and
right and left sides.

For example, in a 5x5 plot for variables X1, X2, X3, X4, X5
the coordinate scales for X2, X4 appear beside rows 2 and 4
on the left, and the scales for X1, X3, X5 appear beside rows
1, 3, 5 on the right.

Similarly, the scales for X2 and X4 appear above columns 2 and 4,
and the scales for X1, X3, X5 appear below columns 1, 3, 5.

Is there a parameter lurking somewhere in the depths of this
function which can be set so that the scales for all the variables
X1,X2,X3,X4,X5 appear both above and below  columns 1,2,3,4,5;
and both to the left and to the right of rows 1,2,3,4,5?

With thanks,
Ted.

-
E-Mail: (Ted Harding) 
Date: 21-Aug-2013  Time: 18:30:44
This message was sent by 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] data import: strange experience

2013-08-21 Thread David Carlson
You should be able to figure it out if you just print out the
four factor levels that read.table() missed. The main
differences are that read.table() includes ' in the quote=
argument and it recognizes # as a comment (and therefore
discards it and everything after it):

setdiff(levels(dfcsv$Var), levels(dftxt$Var))

The base function is read.table() and it includes the following
defaults:

quote="\"'", comment.char="#"

Functions read.csv() and read.delim() call read.table() but
change those defaults to

quote="\"", comment.char=""

David

From: SH [mailto:empti...@gmail.com] 
Sent: Wednesday, August 21, 2013 10:14 AM
To: dcarl...@tamu.edu; peter dalgaard
Cc: r-help
Subject: Re: [R] data import: strange experience

Thanks Peter.  It works with read.delim.
 
David: Thanks for your comments.  To answer your questions.  I
don't have 'NA' and all balanced.  The number of mssing levels
were 4 and it happened only to those four levels.  Yes, there
is commas embedded and some characters (e.g., '-', space, some
wired characters in the middle of names, etc.).  I can send you
sample data if you are willing to take a look.  Even though
using 'read.delim' works, I am still curious what caused the
problem and potential problem that I may miss.
 
Thanks again,
 
SH
 
 

On Wed, Aug 21, 2013 at 10:58 AM, David Carlson
 wrote:
This is not really enough information to diagnose the problem.
What are the missing factor levels? Were the missing levels
combined with another level or do you have missing values (NA)
for those observations? Do the extra factor levels include
embedded commas? There are differences between read.table and
read.csv in the default quote= and comment.char= arguments.

-
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of SH
Sent: Wednesday, August 21, 2013 9:36 AM
To: r-help@r-project.org
Subject: [R] data import: strange experience

Dear List:

I had some strange experience in importing data.  I wonder if
anyone of you
had the same problem before and would greatly appreciate your
suggestion in
advance.

The original data set in excel format.

Here is a brief summary of the procedure I did:
1. I saved the original excel data as csv and txt formats,
separately.
2. I imported two data using the following codes.  There were no
error
messages.
dftxt = read.table('df.txt',header=T, sep='\t')
dfcsv = read.csv('df.csv',header=T, sep=',')
3. When I checked data with 'str', I found that factor levels of
a variable
were different each other.
Levels of dftxt were less than those of dfcsv (48 vs 52).
4. So, I checked 'df.txt' file and found that the missing levels
were still
there, i.e., there is a no problem in text file.  I suspect that
something
happened when I imported it into R.

Since there was no errors in importing the file into R, I do not
have an
idea where to start to fix it.  Do you have any suggestion?

Thank you very much in advance,

SH
        [[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] Problems installing FAME package on Windows 7.

2013-08-21 Thread Uwe Ligges

Probably something with your environment and/or your toolset.

Does the CRAN binary work for you?

i.e. just use

 install.packages("fame")

and try it out..

Best,
Uwe Ligges



On 20.08.2013 11:07, Andreas Dibiasi wrote:

I have problems to install the FAME package. I have installed the fame
client 9.3.32.2 and the environmental variable is set. However, for
some reason, the warnings "error: argument "lib.loc" > is missing,
with no default" pops up under the i386 installation and "LoadLibrary
failure:  %1 is not a valid Win32 application" under x64. Has anyone
experienced similar problems and know the a way how to solve it?


R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.



install.packages("fame", repos = "http://cran.r-project.org/";, 
type="source")Installing package into ‘C:/APPS/R/R-3.0.1/library’

(as ‘lib’ is unspecified)trying URL
'http://cran.r-project.org/src/contrib/fame_2.18.tar.gz'Content type
'application/x-gzip' length 51940 bytes (50 Kb)opened URLdownloaded 50
Kb
* installing *source* package 'fame' ...
** Paket 'fame' erfolgreich entpackt und MD5 Summen überprüft
** libs

*** arch - i386
cygwin warning:
   MS-DOS style path detected: C:/R/R-30~1.1/etc/i386/Makeconf
   Preferred POSIX equivalent is: /cygdrive/c/R/R-30~1.1/etc/i386/Makeconf
   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
   Consult the user's guide for more details about POSIX paths:
 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m32 -I"C:/R/R-30~1.1/include" -DNDEBUG -Dfame -DDUMMY_CALLS
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall
-std=gnu99 -mtune=core2 -c chli.c -o chli.o
gcc -m32 -I"C:/R/R-30~1.1/include" -DNDEBUG -Dfame -DDUMMY_CALLS
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall
-std=gnu99 -mtune=core2 -c fame.c -o fame.o
gcc -m32 -shared -s -static-libgcc -o fame.dll tmp.def chli.o fame.o
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-30~1.1/bin/i386
-lR
C:\Rtools\gcc-4.6.3\bin\nm.exe: chli.c: File format not recognized
gcc -m32 -shared -s -static-libgcc -o chli.dll chli.def chli.c
-L"d:/RCompile/CRANpkg/extralibs64/local/lib/i386"
-L"d:/RCompile/CRANpkg/extralibs64/local/lib"
-L"C:/R/R-30~1.1/bin/i386" -lR
installing to C:/APPS/R/R-3.0.1/library/fame/libs/i386

*** arch - x64
cygwin warning:
   MS-DOS style path detected: C:/R/R-30~1.1/etc/x64/Makeconf
   Preferred POSIX equivalent is: /cygdrive/c/R/R-30~1.1/etc/x64/Makeconf
   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
   Consult the user's guide for more details about POSIX paths:
 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m64 -I"C:/R/R-30~1.1/include" -DNDEBUG -Dfame -DDUMMY_CALLS
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall
-std=gnu99 -mtune=core2 -c chli.c -o chli.o
gcc -m64 -I"C:/R/R-30~1.1/include" -DNDEBUG -Dfame -DDUMMY_CALLS
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall
-std=gnu99 -mtune=core2 -c fame.c -o fame.o
gcc -m64 -shared -s -static-libgcc -o fame.dll tmp.def chli.o fame.o
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-30~1.1/bin/x64
-lR
C:\Rtools\gcc-4.6.3\bin\nm.exe: chli.c: File format not recognized
gcc -m64 -shared -s -static-libgcc -o chli.dll chli.def chli.c
-L"d:/RCompile/CRANpkg/extralibs64/local/lib/x64"
-L"d:/RCompile/CRANpkg/extralibs64/local/lib"
-L"C:/R/R-30~1.1/bin/x64" -lR
installing to C:/APPS/R/R-3.0.1/library/fame/libs/x64
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'fame', details:
   call: library.dynam("fame", package = "fame")
   error: Argument "lib.loc" fehlt (ohne Standardwert)
Fehler: Laden fehlgeschlagen
Ausführung angehalten
*** arch - x64
Error : .onLoad failed in loadNamespace() for 'fame', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: kann shared object 'C:/Program Files (x86)/FAME/chli.dll' nicht laden:
   LoadLibrary failure:  %1 is not a valid Win32 application.

Fehler: Laden fehlgeschlagen
Ausführung angehalten
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/APPS/R/R-3.0.1/library/fame'
* restoring previous 'C:/APPS/R/R-3.0.1/library/f

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-21 Thread Ben Bolker
Rolf Turner  xtra.co.nz> writes:

> 
> On 21/08/13 11:23, Ye Lin wrote:
> > T
> > hanks for your insights Rolf! The model I want to fit is y=x/a+x with 
> > no intercept, so I transformed it to 1/y=1+a/x as they are the same.
> 
> For crying out loud, they are ***NOT*** the same.  The equations y = 
> x/(a+x) and
> 1/y = 1 + a/x are indeed algebraically identical, but if an "error" or 
> "noise" term is added
> to each then then the nature of the error term is vastly different. It 
> is the error or
> noise term that is of central concern in a statistical context.
> 
>  cheers,
> 
>  Rolf


  For what it's worth this model can also be fitted (without messing
up the error structure) via

 glm(1/y~x,family=gaussian(link="inverse"))

Although you may not get the parameters in exactly the form you
want.

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

2013-08-21 Thread Tom Li


> Error: XML content does not seem to be XML: 'content_1.xml'In addition: 
> Warning message:In file.remove("content.xml") :  cannot remove file 
> 'content.xml', reason 'No such file or directory'


Check out the XML file. When I run into errors with odfWeave, it's usually 
because a non-unicode character not being escaped properly.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: bwplot: getting two plots into one.

2013-08-21 Thread Richard M. Heiberger
This is the fundamentals

bwplot(var1 ~ factor1 | factor2, data=mydata,
  panel=function(...) {
panel.abline(h=0, lty=2, col="gray90")
panel.bwplot(...)
})

You can add the font control if you need to.  The major change I made was
to put the
panel.abline first.  It is part of the background and I don't want it to
overwrite the graph.
Also, I made it in a light gray so it wouldn't take attention away from the
data.

Rich


On Wed, Aug 21, 2013 at 4:42 AM, Anna Zakrisson Braeunlich <
anna.zakris...@su.se> wrote:

> Dear all,
>
> I have problems gettting the following as one graph instead of the two
> created by this script. I know that with this dummy data, the resulting
> graph will look like a catastrophy. I have other data I wish to apply this
> too. Just wanted to supply some dummy data to work with.
> There may be unnecessary code below. I am still learning.
>
> Is it possible to do two different bwplots from different dataframes and
> then superpose them on to each other?
> with kind regards
>
> A. Zakrisson
>
> mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)), #Dummy
> data
> factor2 = factor(rep(c(1:2), each = 16)),
> var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
>  sd = rep(c(1, 2, 3), each = 20)))
>
> font.settings <- list( font = 1, cex = 1.3, fontfamily = "serif")
>
> my.theme <- list(
>   box.umbrella = list(col = "black"), #Color of deviation lines (95%)
>   box.rectangle = list(col="black"),  #Color of the line around the box
>   box.dot = list(col = "black", pch = 3, lty=2, lwd=5, cex=1.3),
>   plot.symbol   = list(cex = 1, col = 1, pch= 0), #outlier size and color
>   par.xlab.text = font.settings,
>   mfrow=c(2,2),
>   par.ylab.text = font.settings,
>   axis.line=list(col="black"), #Set "transparent if no axes
>   axis.text = font.settings,
>   strip.shingle=list(col=c("white","white")),
>   superpose.symbol=list(fill=c("white","white")), # boxplots
>   superpose.fill=list(col=c("white","white")),
>   superpose.polygon=list(col=c("white","white")), # legend
>   par.sub=font.settings)
>
> bgColors <- c("white", "white", "white")
> txtColors <- c("black", "black", "black")
> myStripStyle <- function(which.panel, factor.levels, par.strip.text,
>  custBgCol=par.strip.text$custBgCol,
>  custTxtCol=par.strip.text$custTxtCol,...) {
>   par.settings = list(layout.heights=list(strip=3))
>   panel.rect(0, 0, 1, 1,
>  col = custBgCol[which.panel],
>  border = 1.2)
>   panel.text(x = 0.5, y = 0.5,
>  font=1,
>  fontfamily = "serif",
>  cex=1.4,
>  lab = factor.levels[which.panel],
>  col = custTxtCol[which.panel])
> }
>
> bwplot(var1 ~ factor1|factor2, data = mydata,
>groups=factor2,
>box.width = 1/3,#width of the boxes
>panel=panel.superpose,
>ylab = expression(paste("",delta^{15}, "N")),
>xlab="Station",
>par.settings = my.theme,
>par.strip.text=list(custBgCol=bgColors,
>custTxtCol=txtColors),
>strip=myStripStyle,
>scales = list(alternating = TRUE,
>  x = list(relation = "same", rot=45),
>  y = list(relation = "same")),
>panel.groups = function(x, y, ..., group.number) {
>  panel.bwplot(x + (group.number-1.8)/3, y, ...)
>})
> trellis.focus("panel", 1, 1)
> panel.abline(h=0, lty=2)  #lwd
> trellis.unfocus()
> trellis.focus("panel", 2, 1)
> panel.abline(h=0, lty=2)  #lwd
> trellis.unfocus()
>
>
> Anna Zakrisson Braeunlich
> PhD student
>
> Department of Ecology, Environment and Plant Sciences
> Stockholm University
> Svante Arrheniusv. 21A
> SE-106 91 Stockholm
> Sweden/Sverige
>
> Lives in Berlin.
> For paper mail:
> Katzbachstr. 21
> D-10965, Berlin - Kreuzberg
> Germany/Deutschland
>
> E-mail: anna.zakris...@su.se
> Tel work: +49-(0)3091541281
> Mobile: +49-(0)15777374888
> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
>
> ><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• `•. .><º>`•. . •
> `•. .• `•. .><º>
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] multiple core

2013-08-21 Thread Uwe Ligges



On 20.08.2013 21:05, Andrea Lamont wrote:

Hello:

I have somewhat of a generic question.  How do you use multiple CPU/core
processors in R?  For those familiar with Mplus software, I'm looking for
something analogous to PROCESSORS command in Mplus to speed up processing.
  I searched previous helps/googled it and see that there is a multicore and
parallel package, but I am not understanding how to use these packages.  Is
there a straightforward way to tell R to use more than one processor?

In my search, I found this:
Sys.setenv(MC_CORES=12)
but am unsure what it does...


You have to write code that can be executed in parallel. The parallel 
package helps, see its documentation.


Best,
Uwe Ligges





Thanks!
Andrea



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

2013-08-21 Thread SH
Thanks Peter.  It works with read.delim.

David: Thanks for your comments.  To answer your questions.  I don't have
'NA' and all balanced.  The number of mssing levels were 4 and it happened
only to those four levels.  Yes, there is commas embedded and some
characters (e.g., '-', space, some wired characters in the middle of names,
etc.).  I can send you sample data if you are willing to take a look.  Even
though using 'read.delim' works, I am still curious what caused the problem
and potential problem that I may miss.

Thanks again,

SH




On Wed, Aug 21, 2013 at 10:58 AM, David Carlson  wrote:

> This is not really enough information to diagnose the problem.
> What are the missing factor levels? Were the missing levels
> combined with another level or do you have missing values (NA)
> for those observations? Do the extra factor levels include
> embedded commas? There are differences between read.table and
> read.csv in the default quote= and comment.char= arguments.
>
> -
> David L Carlson
> Associate Professor of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of SH
> Sent: Wednesday, August 21, 2013 9:36 AM
> To: r-help@r-project.org
> Subject: [R] data import: strange experience
>
> Dear List:
>
> I had some strange experience in importing data.  I wonder if
> anyone of you
> had the same problem before and would greatly appreciate your
> suggestion in
> advance.
>
> The original data set in excel format.
>
> Here is a brief summary of the procedure I did:
> 1. I saved the original excel data as csv and txt formats,
> separately.
> 2. I imported two data using the following codes.  There were no
> error
> messages.
> dftxt = read.table('df.txt',header=T, sep='\t')
> dfcsv = read.csv('df.csv',header=T, sep=',')
> 3. When I checked data with 'str', I found that factor levels of
> a variable
> were different each other.
> Levels of dftxt were less than those of dfcsv (48 vs 52).
> 4. So, I checked 'df.txt' file and found that the missing levels
> were still
> there, i.e., there is a no problem in text file.  I suspect that
> something
> happened when I imported it into R.
>
> Since there was no errors in importing the file into R, I do not
> have an
> idea where to start to fix it.  Do you have any suggestion?
>
> Thank you very much in advance,
>
> SH
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible
> code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] data import: strange experience

2013-08-21 Thread SH
Hi Sarah,

Thanks for a prompt feedback.  I knew it will be very vague without
example.  However, I only used two commands to import data and had no
'apparent' errors.  The original data have about 19000 obs and I was able
to reduce about 3200.  I wonder if I can attach the data file (size:
109K) with my email.

Best,

Steve


On Wed, Aug 21, 2013 at 10:46 AM, Sarah Goslee wrote:

> Hi,
>
> We don't know anything about your data or your file, so it's utterly
> impossible to offer useful suggestions.
>
> The very best thing you can do is condense your problem into a
> reproducible example, with fake data if necessary. Otherwise you're
> limited by the ability of the list to guess what you're looking at,
> and our track record with that is spotty.
>
>
> Sarah
>
> On Wed, Aug 21, 2013 at 10:35 AM, SH  wrote:
> > Dear List:
> >
> > I had some strange experience in importing data.  I wonder if anyone of
> you
> > had the same problem before and would greatly appreciate your suggestion
> in
> > advance.
> >
> > The original data set in excel format.
> >
> > Here is a brief summary of the procedure I did:
> > 1. I saved the original excel data as csv and txt formats, separately.
> > 2. I imported two data using the following codes.  There were no error
> > messages.
> > dftxt = read.table('df.txt',header=T, sep='\t')
> > dfcsv = read.csv('df.csv',header=T, sep=',')
> > 3. When I checked data with 'str', I found that factor levels of a
> variable
> > were different each other.
> > Levels of dftxt were less than those of dfcsv (48 vs 52).
> > 4. So, I checked 'df.txt' file and found that the missing levels were
> still
> > there, i.e., there is a no problem in text file.  I suspect that
> something
> > happened when I imported it into R.
> >
> > Since there was no errors in importing the file into R, I do not have an
> > idea where to start to fix it.  Do you have any suggestion?
> >
> > Thank you very much in advance,
> >
> > SH
> >
>
> --
> Sarah Goslee
> http://www.functionaldiversity.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.


Re: [R] data import: strange experience

2013-08-21 Thread David Carlson
This is not really enough information to diagnose the problem.
What are the missing factor levels? Were the missing levels
combined with another level or do you have missing values (NA)
for those observations? Do the extra factor levels include
embedded commas? There are differences between read.table and
read.csv in the default quote= and comment.char= arguments.

-
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of SH
Sent: Wednesday, August 21, 2013 9:36 AM
To: r-help@r-project.org
Subject: [R] data import: strange experience

Dear List:

I had some strange experience in importing data.  I wonder if
anyone of you
had the same problem before and would greatly appreciate your
suggestion in
advance.

The original data set in excel format.

Here is a brief summary of the procedure I did:
1. I saved the original excel data as csv and txt formats,
separately.
2. I imported two data using the following codes.  There were no
error
messages.
dftxt = read.table('df.txt',header=T, sep='\t')
dfcsv = read.csv('df.csv',header=T, sep=',')
3. When I checked data with 'str', I found that factor levels of
a variable
were different each other.
Levels of dftxt were less than those of dfcsv (48 vs 52).
4. So, I checked 'df.txt' file and found that the missing levels
were still
there, i.e., there is a no problem in text file.  I suspect that
something
happened when I imported it into R.

Since there was no errors in importing the file into R, I do not
have an
idea where to start to fix it.  Do you have any suggestion?

Thank you very much in advance,

SH

[[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] Bringing tk_choose.files to front

2013-08-21 Thread mmiikkii
Dear Jimbo,

 

Unfortunately I got no answer to this problem so I decided to put the
instructions in user manual for the program I am writing...not the best
solution, but I cannot think of anything better. 

 

If you find out how to solve this in a better way, please share the
knowledge.

 

Best

Miki

 

From: jimbo616 [via R] [mailto:ml-node+s789695n4673676...@n4.nabble.com] 
Sent: Tuesday, August 13, 2013 10:04 PM
To: mmiikkii
Subject: Re: Bringing tk_choose.files to front

 



I have this same problem-- the file browser window opens behind RStudio with
no indication to the user that it is there.  Did you ever find a solution to
make it open as a top level window in front of RStudio? 

mmiikkii wrote

I want to make a script in R (I use RStudio if it matters) in which the user
chooses the initial data file interactively using tk_choose.files 

the code goes like this: 
 
library(tcltk) 
library(foreign) 

fname1<-tk_choose.files(default = "", caption = "Choose original file",multi
= FALSE, filters = NULL, index = 1) 
x1<-read.spss(fname1, use.value.labels=FALSE, to.data.frame=TRUE,
use.missings=FALSE) 
- 

however, it pops out a new window behind the RStudio window. 

How can I make it pop out as top level window (in front of everything)? 

Thank you for helping. 

 

  _  

If you reply to this email, your message will be added to the discussion
below:

http://r.789695.n4.nabble.com/Bringing-tk-choose-files-to-front-tp4657938p46
73676.html 

To unsubscribe from Bringing tk_choose.files to front, click here
 .
 
 NAML 





--
View this message in context: 
http://r.789695.n4.nabble.com/Bringing-tk-choose-files-to-front-tp4657938p4674217.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] data import: strange experience

2013-08-21 Thread peter dalgaard

On Aug 21, 2013, at 16:46 , Sarah Goslee wrote:

> Hi,
> 
> We don't know anything about your data or your file, so it's utterly
> impossible to offer useful suggestions.
> 
> The very best thing you can do is condense your problem into a
> reproducible example, with fake data if necessary. Otherwise you're
> limited by the ability of the list to guess what you're looking at,
> and our track record with that is spotty.
> 

Yes. That being said, though, try read.delim() instead of read.table. Various 
options are set differently.

-pd


> 
> Sarah
> 
> On Wed, Aug 21, 2013 at 10:35 AM, SH  wrote:
>> Dear List:
>> 
>> I had some strange experience in importing data.  I wonder if anyone of you
>> had the same problem before and would greatly appreciate your suggestion in
>> advance.
>> 
>> The original data set in excel format.
>> 
>> Here is a brief summary of the procedure I did:
>> 1. I saved the original excel data as csv and txt formats, separately.
>> 2. I imported two data using the following codes.  There were no error
>> messages.
>> dftxt = read.table('df.txt',header=T, sep='\t')
>> dfcsv = read.csv('df.csv',header=T, sep=',')
>> 3. When I checked data with 'str', I found that factor levels of a variable
>> were different each other.
>> Levels of dftxt were less than those of dfcsv (48 vs 52).
>> 4. So, I checked 'df.txt' file and found that the missing levels were still
>> there, i.e., there is a no problem in text file.  I suspect that something
>> happened when I imported it into R.
>> 
>> Since there was no errors in importing the file into R, I do not have an
>> idea where to start to fix it.  Do you have any suggestion?
>> 
>> Thank you very much in advance,
>> 
>> SH
>> 
> 
> -- 
> 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.

-- 
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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Filter Dataframe for Alarm for particular column(s).

2013-08-21 Thread R_Antony
Ok. I got it. 

 

From: Akkara, Antony (GE Energy, Non-GE) 
Sent: Wednesday, August 21, 2013 3:52 PM
To: 'arun kirshna [via R]'
Subject: RE: Filter Dataframe for Alarm for particular column(s).

 

What will be the code, if we required all the row number ?

 

Thanks,

Antony.

 

From: arun kirshna [via R] [mailto:ml-node+s789695n467097...@n4.nabble.com] 
Sent: Saturday, July 06, 2013 12:54 AM
To: Akkara, Antony (GE Power & Water, Non-GE)
Subject: Re: Filter Dataframe for Alarm for particular column(s).

 

Hi, 
May be this helps: 
If you had showed your solution, it would be easier to compare. 

res<-data.frame(lapply(sapply(MyDF[,c(2,4)],function(x) 
{x1<-which(c(0,diff(x))<0);x1[length(x1)==0]<-0;x1}),`[`,1)) 
 res 
#  TNH BIX 
#1   3   9 


#Speed 

 set.seed(24) 
 MyDFNew<- 
data.frame(TNH=sample(0:1,1e6,replace=TRUE),BIX=sample(0:1,1e6,replace=TRUE)) 
system.time(res1<-data.frame(lapply(sapply(MyDFNew,function(x) 
{x1<-which(c(0,diff(x))<0);x1[length(x1)==0]<-0;x1}),`[`,1))) 
#   user  system elapsed 
#  0.364   0.000   0.363 

 res1 
#  TNH BIX 
#1   7   2 
 MyDFNew[1:10,] 
#   TNH BIX 
#10   1 
#20   0 
#31   1 
#41   1 
#51   0 
#61   0 
#70   1 
#81   1 
#91   1 
#10   0   0 


A.K. 


Hi, 


Hi here i have a dataframe called MyDF. 

a<-c(1,1,1,1,1,0,0,0,1,1) 
b<-c(1,1,0,1,1,0,0,0,1,1) 
c<-c(1,1,1,1,1,1,1,0,1,1) 
d<-c(1,1,1,1,1,1,1,1,0,1) 
MyDF<-data.frame(DWATT=a,TNH=b,CSGV=c,BIX=d) 

My requirement is, here i need a function - to get for a 
particular row number(s), when particular column(s) value change from 
one-to-zero  (for the first change). Suppose there is no change is 
happening then it should return "Zero" 

For example,  Using MyDF, 

DWATT TNH CSGV BIX 
1   11   1 
1   11   1 
1   01   1 
1   11   1 
1   11   1 
0   01   1 
0   01   1 
0   00   1 
1   11   0 
1   11   1 

Here i want to know, the row number where TNH-column and BIX-column values 
change happening from one-to-zero for the first time. 

Note:- Suppose there is no change is happening then it should return "Zero" 

Answer should be  a dataframe with single row. 
So here answer should return a dataframe like this. 

TNH  BIX 
-- 
3  9 


i used some ways to get a solution using loops. But there is a bulk files with 
bulk rows to process. 
So performace is most important. Could someone please suggest better ideas ? 

Thanks, 
Antony. 

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



If you reply to this email, your message will be added to the discussion below:

http://r.789695.n4.nabble.com/Filter-Dataframe-for-Alarm-for-particular-column-s-tp4670950p4670970.html
 

To unsubscribe from Filter Dataframe for Alarm for particular column(s)., click 
here 

 .
NAML 

  





--
View this message in context: 
http://r.789695.n4.nabble.com/Filter-Dataframe-for-Alarm-for-particular-column-s-tp4670950p4674212.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] lattice: bwplot: getting two plots into one.

2013-08-21 Thread Anna Zakrisson Braeunlich
Dear all,

I have problems gettting the following as one graph instead of the two created 
by this script. I know that with this dummy data, the resulting graph will look 
like a catastrophy. I have other data I wish to apply this too. Just wanted to 
supply some dummy data to work with.
There may be unnecessary code below. I am still learning.

Is it possible to do two different bwplots from different dataframes and then 
superpose them on to each other?
with kind regards

A. Zakrisson

mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)), #Dummy data
factor2 = factor(rep(c(1:2), each = 16)),
var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
 sd = rep(c(1, 2, 3), each = 20)))

font.settings <- list( font = 1, cex = 1.3, fontfamily = "serif")

my.theme <- list(
  box.umbrella = list(col = "black"), #Color of deviation lines (95%)
  box.rectangle = list(col="black"),  #Color of the line around the box
  box.dot = list(col = "black", pch = 3, lty=2, lwd=5, cex=1.3),
  plot.symbol   = list(cex = 1, col = 1, pch= 0), #outlier size and color
  par.xlab.text = font.settings,
  mfrow=c(2,2),
  par.ylab.text = font.settings,
  axis.line=list(col="black"), #Set "transparent if no axes
  axis.text = font.settings,
  strip.shingle=list(col=c("white","white")),
  superpose.symbol=list(fill=c("white","white")), # boxplots
  superpose.fill=list(col=c("white","white")),
  superpose.polygon=list(col=c("white","white")), # legend
  par.sub=font.settings)

bgColors <- c("white", "white", "white")
txtColors <- c("black", "black", "black")
myStripStyle <- function(which.panel, factor.levels, par.strip.text,
 custBgCol=par.strip.text$custBgCol,
 custTxtCol=par.strip.text$custTxtCol,...) {
  par.settings = list(layout.heights=list(strip=3))
  panel.rect(0, 0, 1, 1,
 col = custBgCol[which.panel],
 border = 1.2)
  panel.text(x = 0.5, y = 0.5,
 font=1,
 fontfamily = "serif",
 cex=1.4,
 lab = factor.levels[which.panel],
 col = custTxtCol[which.panel])
}

bwplot(var1 ~ factor1|factor2, data = mydata,
   groups=factor2,
   box.width = 1/3,#width of the boxes
   panel=panel.superpose,
   ylab = expression(paste("",delta^{15}, "N")),
   xlab="Station",
   par.settings = my.theme,
   par.strip.text=list(custBgCol=bgColors,
   custTxtCol=txtColors),
   strip=myStripStyle,
   scales = list(alternating = TRUE,
 x = list(relation = "same", rot=45),
 y = list(relation = "same")),
   panel.groups = function(x, y, ..., group.number) {
 panel.bwplot(x + (group.number-1.8)/3, y, ...)
   })
trellis.focus("panel", 1, 1)
panel.abline(h=0, lty=2)  #lwd
trellis.unfocus()
trellis.focus("panel", 2, 1)
panel.abline(h=0, lty=2)  #lwd
trellis.unfocus()


Anna Zakrisson Braeunlich
PhD student

Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

><º>`•. . • `•. .• `•. . ><º>`•. . • `•. .• `•. .><º>`•. . • `•. .• 
>`•. .><º>

[[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] Filter Dataframe for Alarm for particular column(s).

2013-08-21 Thread R_Antony
What will be the code, if we required all the row number ?

 

Thanks,

Antony.

 

From: arun kirshna [via R] [mailto:ml-node+s789695n467097...@n4.nabble.com] 
Sent: Saturday, July 06, 2013 12:54 AM
To: Akkara, Antony (GE Power & Water, Non-GE)
Subject: Re: Filter Dataframe for Alarm for particular column(s).

 

Hi, 
May be this helps: 
If you had showed your solution, it would be easier to compare. 

res<-data.frame(lapply(sapply(MyDF[,c(2,4)],function(x) 
{x1<-which(c(0,diff(x))<0);x1[length(x1)==0]<-0;x1}),`[`,1)) 
 res 
#  TNH BIX 
#1   3   9 


#Speed 

 set.seed(24) 
 MyDFNew<- 
data.frame(TNH=sample(0:1,1e6,replace=TRUE),BIX=sample(0:1,1e6,replace=TRUE)) 
system.time(res1<-data.frame(lapply(sapply(MyDFNew,function(x) 
{x1<-which(c(0,diff(x))<0);x1[length(x1)==0]<-0;x1}),`[`,1))) 
#   user  system elapsed 
#  0.364   0.000   0.363 

 res1 
#  TNH BIX 
#1   7   2 
 MyDFNew[1:10,] 
#   TNH BIX 
#10   1 
#20   0 
#31   1 
#41   1 
#51   0 
#61   0 
#70   1 
#81   1 
#91   1 
#10   0   0 


A.K. 


Hi, 


Hi here i have a dataframe called MyDF. 

a<-c(1,1,1,1,1,0,0,0,1,1) 
b<-c(1,1,0,1,1,0,0,0,1,1) 
c<-c(1,1,1,1,1,1,1,0,1,1) 
d<-c(1,1,1,1,1,1,1,1,0,1) 
MyDF<-data.frame(DWATT=a,TNH=b,CSGV=c,BIX=d) 

My requirement is, here i need a function - to get for a 
particular row number(s), when particular column(s) value change from 
one-to-zero  (for the first change). Suppose there is no change is 
happening then it should return "Zero" 

For example,  Using MyDF, 

DWATT TNH CSGV BIX 
1   11   1 
1   11   1 
1   01   1 
1   11   1 
1   11   1 
0   01   1 
0   01   1 
0   00   1 
1   11   0 
1   11   1 

Here i want to know, the row number where TNH-column and BIX-column values 
change happening from one-to-zero for the first time. 

Note:- Suppose there is no change is happening then it should return "Zero" 

Answer should be  a dataframe with single row. 
So here answer should return a dataframe like this. 

TNH  BIX 
-- 
3  9 


i used some ways to get a solution using loops. But there is a bulk files with 
bulk rows to process. 
So performace is most important. Could someone please suggest better ideas ? 

Thanks, 
Antony. 

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





If you reply to this email, your message will be added to the discussion below:

http://r.789695.n4.nabble.com/Filter-Dataframe-for-Alarm-for-particular-column-s-tp4670950p4670970.html
 

To unsubscribe from Filter Dataframe for Alarm for particular column(s)., click 
here 

 .
NAML 

  





--
View this message in context: 
http://r.789695.n4.nabble.com/Filter-Dataframe-for-Alarm-for-particular-column-s-tp4670950p4674211.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] data import: strange experience

2013-08-21 Thread Sarah Goslee
Hi,

We don't know anything about your data or your file, so it's utterly
impossible to offer useful suggestions.

The very best thing you can do is condense your problem into a
reproducible example, with fake data if necessary. Otherwise you're
limited by the ability of the list to guess what you're looking at,
and our track record with that is spotty.


Sarah

On Wed, Aug 21, 2013 at 10:35 AM, SH  wrote:
> Dear List:
>
> I had some strange experience in importing data.  I wonder if anyone of you
> had the same problem before and would greatly appreciate your suggestion in
> advance.
>
> The original data set in excel format.
>
> Here is a brief summary of the procedure I did:
> 1. I saved the original excel data as csv and txt formats, separately.
> 2. I imported two data using the following codes.  There were no error
> messages.
> dftxt = read.table('df.txt',header=T, sep='\t')
> dfcsv = read.csv('df.csv',header=T, sep=',')
> 3. When I checked data with 'str', I found that factor levels of a variable
> were different each other.
> Levels of dftxt were less than those of dfcsv (48 vs 52).
> 4. So, I checked 'df.txt' file and found that the missing levels were still
> there, i.e., there is a no problem in text file.  I suspect that something
> happened when I imported it into R.
>
> Since there was no errors in importing the file into R, I do not have an
> idea where to start to fix it.  Do you have any suggestion?
>
> Thank you very much in advance,
>
> SH
>

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

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


[R] data import: strange experience

2013-08-21 Thread SH
Dear List:

I had some strange experience in importing data.  I wonder if anyone of you
had the same problem before and would greatly appreciate your suggestion in
advance.

The original data set in excel format.

Here is a brief summary of the procedure I did:
1. I saved the original excel data as csv and txt formats, separately.
2. I imported two data using the following codes.  There were no error
messages.
dftxt = read.table('df.txt',header=T, sep='\t')
dfcsv = read.csv('df.csv',header=T, sep=',')
3. When I checked data with 'str', I found that factor levels of a variable
were different each other.
Levels of dftxt were less than those of dfcsv (48 vs 52).
4. So, I checked 'df.txt' file and found that the missing levels were still
there, i.e., there is a no problem in text file.  I suspect that something
happened when I imported it into R.

Since there was no errors in importing the file into R, I do not have an
idea where to start to fix it.  Do you have any suggestion?

Thank you very much in advance,

SH

[[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] Narrowing values collected from .txt file

2013-08-21 Thread Morway, Eric
useRs-

The output generated from a groundwater model post-processor contains
millions of lines of text.  Using the custom R function shown below, I can
quickly gather values from this file.

As you can see in the textConnection provided below (which is only a small
snippet from the file), the output is repetitive but does have some header
lines I hope to make use of to narrow the collected output.  The header
lines I'm speaking of are:
1) " Flow Budget for Zone  1 at Time Step   1 of Stress Period   2"
2) " Flow Budget for Zone  2 at Time Step   1 of Stress Period   2"
3) " Flow Budget for Zone  3 at Time Step   1 of Stress Period   2"
4) " Flow Budget for Zone  1 at Time Step   1 of Stress Period   3"
...

and so on for 111 different "zones" as well as 575 distinct "stress
periods".  In the custom function that follows, currently named "g", I can
collect all values of "Recharge".  If instead I want to restrict the
collected "Recharge" values to "Zone 2" for all 575 stress periods, is
there a way to first look for the header "Flow Budget for Zone  2", collect
only the next two values of Recharge, and then skip down to the next header
containing "Zone 2", collect 2 more values of "Recharge", and on like this
to the end?  'Peeling' out targeted flow budget terms will facilitate
generation of budget-specific plots through time.

The "edm" variable at the end of the R code that follows currently looks
like this:
edm
# [1] 1.28980e+05 0.0e+00 *2.74161e-01* 0.0e+00 8.10840e+04
0.0e+00
# [7] 1.28980e+05 0.0e+00 *2.74165e-01* 0.0e+00 8.10840e+04
0.0e+00

but with the proposed revision, which only collects Recharge values from
Zone 2, it would look like:
edm
# [1] *2.74161e-01* 0.0e+00 *2.74165e-01* 0.0e+00


txt_con<-textConnection(" mark_zone


 Flow Budget for Zone  1 at Time Step   1 of Stress Period   2
 -

   Budget Term Flow (L**3/T)
   -

 IN:
 ---
   STORAGE =   0.37855E-02
 CONSTANT HEAD =0.
  RECHARGE =   0.12898E+06
STREAM LEAKAGE =0.
 LAKE  SEEPAGE =0.
UZF ET =0.
 GW ET =0.
  UZF INFILTR. =0.
  SFR-DIV. INFLTR. =0.
  UZF RECHARGE =0.
   SURFACE LEAKAGE =0.
   Zone  16 to   1 =0.
   Zone  31 to   1 =0.
   Zone  40 to   1 =0.
   Zone  91 to   1 =0.

  Total IN =   0.12898E+06

 OUT:
 
   STORAGE =   0.58275E-04
 CONSTANT HEAD =0.
  RECHARGE =0.
STREAM LEAKAGE =0.
 LAKE  SEEPAGE =0.
UZF ET =0.
 GW ET =0.
  UZF INFILTR. =0.
  SFR-DIV. INFLTR. =0.
  UZF RECHARGE =0.
   SURFACE LEAKAGE =0.
   Zone   1 to  16 =399.88
   Zone   1 to  31 =85204.
   Zone   1 to  40 =12404.
   Zone   1 to  91 =30968.

 Total OUT =   0.12898E+06

  IN - OUT =   0.14138E-03

   Percent Discrepancy =0.00
1
 mark_zone


 Flow Budget for Zone  2 at Time Step   1 of Stress Period   2
 -

   Budget Term Flow (L**3/T)
   -

 IN:
 ---
   STORAGE =   0.18833E-05
 CONSTANT HEAD =0.
  RECHARGE =   0.274161E+06
STREAM LEAKAGE =0.
 LAKE  SEEPAGE =0.
UZF ET =0.
 GW ET =0.
  UZF INFILTR. =0.
  SFR-DIV. INFLTR. =0.
  UZF RECHARGE =0.
   SURFACE LEAKAGE =0.
   Zone  15 to   2 =0.
   Zone  31 to   2 =0.
   Zone  91 to   2 =13134.

  Total IN =   0.28729E+06

 OUT:
 
   STORAGE =   0.10823E-04
 CONSTANT HEAD =0.
  RECHARGE =0.
STREAM LEAKAGE =0

Re: [R] Rmpi unable to load

2013-08-21 Thread Prof Brian Ripley
I think you need to ask whoever installed Rmpi on your machine or 
provided a binary package: CRAN does not distribute a Windows binary, 
and one reason is that Rmpi has to be compiled against a specific MPI 
installation.


Or ask the package maintainer, as the posting guide suggested.  In any 
case, R-devel would have been more appropriate: this is about non-R 
programming.  See also http://www.stats.uwo.ca/faculty/yu/Rmpi/windows.htm



On 21/08/2013 13:18, Stephen Clark wrote:

Hello,

I am trying to run the optimise_ppso_robust parallel swarm optimisation 
function in R3.0.0 on a 6 core AMD Windows 8 64bit PC. To do this I need to 
load the Rmpi package. When I do this I get the following message in a dialogue 
box:

The program can't start because mpich2mpi.dll is missing from your computer. 
Try installing the program to fix this problem.

Additionally in the R console it says:

Error : .onLoad failed in loadNamespace() for 'Rmpi', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object 'C:/Program 
Files/R/R-3.0.0/library/Rmpi/libs/x64/Rmpi.dll':
   LoadLibrary failure:  The specified module could not be found.

In addition: Warning message:
package 'Rmpi' was built under R version 3.0.1
Error: package or namespace load failed for 'Rmpi'

I have checked and there is a Rmpi.dll file in the specified directory.


So you have misread the message.  It does not say 'Rmpi.dll could not be 
found': if you choose to use Windows you should be used to its arcane 
messages.  It means 'some DLL etc needed could not be found' and on 
recent versions of Windows there is usually a message box about one of them.




To try and solve this problem I have tried installing mpich2 from here 
http://www.mpich.org/downloads/ (both the Windows Team "version" and the Jayesh Krishna 
"version"). I can then get the cpi.exe test program running on multi-cores in a command 
windows.

Has anyone got package Rmpi to install under Windows 8 without my error 
messages and how did they do this?

Thanks.

--
Stephen Clark,
Second year PhD,  School of Geography
Tel : 0113 343 6707
Email : g...@leeds.ac.uk
Web : http://www.geog.leeds.ac.uk/people/s.clark


[[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,  rip...@stats.ox.ac.uk
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] Rmpi unable to load

2013-08-21 Thread Stephen Clark
Hello,

I am trying to run the optimise_ppso_robust parallel swarm optimisation 
function in R3.0.0 on a 6 core AMD Windows 8 64bit PC. To do this I need to 
load the Rmpi package. When I do this I get the following message in a dialogue 
box:

The program can't start because mpich2mpi.dll is missing from your computer. 
Try installing the program to fix this problem.

Additionally in the R console it says:

Error : .onLoad failed in loadNamespace() for 'Rmpi', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Program 
Files/R/R-3.0.0/library/Rmpi/libs/x64/Rmpi.dll':
  LoadLibrary failure:  The specified module could not be found.

In addition: Warning message:
package 'Rmpi' was built under R version 3.0.1
Error: package or namespace load failed for 'Rmpi'

I have checked and there is a Rmpi.dll file in the specified directory.

To try and solve this problem I have tried installing mpich2 from here 
http://www.mpich.org/downloads/ (both the Windows Team "version" and the Jayesh 
Krishna "version"). I can then get the cpi.exe test program running on 
multi-cores in a command windows.

Has anyone got package Rmpi to install under Windows 8 without my error 
messages and how did they do this?

Thanks.

--
Stephen Clark,
Second year PhD,  School of Geography
Tel : 0113 343 6707
Email : g...@leeds.ac.uk
Web : http://www.geog.leeds.ac.uk/people/s.clark


[[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] Visualising SOM as hexagonal heatmaps

2013-08-21 Thread Roger Bivand
Adam Szałucha  gmail.com> writes:

> 
> I have a kohonen object generated with grid parameters grid =
> somgrid(20, 20, "hexagonal"). Standard plot shows the codebook vectors
> for all variables. I want to have a hexagonal heatmap for each
> variable.
> 
> I found in Applied Spatial Data Analysis with R code to generate hexagonal
grid.
> 
...
> But there are some problems. Firstly the line
...
> Why does it happen?


Please consider posting on R-sig-geo, where a response may be easier to elicit.

> 
> Thanks
> Adam Szałucha
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] bootstrap from binary confidence intervals (Hmisc binconf)

2013-08-21 Thread Folkes, Michael
Hello all,
I've generated a series of CI's of proportions from numerous samples using 
Hmisc binconf().
Now I wish to bootstrap from those values for some additional products. (ie 
sample to get a proportion, multiply that proportion with another number). We 
know it's not normally distributed. How can I represent these data for 
bootstrapping?

Much appreciated.
Michael

___
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans 
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053  michael.fol...@dfo-mpo.gc.ca


[[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] Confidence Intervals for survreg (survival)

2013-08-21 Thread Luis Antunes
Very simple, indeed.
Thank you very much for your help.
Luis


> Subject: Re: [R] Confidence Intervals for survreg (survival)
> From: dwinsem...@comcast.net
> Date: Tue, 20 Aug 2013 11:50:52 -0700
> CC: r-help@r-project.org
> To: ljantu...@hotmail.com
> 
> 
> On Aug 20, 2013, at 7:04 AM, Luis Antunes wrote:
> 
> > Hello,
> > I am fitting a weibull regression model to a survival data set, using 
> > survreg from the survival package.I would like to obtain the confidence 
> > interval for the regression coefficients estimates, but I not seeing 
> > how.Can anyone help me?
> 
> ?summary.survreg
> ?confint
> 
> Basically any regression object returned with list components 'coefficients' 
> (actually with a coef()-method)  and 'var' can be passed to confint.
> -- 
> David Winsemius
> Alameda, CA, USA
> 
  
[[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.