Re: [R] How can I draw a 3D diagram (persp) with these Infos

2013-09-24 Thread Pascal Oettli
Hello,

This request looks very similar to:

http://stackoverflow.com/questions/18982662/showing-a-3d-diagram-in-r
http://stackoverflow.com/questions/18913143/non-numeric-argument-error-while-running-fft-on-a-matrix

Regards,
Pascal


2013/9/25 Babak Bastan 

> I want to have a 3D diagramm. My Information are:
>
>- x:Time - it could be 1:n (integer number)
>- Y:Frequency ---it could be 1:n like x
>
> z:the value of z come from a function
>
> *fft_amplitude <- function(x) {sqrt((Re(fft(x)))^2+(Im(fft(x)))^2)}*
>
> **
>
> The input values for this function should be read from a CSV file. How can
> I draw a 3D diagram* *perspwith this infos?
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

[[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] How can I draw a 3D diagram (persp) with these Infos

2013-09-24 Thread Babak Bastan
I want to have a 3D diagramm. My Information are:

   - x:Time - it could be 1:n (integer number)
   - Y:Frequency ---it could be 1:n like x

z:the value of z come from a function

*fft_amplitude <- function(x) {sqrt((Re(fft(x)))^2+(Im(fft(x)))^2)}*

**

The input values for this function should be read from a CSV file. How can
I draw a 3D diagram* *perspwith this infos?

[[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] failure to replayPlot() a recordedplot object saved in a previous session?

2013-09-24 Thread Gergely Daróczi
It might worth checking out this nice workaround of JJ:
https://github.com/Rapporter/pander/blob/master/R/evals.R#L1135

Best,
Gergely


On 25 September 2013 02:35, Paul Murrell  wrote:

> Hi
>
> Attempting to use a display list snapshot (as created by recordPlot())
> between R sessions has always been strongly discouraged, but as of about R
> 3.0.0 it has become impossible (due to internal changes, which was part of
> the reason for strongly discouraging this in the first place).
>
> Sorry to be the bearer of bad news.
>
> Paul
>
> On 09/13/13 10:54, MacQueen, Don wrote:
>
>> I have the following experience.
>>
>> If I use, for example,
>> tmp <-  recordPlot()
>> in a session, then immediately the saved plot replays successfully using
>> replayPlot()
>> in the same session. But not in the next R session. See examples below,
>> copy/pasted from my shell window.
>>
>> The first R session is brand new; no saved objects left over from a
>> previous session.
>>
>> I also have the same experience with R 3.0.1 patched on a linux machine
>> (RHEL).
>>
>>
>> Is this a known or expected behavior?
>>
>> Thanks
>> -Don
>>
>>
>>  R session #1
>>
>> mydir[42]% R
>>
>> R version 3.0.1 Patched (2013-08-13 r63562) -- "Good Sport"
>> Copyright (C) 2013 The R Foundation for Statistical Computing
>> Platform: x86_64-apple-darwin10.8.0 (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.
>>
>>Natural language support but running in an English locale
>>
>> 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.
>>
>>
>>> x11()
>>> plot(1:2)
>>> tmp <- recordPlot()
>>> replayPlot(tmp)
>>> q()
>>>
>> Save workspace image? [y/n/c]: y
>>
>>
>>
>>
>>  R session #2
>>
>>
>> mydir[43]% R
>>
>> R version 3.0.1 Patched (2013-08-13 r63562) -- "Good Sport"
>> Copyright (C) 2013 The R Foundation for Statistical Computing
>> Platform: x86_64-apple-darwin10.8.0 (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.
>>
>>Natural language support but running in an English locale
>>
>> 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.
>>
>> [Previously saved workspace restored]
>>
>>  ls()
>>>
>> [1] "tmp"
>>
>>> class(tmp)
>>>
>> [1] "recordedplot"
>>
>>> x11()
>>> replayPlot(tmp)
>>>
>> Error: NULL value passed as symbol address
>>
>>>
>>> sessionInfo()
>>>
>> R version 3.0.1 Patched (2013-08-13 r63562)
>> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>>
>> locale:
>> [1] C
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>>>
>>>
>>
>>
>>
> --
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> p...@stat.auckland.ac.nz
> http://www.stat.auckland.ac.**nz/~paul/
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/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] fit a time varying coefficient log linear model in r

2013-09-24 Thread David Winsemius


On Sep 24, 2013, at 3:33 PM, shanxiao wrote:


Hello, all,



Does anyone know any package in r to fit a log linear model with time
varying coefficients in R? I have googled but with no results. Your  
help

will be appreciated. J



Perhaps glm (in the default stats package)  with an offset of log(time)?

--

David Winsemius, MD
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] Graph is without line

2013-09-24 Thread mohan . radhakrishnan
Hi,
 Yes. It worked. Is 'stringAsFactors=FALSE' the switch to use 
when reading data into a frame ? All the values I use are either numbers 
or dates or strings. Sometimes while I manipulate the data by filtering, 
the values seem to become factors ?

Thanks,
Mohan



From:   Jim Lemon 
To: mohan.radhakrish...@polarisft.com
Cc: r-help@r-project.org
Date:   09/25/2013 05:56 AM
Subject:Re: [R] Graph is without line



On 09/24/2013 10:46 PM, mohan.radhakrish...@polarisft.com wrote:
> Hi,
>  Sometimes I get a graph like the attached one. The data type 
could
> have something to do with it. This graph does not use the color and does
> not draw
> a line. Earlier I used to convert the factors in the data frame to 
another
> data type and drew the correct graphs.
>
> Any idea why this happens ?
>
> Thanks,
> Mohan
>
>  Var1 Freq
> 1 10.1.17.10  205
> 2 10.1.17.15  216
> 3 10.1.17.17   79
> 4 10.1.17.23   76
> 5 10.1.17.24  209
> 6  10.1.17.5  244
> 7  10.1.17.6  178
> 8  10.1.17.7  165
> 9  10.1.17.8  146
>
>
>
> #prints factor
> print(class(data$Var1))
>
> 
plot(data$Var1,data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
> title("Estimation of concurrent connections",cex.main=3)
> library(plotrix)
> staxlab(at=data$Var1,
>labels=as.character(data$Var1),nlines=3,srt=90)
>
Hi Mohan,
If you pass a factor as the "x" value to plot, it assumes that the 
values of the factor are nominal or at best ordinal and does not try to 
connect them into a metric scale. You can get a "line" with:

plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col="green",type="o",
  ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
...

but think carefully about whether this means anything sensible.

Jim




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.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] Checking a large data set for normality

2013-09-24 Thread David Winsemius


On Sep 24, 2013, at 11:44 AM, steric wrote:


Hello,

I have a large data set that includes many soil parameters (i.e. pH,  
calcium
levels, enzyme activity, etc) Does anyone have any input as to the  
easiest
way to check a large data set for normality? Is there an R function/ 
package

that can do this all at once?



This raises the question about why one should be doing this. There is  
quite a bit of misinformation about the "need for normality", some of  
it presented by Six Sigma "experts" or even by college professors who  
should know better. One might even say that if you don't know how to  
check for normality then there is a high likelihood that you should  
not be doing so.


--
David Winsemius, MD
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] object not found in a cca analysis with vegan package

2013-09-24 Thread Pascal Oettli
Hello,

It is kindly requested to post in plain text. HTML is prohibited.

Your data are stored in "abondance.txt", not in "abondance".

Hope this helps,
Pascal



2013/9/25 Pierre Paradis 

> I'm a beginner, trying to do a canonical correspondance analysis with the
> vegan package, but I come up with that : > library(vegan) > abondance.txt
> <- read.table("C:/Users/abondance.txt",header=T,sep="\t") > abondance <-
> cca(abondance[,-c(1,2)]~altitude, data=abondance, nhea) Error in
> model.frame(data = abondance, na.action = function (object,  :   object
> 'abondance' not found any ideas ? thanks !
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

[[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] failure to replayPlot() a recordedplot object saved in a previous session?

2013-09-24 Thread Paul Murrell

Hi

Attempting to use a display list snapshot (as created by recordPlot()) 
between R sessions has always been strongly discouraged, but as of about 
R 3.0.0 it has become impossible (due to internal changes, which was 
part of the reason for strongly discouraging this in the first place).


Sorry to be the bearer of bad news.

Paul

On 09/13/13 10:54, MacQueen, Don wrote:

I have the following experience.

If I use, for example,
tmp <-  recordPlot()
in a session, then immediately the saved plot replays successfully using
replayPlot()
in the same session. But not in the next R session. See examples below,
copy/pasted from my shell window.

The first R session is brand new; no saved objects left over from a
previous session.

I also have the same experience with R 3.0.1 patched on a linux machine
(RHEL).


Is this a known or expected behavior?

Thanks
-Don


 R session #1

mydir[42]% R

R version 3.0.1 Patched (2013-08-13 r63562) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (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.

   Natural language support but running in an English locale

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.



x11()
plot(1:2)
tmp <- recordPlot()
replayPlot(tmp)
q()

Save workspace image? [y/n/c]: y




 R session #2


mydir[43]% R

R version 3.0.1 Patched (2013-08-13 r63562) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (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.

   Natural language support but running in an English locale

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.

[Previously saved workspace restored]


ls()

[1] "tmp"

class(tmp)

[1] "recordedplot"

x11()
replayPlot(tmp)

Error: NULL value passed as symbol address


sessionInfo()

R version 3.0.1 Patched (2013-08-13 r63562)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] C

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








--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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


[R] fit a time varying coefficient log linear model in r

2013-09-24 Thread shanxiao
Hello, all, 

 

Does anyone know any package in r to fit a log linear model with time
varying coefficients in R? I have googled but with no results. Your help
will be appreciated. J

 

Shan Xiao

Ph.D. student of Biostatistics, 

Department of Biostatistics, IUPUI.

 


[[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] object not found in a cca analysis with vegan package

2013-09-24 Thread Pierre Paradis
I'm a beginner, trying to do a canonical correspondance analysis with the vegan 
package, but I come up with that : > library(vegan) > abondance.txt <- 
read.table("C:/Users/abondance.txt",header=T,sep="\t") > abondance <- 
cca(abondance[,-c(1,2)]~altitude, data=abondance, nhea) Error in 
model.frame(data = abondance, na.action = function (object,  :   object 
'abondance' not found any ideas ? thanks !  

[[alternative HTML version deleted]]

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


Re: [R] adjust scale of x-axis to unequal intervals

2013-09-24 Thread Jim Lemon

On 09/25/2013 01:56 AM, Sagan Friant wrote:

Thank you!  This worked beautifully.  Can you help me adapt the code to
do the same thing for a plot of means? The application is not a simple
as I hoped...

plotMeans(rich.small$ALL, rich.small$sample, error.bars="se")
...


Hi Sagan,
Let's see, plotMeans is in the Rcmdr package. After installing it, I 
couldn't get it to plot, but upon exiting the Rcmdr window I worked out 
that the second argument (factor1) must obviously be a factor. After 
correcting this:


rich.small<-data.frame(ALL=rnorm(240,5),
 sample=factor(c(rep(0,60),rep(2,50),rep(4,40),
 rep(7,30),rep(10,30),rep(18,30

I get a plot, but I can see no way of adjusting the positions of the 
means displayed. I suggest:


plot(c(0,10,13,16,19,94),
 by(rich.small$ALL,rich.small$sample,FUN=mean),
 xaxt="n",ylim=c(4.7,5.4))
library(plotrix)
dispersion(c(0,10,13,16,19,94),
 by(rich.small$ALL,rich.small$sample,FUN=mean),
 by(rich.small$ALL,rich.small$sample,FUN=std.error))
staxlab(1,at=c(0,10,13,16,19,94),labels=c(0,2,4,7,10,18))

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] how to add a box to map plotted by a levelplot?

2013-09-24 Thread Pascal Oettli
Hello,

?panel.text
?grid.text

Regards,
Pascal


2013/9/24 Jonsson 

> Thanks.That worked fine.Is there a way to print a number like 1 inside the
> box plotted?
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-add-a-box-to-map-plotted-by-a-levelplot-tp4676815p4676825.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

[[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] Graph is without line

2013-09-24 Thread Jim Lemon

On 09/24/2013 10:46 PM, mohan.radhakrish...@polarisft.com wrote:

Hi,
 Sometimes I get a graph like the attached one. The data type could
have something to do with it. This graph does not use the color and does
not draw
a line. Earlier I used to convert the factors in the data frame to another
data type and drew the correct graphs.

Any idea why this happens ?

Thanks,
Mohan

 Var1 Freq
1 10.1.17.10  205
2 10.1.17.15  216
3 10.1.17.17   79
4 10.1.17.23   76
5 10.1.17.24  209
6  10.1.17.5  244
7  10.1.17.6  178
8  10.1.17.7  165
9  10.1.17.8  146



#prints factor
print(class(data$Var1))

plot(data$Var1,data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
title("Estimation of concurrent connections",cex.main=3)
library(plotrix)
staxlab(at=data$Var1,
   labels=as.character(data$Var1),nlines=3,srt=90)


Hi Mohan,
If you pass a factor as the "x" value to plot, it assumes that the 
values of the factor are nominal or at best ordinal and does not try to 
connect them into a metric scale. You can get a "line" with:


plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col="green",type="o",
 ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
...

but think carefully about whether this means anything sensible.

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.


[R] Confusing behaviour in data.table: unexpectedly changing variable

2013-09-24 Thread Jonathan Dushoff
I got bitten badly when a variable I created for the purpose of
recording an old set of names changed when I didn't think I was going
near it.

I'm not sure if this is a desired behaviour, or documented, or warned
about.  I read the data.table intro and the FAQ, and also ?setnames.

Ben Bolker created a minimal reproducible example:

library(data.table)
DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)
names(DT)
## [1] "x" "y" "v"

oldnames <- names(DT)
print(oldnames)
## [1] "x" "y" "v"

setnames(DT, LETTERS[1:3])
print(oldnames)
## [1] "A" "B" "C"

-- 
McMaster University Department of Biology
http://lalashan.mcmaster.ca/theobio/DushoffLab/index.php/Main_Page
https://twitter.com/jd_mathbio

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

2013-09-24 Thread Jim Lemon

On 09/25/2013 03:25 AM, Hermann Norpois wrote:

Hello,

i attached an example with two plotted vectors, respectively. And you might
see that the y and x axis are not the same scale (e.g. the third and the
last plot).

I would prefer them to be the same scale.

A toy example:

a<- c (1,2,3,4,5,6,9,20)

b<- c (0.2,0.4,0.6,1,0.5,1,1,0.1)
plot (a,b)


I would like to a have a plot with the same scales for the y and x axis.

Could you please give me a hint how it works.
thanks
Hermann


Hi Herman,
My guess is that you want the x and y scales to have the same length in 
user units and perhaps even to have the same tick positions and values. 
For the toy example:


a <- c (1,2,3,4,5,6,9,20)
b <- c (0.2,0.4,0.6,1,0.5,1,1,0.1)
plot (a,b,xlim=c(0,20),ylim=c(0,20))

Adding the solution that Bill provided:

plot (a,b,xlim=c(0,20),ylim=c(0,20),asp=1)

will ensure that the actual intervals on the x and y axes will be the same.

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] plot - scaling axis

2013-09-24 Thread William Dunlap
Use asp=1 in the plot command.  E.g.,

par(mar=c(3,1,1,1), fig=c(0,1,.5,1)) ; plot(1:10, 1:10, asp=1)
par(new=TRUE, fig=c(0,.3,0,.5)) ; plot(1:10, 1:10, asp=1)
par(new=TRUE, fig=c(0.3,1,0,.5)) ; plot(1:10, 1:10, asp=1)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Hermann Norpois
> Sent: Tuesday, September 24, 2013 10:26 AM
> To: r-help
> Subject: [R] plot - scaling axis
> 
> Hello,
> 
> i attached an example with two plotted vectors, respectively. And you might
> see that the y and x axis are not the same scale (e.g. the third and the
> last plot).
> 
> I would prefer them to be the same scale.
> 
> A toy example:
> 
> a <- c (1,2,3,4,5,6,9,20)
> > b <- c (0.2,0.4,0.6,1,0.5,1,1,0.1)
> > plot (a,b)
> 
> I would like to a have a plot with the same scales for the y and x axis.
> 
> Could you please give me a hint how it works.
> thanks
> Hermann

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

2013-09-24 Thread Hermann Norpois
Hello,

i attached an example with two plotted vectors, respectively. And you might
see that the y and x axis are not the same scale (e.g. the third and the
last plot).

I would prefer them to be the same scale.

A toy example:

a <- c (1,2,3,4,5,6,9,20)
> b <- c (0.2,0.4,0.6,1,0.5,1,1,0.1)
> plot (a,b)

I would like to a have a plot with the same scales for the y and x axis.

Could you please give me a hint how it works.
thanks
Hermann
<>__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] TwitteR package

2013-09-24 Thread Bingham-Hall, John
Hi all,

I am a beginner in R attempting to use TwitteR package to query lists of 
Twitter followers for several users. I successfully have set "nx" as an object 
assigned with the screenName I want to query but when I use the method 
"nx$getFollowerIDs(n=NULL)" it returns a list of users from my own profile 
rather than the profile assigned to nx.

Can anyone let me know how to return the list of users for a profile other than 
my own?

Thank you
--
 John
University College London


[[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] display recursive partitioning tree as a treemap?

2013-09-24 Thread Michael Friendly
The rpart and party packages, among others, calculate recursive 
partitioning trees
for regression and classification.  There are plot methods available for 
showing

various features as, well,  trees.

But trees can be displayed more compactly as treemaps, eg with the 
treemap packge,

giving a recursive partitioning of a unit rectangle.
I'm wondering if anyone has tried to map the output from rpart() or 
party::ctree() into

the form required as input for a treemap in R.

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Checking a large data set for normality

2013-09-24 Thread Simon Zehnder
Check the Jarque-Bera Test for univariate testing 
(http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/tseries/html/jarque.bera.test.html)
 and Mardia's test for multivariate testing 
(http://www.inside-r.org/packages/cran/MVN/docs/mardia.test).


On Sep 24, 2013, at 6:44 PM, steric  wrote:

> Hello,
> 
> I have a large data set that includes many soil parameters (i.e. pH, calcium
> levels, enzyme activity, etc) Does anyone have any input as to the easiest
> way to check a large data set for normality? Is there an R function/package
> that can do this all at once?
> 
> Thank you in advance,
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Checking-a-large-data-set-for-normality-tp4676858.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] [] and escaping in regular expressions

2013-09-24 Thread Bert Gunter
Ah... Thanks, Ista. Missed that typo.

-- Bert


On Tue, Sep 24, 2013 at 8:48 AM, Ista Zahn  wrote:

> On Tue, Sep 24, 2013 at 11:40 AM, Bert Gunter 
> wrote:
> > Time to spend some time with the docs!
> >
> > ?egexp
>
> Just to avoid any confusion: the documentation topic is ?regexp, not ?egexp
>
> >
> > tells you:
> >
> > ". (Only ^ - \ ] are special inside character classes.)"
> >
> > See also inline below.
> >
> > Cheers,
> > Bert
> >
> >
> > On Tue, Sep 24, 2013 at 8:30 AM, Juliet Hannah  >wrote:
> >
> >> Is it correct that one does not need to escape special characters such
> as
> >> "*" (are these
> >> properly called metacharacters) inside []. If so, what is the logic to
> >> this?
> >>
> >
> > Huh?  Are you aware that regular expressions are actually a context free
> > grammar IIRC (computer science gurus, please confirm or correct)?
> >
> >>
> >> mytest <- "he*llo"
> >> sub("[*]","",mytest)
> >> sub("\\*","",mytest)
> >>
> >> [] is easier to read for me than \\. Is this what people tend to use?
> >>
> >
> > That would require a survey to answer, would it not? Tastes vary, as they
> > say.
> >
> >
> >
> >> Thanks.
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >
> >
> > --
> >
> > Bert Gunter
> > Genentech Nonclinical Biostatistics
> >
> > Internal Contact Info:
> > Phone: 467-7374
> > Website:
> >
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[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] Checking a large data set for normality

2013-09-24 Thread steric
Hello,

I have a large data set that includes many soil parameters (i.e. pH, calcium
levels, enzyme activity, etc) Does anyone have any input as to the easiest
way to check a large data set for normality? Is there an R function/package
that can do this all at once?

Thank you in advance,





--
View this message in context: 
http://r.789695.n4.nabble.com/Checking-a-large-data-set-for-normality-tp4676858.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Installing R, R packages

2013-09-24 Thread Simon Zehnder
Had yesterday something pretty similar on the 73 installing benchmark:

Error in untar2(tarfile, files, list, exdir, restore_times) :
  incomplete block on file

The downloaded source packages are in

‘/private/var/folders/n9/zxfxcd01557dc06bf3c1njy0gn/T/RtmpkwQyuQ/downloaded_packages’
Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 247786 != reported length 474551
2: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 280942 != reported length 403808
3: In install.packages("benchmark") :
  installation of package ‘relations’ had non-zero exit status
4: In install.packages("benchmark") :
  installation of package ‘benchmark’ had non-zero exit status

Today doing the same worked perfectly.


On Sep 24, 2013, at 6:10 PM, David Winsemius  wrote:

> 
> On Sep 24, 2013, at 12:47 AM, Jeff Newmiller wrote:
> 
>> I have stopped using the Berkeley mirror, and just automatically use UCLA 
>> due to missing packages. However, I feel no compulsion to extrapolate and 
>> say that there is "some sort of corruption going on at CRAN mirrors" because 
>> it is only one data point.
> 
> I have not been having this sort of difficulty with the Berkeley mirror. 
> Never have seen this particular error. Occasionally see the mirror down on a 
> weekend, but that happens with all mirrors. (I do use Berkeley as my standard 
> mirror and I do download a relatively large number of packages especially at 
> the point where I call `update.packages`.)
> 
> 
> -- 
> David.
> 
>> Sent from my phone. Please excuse my brevity.
>> 
>> David Arnold  wrote:
>>> All,
>>> 
>>> Consider this attempt:
 install.packages("car")
>>> trying URL
>>> 'http://cran.cnr.Berkeley.edu/bin/macosx/contrib/3.0/car_2.0-19.tgz'
>>> Content type 'application/x-gzip' length 1326903 bytes (1.3 Mb)
>>> opened URL
>>> ==
>>> downloaded 1.1 Mb
>>> 
>>> car/data/Rdata.rdb: Truncated tar archive
>>> tar: Error exit delayed from previous errors.
>>> 
>>> The downloaded binary packages are in
>>> 
>>> /var/folders/qE/qEavkZWTFMmxjncuY+HnqE+++TI/-Tmp-//Rtmpnxi1hV/downloaded_packages
>>> Warning messages:
>>> 1: In download.file(url, destfile, method, mode = "wb", ...) :
>>> downloaded length 1126960 != reported length 1326903
>>> 2: 'tar' returned non-zero exit code 1
 
>>> 
>>> This seems to be happening frequently at the cran berkeley site. I've
>>> also
>>> had students try to install R from the Berkeley site and it just
>>> doesn't
>>> work for them.
>>> 
>>> I had another student tell me today he tried all sorts of mirrors and
>>> could
>>> not get R and knitr installed until he tried the Washington site.
>>> 
>>> Is there some sort of corruption going on at the CRAN mirrors?
>>> 
>>> D.
>>> 
>> 
> 
> 
> David Winsemius, MD
> 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.

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


Re: [R] Installing R, R packages

2013-09-24 Thread David Winsemius


On Sep 24, 2013, at 12:47 AM, Jeff Newmiller wrote:

I have stopped using the Berkeley mirror, and just automatically use  
UCLA due to missing packages. However, I feel no compulsion to  
extrapolate and say that there is "some sort of corruption going on  
at CRAN mirrors" because it is only one data point.


I have not been having this sort of difficulty with the Berkeley  
mirror. Never have seen this particular error. Occasionally see the  
mirror down on a weekend, but that happens with all mirrors. (I do use  
Berkeley as my standard mirror and I do download a relatively large  
number of packages especially at the point where I call  
`update.packages`.)



--
David.


Sent from my phone. Please excuse my brevity.

David Arnold  wrote:

All,

Consider this attempt:

install.packages("car")

trying URL
'http://cran.cnr.Berkeley.edu/bin/macosx/contrib/3.0/car_2.0-19.tgz'
Content type 'application/x-gzip' length 1326903 bytes (1.3 Mb)
opened URL
==
downloaded 1.1 Mb

car/data/Rdata.rdb: Truncated tar archive
tar: Error exit delayed from previous errors.

The downloaded binary packages are in

/var/folders/qE/qEavkZWTFMmxjncuY+HnqE+++TI/-Tmp-//Rtmpnxi1hV/ 
downloaded_packages

Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 1126960 != reported length 1326903
2: 'tar' returned non-zero exit code 1




This seems to be happening frequently at the cran berkeley site. I've
also
had students try to install R from the Berkeley site and it just
doesn't
work for them.

I had another student tell me today he tried all sorts of mirrors and
could
not get R and knitr installed until he tried the Washington site.

Is there some sort of corruption going on at the CRAN mirrors?

D.






David Winsemius, MD
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] adjust scale of x-axis to unequal intervals

2013-09-24 Thread Sagan Friant
Thank you!  This worked beautifully.  Can you help me adapt the code to do
the same thing for a plot of means? The application is not a simple as I
hoped...

plotMeans(rich.small$ALL, rich.small$sample, error.bars="se")


On Mon, Sep 23, 2013 at 10:41 PM, Jim Lemon  wrote:

> On 09/24/2013 10:05 AM, Sagan Friant wrote:
>
>> Dear R community,
>>
>> Please help.  I am new(ish) to R and have spent too many hours trying to
>> achieve what I believe should be a relatively simple task.  I have
>> searched
>> help forums, but have not been able to successfully apply responses to
>> loosely related questions to my own.
>>
>> I am running some preliminary summary statistics.  I wish to create a
>> boxplot graph that represents summaries of samples collected over a series
>> of time points (0-18).  My sample collection intensity was highest early
>> on, with samples collection decreasing in frequency over time.  I am
>> trying
>> to scale the the x-axis to unequal intervals.
>>
>> The code I used for a graph representing a subset of my sample (re-named)
>> is below:
>>
>> Boxplot(ALL~sample, data=rich.small, id.method="n", las = 2, names =
>> c("0","2","4","7","10","18"))
>>
>> There were 10days between samples 0&2 and 3 days between 2&4, 4&7, 7&10,
>> and then 75days between 10&18
>>
>>  Hi Sagan,
> I think what you want is to have the boxplots spaced out as the occasions
> of measurement:
>
> rich.small<-data.frame(ALL=**rnorm(240,5),
>  sample=c(rep(0,60),rep(2,50),**rep(4,40),
>  rep(7,30),rep(10,30),rep(18,**30)))
> # this gives you the spacing with the occasion labels
> boxplot(ALL~sample,rich.small,**at=c(0,10,13,16,19,94),xaxt="**n",
>  xlab="Occasion")
> library(plotrix)
> staxlab(1,at=c(0,10,13,16,19,**94),labels=c(0,2,4,7,10,18))
> # and this gives you the days
> boxplot(ALL~sample,rich.small,**at=c(0,10,13,16,19,94),xaxt="**n",
>  xlab="Days")
> staxlab(1,at=c(0,10,13,16,19,**94))
>
> Lots of space in the middle for something.
>
> Jim
>



-- 
Sagan C. Friant, MSc
Environment & Resources Ph.D Program
Nelson Institute of Environmental Studies
University of Wisconsin - Madison

[[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] [] and escaping in regular expressions

2013-09-24 Thread Ista Zahn
On Tue, Sep 24, 2013 at 11:40 AM, Bert Gunter  wrote:
> Time to spend some time with the docs!
>
> ?egexp

Just to avoid any confusion: the documentation topic is ?regexp, not ?egexp

>
> tells you:
>
> ". (Only ^ - \ ] are special inside character classes.)"
>
> See also inline below.
>
> Cheers,
> Bert
>
>
> On Tue, Sep 24, 2013 at 8:30 AM, Juliet Hannah wrote:
>
>> Is it correct that one does not need to escape special characters such as
>> "*" (are these
>> properly called metacharacters) inside []. If so, what is the logic to
>> this?
>>
>
> Huh?  Are you aware that regular expressions are actually a context free
> grammar IIRC (computer science gurus, please confirm or correct)?
>
>>
>> mytest <- "he*llo"
>> sub("[*]","",mytest)
>> sub("\\*","",mytest)
>>
>> [] is easier to read for me than \\. Is this what people tend to use?
>>
>
> That would require a survey to answer, would it not? Tastes vary, as they
> say.
>
>
>
>> Thanks.
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
>
> [[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] [] and escaping in regular expressions

2013-09-24 Thread Juliet Hannah
Is it correct that one does not need to escape special characters such as
"*" (are these
properly called metacharacters) inside []. If so, what is the logic to this?

mytest <- "he*llo"
sub("[*]","",mytest)
sub("\\*","",mytest)

[] is easier to read for me than \\. Is this what people tend to use?

Thanks.

[[alternative HTML version deleted]]

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


Re: [R] [] and escaping in regular expressions

2013-09-24 Thread Bert Gunter
Time to spend some time with the docs!

?egexp

tells you:

". (Only ^ - \ ] are special inside character classes.)"

See also inline below.

Cheers,
Bert


On Tue, Sep 24, 2013 at 8:30 AM, Juliet Hannah wrote:

> Is it correct that one does not need to escape special characters such as
> "*" (are these
> properly called metacharacters) inside []. If so, what is the logic to
> this?
>

Huh?  Are you aware that regular expressions are actually a context free
grammar IIRC (computer science gurus, please confirm or correct)?

>
> mytest <- "he*llo"
> sub("[*]","",mytest)
> sub("\\*","",mytest)
>
> [] is easier to read for me than \\. Is this what people tend to use?
>

That would require a survey to answer, would it not? Tastes vary, as they
say.



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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[alternative HTML version deleted]]

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


Re: [R] Help: calculations based on three matrices

2013-09-24 Thread Berend Hasselman

On 24-09-2013, at 16:51, arun  wrote:

> Hi,
> Try:
> ME<- matrix(NA,dim(geno[1]),dim(geno)[2])
> indx0<- geno==0 & !is.na(geno)
> ME[indx0]<- Mx[indx0]+My[indx0]
>  indx1<- geno==1 & !is.na(geno)
> ME[indx1]<- apply(cbind(Mx[indx1],My[indx1]),1,max)
> 
I would do this to avoid the apply

ME[indx1]<- pmax(Mx[indx1],My[indx1]) 

Berend

> ME
> A.K.
> 
> 
> 
> 
> - Original Message -
> From: JiangZhengyu 
> To: "r-help@r-project.org" 
> Cc: 
> Sent: Tuesday, September 24, 2013 10:07 AM
> Subject: [R] Help: calculations based on three matrices
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Dear R experts,
> 
> I have 3 matrices - "Mx", "My" and "geno" that have the same exact dimensions 
> (attached).  I want to calculate a expression matrix (ME) of the same 
> dimension as well. It is a little complicated.
> 
> To calculate and for a specific cell in ME,  e.g. ME[2,2],
> 
> if value of geno[2,2] is 0, ME[2,2]=Mx[2,2]+My[2,2];
> if value of geno[2,2] is 1, ME[2,2]=the larger number of Mx[2,2] and My[2,2]
> if value of geno[2,2] is NA, ME[2,2]=NA
> 
> I tried to make codes below, but did not work and got stuck. I was wondering 
> if anyone could help with better coding.
> 
> Thanks in advance,
> Zhengyu
> 
> ---  
> 
> Mx <-  read.table("Mx.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
> strip.white=TRUE)
> My <-  read.table("My.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
> strip.white=TRUE)
> geno <-  read.table("geno.txt",header=TRUE, sep="\t", na.strings="NA", 
> dec=".", strip.white=TRUE)
> 
> #Calculate Exp for geno==0
> ind=which(geno==0,arr.ind=T)
> het=Mx+My
> ME=matrix(het,nrow=nrow(geno),ncol=ncol(geno))
> ME[ind]=het[ind]
> 
> #Calculate Exp for geno==1
> ind=which(geno==1,arr.ind=T)
> hom=apply(M1,c(1:2),function(x)max(M1[],M2[]))# error
> ME=matrix(hom,nrow=nrow(geno),ncol=ncol(geno))
> ME[ind]=hom[ind]
> 
> # I think the first calculation (geno==0) will be replaced but I don't know 
> how to keep them.
> 
>> head(Mx)
>X1cX X2cX  X3cX  X4cX X5cX X6cX X7cX X8cX
> 1 26383 6252 14319 16421 2225  480 2038 1164
> 2   636  310   351   341  218  656  412  267
> 3   301  299   752   236  239  309  283  195
> 4  1016 1046  1364   782  822  274  437  346
> 5  1261 1272  1076  1037  659  337 1143 1195
> 6   609  414   393   459  215  429  566  236
> 
>> dim(Mx)
> [1] 20  8
> 
>> head(My)
>X1cY X2cY X3cY X4cY X5cY X6cY X7cY X8cY
> 1  1039  233  408  607  275 1837 1319  149
> 2  7146 1706 2248 2346 1596  544 2696  417
> 3   266  425 1186  214  325  369  377  215
> 4   260  282  238  240  264  265  317  203
> 5  1070 1052  746  613  384  447  456  683
> 6 13032 1708 2328 5998 2529  923 1068  145
> 
>> dim(My)
> [1] 20  8
> 
>> head(geno)
>   P1 P2 P3 P4 P5 P6 P7 P8
> 1 NA NA NA NA  1 NA NA NA
> 2  1  1  1  1  1  1  1  1
> 3  1  1  0  0  0  0  1  0
> 4  1  1  1  1  1  1  0  0
> 5  0  0  0  0  0  0  1  0
> 6 NA NA NA NA NA NA NA NA
> 
>> dim(geno)
> [1] 20  8
> 
> 
> 
>  
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Help: calculations based on three matrices

2013-09-24 Thread arun
Hi,
Try:
ME<- matrix(NA,dim(geno[1]),dim(geno)[2])
indx0<- geno==0 & !is.na(geno)
ME[indx0]<- Mx[indx0]+My[indx0]
 indx1<- geno==1 & !is.na(geno)
ME[indx1]<- apply(cbind(Mx[indx1],My[indx1]),1,max)

ME
A.K.




- Original Message -
From: JiangZhengyu 
To: "r-help@r-project.org" 
Cc: 
Sent: Tuesday, September 24, 2013 10:07 AM
Subject: [R] Help: calculations based on three matrices









Dear R experts,

I have 3 matrices - "Mx", "My" and "geno" that have the same exact dimensions 
(attached).  I want to calculate a expression matrix (ME) of the same dimension 
as well. It is a little complicated.

To calculate and for a specific cell in ME,  e.g. ME[2,2],

if value of geno[2,2] is 0, ME[2,2]=Mx[2,2]+My[2,2];
if value of geno[2,2] is 1, ME[2,2]=the larger number of Mx[2,2] and My[2,2]
if value of geno[2,2] is NA, ME[2,2]=NA

I tried to make codes below, but did not work and got stuck. I was wondering if 
anyone could help with better coding.

Thanks in advance,
Zhengyu

---  

Mx <-  read.table("Mx.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
strip.white=TRUE)
My <-  read.table("My.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
strip.white=TRUE)
geno <-  read.table("geno.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
strip.white=TRUE)

#Calculate Exp for geno==0
ind=which(geno==0,arr.ind=T)
het=Mx+My
ME=matrix(het,nrow=nrow(geno),ncol=ncol(geno))
ME[ind]=het[ind]

#Calculate Exp for geno==1
ind=which(geno==1,arr.ind=T)
hom=apply(M1,c(1:2),function(x)max(M1[],M2[]))# error
ME=matrix(hom,nrow=nrow(geno),ncol=ncol(geno))
ME[ind]=hom[ind]

# I think the first calculation (geno==0) will be replaced but I don't know how 
to keep them.

> head(Mx)
   X1cX X2cX  X3cX  X4cX X5cX X6cX X7cX X8cX
1 26383 6252 14319 16421 2225  480 2038 1164
2   636  310   351   341  218  656  412  267
3   301  299   752   236  239  309  283  195
4  1016 1046  1364   782  822  274  437  346
5  1261 1272  1076  1037  659  337 1143 1195
6   609  414   393   459  215  429  566  236

> dim(Mx)
[1] 20  8

> head(My)
   X1cY X2cY X3cY X4cY X5cY X6cY X7cY X8cY
1  1039  233  408  607  275 1837 1319  149
2  7146 1706 2248 2346 1596  544 2696  417
3   266  425 1186  214  325  369  377  215
4   260  282  238  240  264  265  317  203
5  1070 1052  746  613  384  447  456  683
6 13032 1708 2328 5998 2529  923 1068  145

> dim(My)
[1] 20  8

> head(geno)
  P1 P2 P3 P4 P5 P6 P7 P8
1 NA NA NA NA  1 NA NA NA
2  1  1  1  1  1  1  1  1
3  1  1  0  0  0  0  1  0
4  1  1  1  1  1  1  0  0
5  0  0  0  0  0  0  1  0
6 NA NA NA NA NA NA NA NA

> dim(geno)
[1] 20  8



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


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


Re: [R] Matrix operation

2013-09-24 Thread arun


Hi,
Try:

set.seed(49)
qcd<- matrix(sample(1:20,124*69,replace=TRUE),ncol=69)

set.seed(345)
listt<- matrix(sample(1:80,124*5,replace=TRUE),ncol=5)
lst1<-list(c(15,2),c(56,54),c(15,62),c(4,14))
 names(lst1)<- 2:5
S<- do.call(cbind,lapply(names(lst1),function(i) 
{ww<-listt[,as.numeric(i),drop=FALSE];indx<-lst1[[i]]; YY<- 
cbind(qcd[,indx[1]],qcd[,indx[2]]);M<- lm(ww~qcd[,indx[1]]+qcd[,indx[2]]); A1<- 
M$coef[2]; B1<- M$coef[3]; unlist(lapply(seq_len(nrow(YY)),function(i){Y<- 
YY[i,];A<- A1*Y[1]; B<- B1*Y[2]; Alp<- A+B} ),use.names=FALSE) }))
colnames(S)<- paste0("Alp",1:4)
 dim(S)
#[1] 124   4

#or just

S1<-do.call(cbind,lapply(names(lst1),function(i) 
{ww<-listt[,as.numeric(i),drop=FALSE];indx<-lst1[[i]]; YY<- 
cbind(qcd[,indx[1]],qcd[,indx[2]]);M<- lm(ww~qcd[,indx[1]]+qcd[,indx[2]]); A1<- 
M$coef[2]; B1<- M$coef[3]; A<- A1* YY[,1]; B<- B1*YY[,2] ; A+B}))
 colnames(S1)<- colnames(S)
 identical(S1,S)
#[1] TRUE




A.K.

From: eliza botto 
To: "smartpink...@yahoo.com"  
Sent: Tuesday, September 24, 2013 8:04 AM
Subject: 




Dear Arun,
I have the following codes to perform a certain operation

where "listt" is a matrix of dimension 124 ROW  and 5 COLUMN. "qcd" has 124 
rows and 69 columns. YY has 12 rows and 2 columns. 
What i want to do is to make a loop so that R automatically replaces "15" in 
Y<-YY[15,] with the numbers from 1 to 124, every where. 
So "Alp1","Alp2","Alp3" and "Alp4" should each be of 124 rows and 1 column. 
similarly "S",in the end,should be of dimension 124*4.
How can i do that?
I hope i am clear but if there is anything that is needed to be cleared about 
question please do let me know.

ww<-matrix(listt[,2],ncol=1)
 YY<-cbind(qcd[,15],qcd[,2])
 Y<-YY[15,]
 M<-lm(ww~qcd[,15]+qcd[,2])
 A<-M$coefficients[2]*Y[1]
 B<-M$coefficients[3]*Y[2]
 Alp1<-A+B
 Alp1

 ww<-matrix(listt[,3],ncol=1)
 YY<-cbind(qcd[,56],qcd[,54])
 Y<-YY[15,]
 M<-lm(ww~qcd[,56]+qcd[,54])
 A<-M$coefficients[2]*Y[1]
 B<-M$coefficients[3]*Y[2]
 Alp2<-A+B
 Alp2

ww<-matrix(listt[,4],ncol=1)
 YY<-cbind(qcd[,15],qcd[,62])
 Y<-YY[15,]
 M<-lm(ww~qcd[,7]+qcd[,62])
 A<-M$coefficients[2]*Y[1]
 B<-M$coefficients[3]*Y[2]
 Alp3<-A+B
Alp3

ww<-matrix(listt[,5],ncol=1)
 YY<-cbind(qcd[,4],qcd[,14])
 Y<-YY[15,]
 M<-lm(ww~qcd[,4]+qcd[,14])
 A<-M$coefficients[2]*Y[1]
 B<-M$coefficients[3]*Y[2]
 Alp4<-A+B
Alp4

S<-cbind(Alp1,Alp2,Alp3,Alp4)

Thanks indeed in advance

Eliza 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] no answer to the following question

2013-09-24 Thread Bert Gunter
You might be more successful if:

1. Post in plain text, not HTML, as the posting guide asks;

2. Don't post at all. Instead read the included tutorial, An Introduction
to R, or one of the many on the web that you might prefer. Nothing wrong
with being a newbie; but (imo, of course) there **is** something wrong with
being a newbie who has not first done some homework before posting to this
list.

Cheers,
Bert




On Tue, Sep 24, 2013 at 1:07 AM, Michel  wrote:

> I sent this message :
> Hello everyone,
> R beginner, I am confronted with the need to use
> Rmpf.
> In my first scripts I made use of
> X=read.table(file.choose(), header=FALSE,
> sep=",",dec=".")
> X=as.matrix(X)
> to load into a matrix data  from file before matrix
> use.
> How can I do to load the same data in a
> "mpfrMatrix".
> Is it possible to use with "mpfrMatrix" the same as
> operations
> M1%*%M2
> scale(M1,TRUE,FALSE)
> Sorry but I'm a newbe
>
> Thanks in advance
>
> Michel
>
> But no body ... may be my question appear too simple for r-help people
> I'll try alone using books
> Thank you anyway
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[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] Hungarian R User's Group: Exploratory and interactive data analysis talks on Wednesday

2013-09-24 Thread Gergely Daróczi
Dear useRs,

although we have just (around a month ago) founded the Budapest Users of R
Network, I am more than happy to announce that 75 members already joined
and we are very close to take part in the first official meeting.

We will meet at the ELTE University, Budapest, Hungary at 18:00 (CET)
tomorrow, and there will be two talks on the _iplots_ and _shiny_ packages
in Hungarian language.

Please feel free to join us and have a pizza and a few drinks with us :)

More info: http://www.meetup.com/Budapest-Users-of-R-Network

Best,
Gergely

[[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: calculations based on three matrices

2013-09-24 Thread JiangZhengyu

 






Dear R experts,
 
I have 3 matrices - "Mx", "My" and "geno" that have the same exact dimensions 
(attached).  I want to calculate a expression matrix (ME) of the same dimension 
as well. It is a little complicated.
 
To calculate and for a specific cell in ME,  e.g. ME[2,2],
 
 if value of geno[2,2] is 0, ME[2,2]=Mx[2,2]+My[2,2];
 if value of geno[2,2] is 1, ME[2,2]=the larger number of Mx[2,2] and My[2,2]
 if value of geno[2,2] is NA, ME[2,2]=NA
 
I tried to make codes below, but did not work and got stuck. I was wondering if 
anyone could help with better coding.
 
Thanks in advance,
Zhengyu
 
---   
 
Mx <-  read.table("Mx.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
strip.white=TRUE)
My <-  read.table("My.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
strip.white=TRUE)
geno <-  read.table("geno.txt",header=TRUE, sep="\t", na.strings="NA", dec=".", 
strip.white=TRUE)
 
#Calculate Exp for geno==0
ind=which(geno==0,arr.ind=T)
het=Mx+My
ME=matrix(het,nrow=nrow(geno),ncol=ncol(geno))
ME[ind]=het[ind]
 
#Calculate Exp for geno==1
ind=which(geno==1,arr.ind=T)
hom=apply(M1,c(1:2),function(x)max(M1[],M2[]))# error
ME=matrix(hom,nrow=nrow(geno),ncol=ncol(geno))
ME[ind]=hom[ind]
 
# I think the first calculation (geno==0) will be replaced but I don't know how 
to keep them.
 
> head(Mx)
   X1cX X2cX  X3cX  X4cX X5cX X6cX X7cX X8cX
1 26383 6252 14319 16421 2225  480 2038 1164
2   636  310   351   341  218  656  412  267
3   301  299   752   236  239  309  283  195
4  1016 1046  1364   782  822  274  437  346
5  1261 1272  1076  1037  659  337 1143 1195
6   609  414   393   459  215  429  566  236

> dim(Mx)
[1] 20  8

> head(My)
   X1cY X2cY X3cY X4cY X5cY X6cY X7cY X8cY
1  1039  233  408  607  275 1837 1319  149
2  7146 1706 2248 2346 1596  544 2696  417
3   266  425 1186  214  325  369  377  215
4   260  282  238  240  264  265  317  203
5  1070 1052  746  613  384  447  456  683
6 13032 1708 2328 5998 2529  923 1068  145

> dim(My)
[1] 20  8

> head(geno)
  P1 P2 P3 P4 P5 P6 P7 P8
1 NA NA NA NA  1 NA NA NA
2  1  1  1  1  1  1  1  1
3  1  1  0  0  0  0  1  0
4  1  1  1  1  1  1  0  0
5  0  0  0  0  0  0  1  0
6 NA NA NA NA NA NA NA NA

> dim(geno)
[1] 20  8




  X1cXX2cXX3cXX4cXX5cXX6cXX7cXX8cX
26383   625214319   16421   2225480 20381164
636 310 351 341 218 656 412 267
301 299 752 236 239 309 283 195
101610461364782 822 274 437 346
1261127210761037659 337 11431195
609 414 393 459 215 429 566 236
1150394 478 662 430 430 511 168
503 414 328 340 348 609 242 235
701 1629569 447 472 247 705 646
1478923 144716231243830 12122819
2511914 15531834497 567 537 528
1551622 789 361 245 192 269 480
406 543 503 370 322 421 205 265
442 553 538 295 162 391 220 258
543 106 344 332 442 286 235 205
394 317 223 192 99  290 251 269
433 492 672 278 373 329 562 709
354 292 424 382 218 333 254 279
186318231176785 552 332 471 212
496 285 307 363 170 471 381 623
X1cYX2cYX3cYX4cYX5cYX6cYX7cYX8cY
1039233 408 607 275 18371319149
71461706224823461596544 2696417
266 425 1186214 325 369 377 215
260 282 238 240 264 265 317 203
10701052746 613 384 447 456 683
13032   1708232859982529923 1068145
18068   8188710313441   826240165952259
221 201 175 178 156 142 234 133
399 643 389 1953225 638 483 396
1578228412831724147614581186508
488 506 460 679 509 288 489 407
538 340 694 594 137 281 223 230
852 314 266 181 169 152 226 249
291 180 219 89  120 167 110 152
168 212 125 203 313 339 280 239
256 111 203 138 117 163 174 145
972111517   11662   0   9392402911070   14861
216 180 183 163 102 153 164 136
216 160 181 271 115 128 154 87
108 148 200 156 154 113 243 239
P1  P2  P3  P4  P5  P6  P7  P8
NA  NA  NA  NA  1   NA  NA  NA
1   

Re: [R] lattice: double y - problem changing axis color after doubleYScale

2013-09-24 Thread Duncan Mackay
Hi Anna

Have a look a ylab in my script - you will need to modify the label I was
going from memory on the exact label  argument name . I think it is text  =
"Np" or whatever you want.

The strip arguments are controlled by useOuterStrip see ?useOuterStrip
So you will need to modify as a custom scale there.

There is doubleYScale in latticeExtra as well . I do not know or use the HH
package

As an afterthought you might have a look at ?make.groups for joining
datasets

Duncan

-Original Message-
From: Anna Zakrisson Braeunlich [mailto:anna.zakris...@su.se] 
Sent: Tuesday, 24 September 2013 22:43
To: Duncan Mackay
Subject: RE: [R] lattice: double y - problem changing axis color after
doubleYScale

Thank you!

The code works if one removes:  strip  = strip.custom(factor.levels =
c("B1", "H2", "H3", "H4")),
   par.strip.text =
  list(fontfamily="serif" )),

it was doubled.

It is not quite what I want as I need Nc and Pc in the same plot panel. Just
a simple double y-axis plot factorized by station and year and with week on
the x-axis.

Maybe you know why ylab=() is overridden in the codes you have sent me?
ylab=() is defined as normal, but is not showing up in the plot. Am I
defining something in the useOuterStrips() command that I am not
understanding?

I have solved the doubleYScale colour problem:
doubleYScale(plotNtest, plotPtest, add.ylab=T, style1=0, style2=0) #makes
both axes black.

I have a funktioning plot with doubleYScale provided this is solved:
1. I still have the problem that the strip.left =() outer strip is ON TOP of
my y-axis. Any ideas on how to tweak the position of the strip and/or move
the entire y-axis, but then using doubleYScale (which I know you don't use,
but maybe some other person does)? 
2. I can add ylab=(). It is non-functional at this time.

thank's

with kind regards
Anna Zakrisson

Here is the full code for my doubleYScale plot:
Ndata <- data.frame(
  Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40),
   sd = rep(c(1, 3, 6), each = 40)),
  fyear = rep(c('2007', '2008'), each = 100*2),
  Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
  Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))

Pdata <- data.frame(
  Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40),
   sd = rep(c(0.1, 0.2, 0.4), each = 40)),
  fyear = rep(c('2007', '2008'), each = 100*2),
  Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
  Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))

SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, 
   mean = mean(Ncellpercent), 
   sd = sd(Ncellpercent))
names(Pdata)
SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, 
   mean = mean(Ppercentcell), 
   sd = sd(Ppercentcell)) SummPdata

plotNtest <- useOuterStrips(strip  = strip.custom(factor.levels =
c("B1", "H2", "H3", "H4"),
  par.strip.text =
list(fontfamily="serif" )),
   strip.left = strip.custom(factor.levels = c("2007", "2008",
"2009"),
 par.strip.text =
   list(fontfamily="serif" )),
   xyplot(mean ~ Week | Station*fyear, data= SummNdata,
  col="black",
  pch=1,
  cex=1.1,
  lty=1,
  par.settings = list(strip.background = list(col =
 
"transparent"),
  add.text = list(fontfamily =
"serif"
  )),
  strip  = strip.custom(factor.levels = c("B1",
"H2", "H3", "H4"),
   par.strip.text =
  list(fontfamily="serif" )),
   scales = list(alternating = c(3,3),
 fontfamily = "serif"),
   ylab = list(text = "Nc", fontfamily = "serif"),
   xlab=list(text = "Week", fontfamily = "serif"),
   key  = list(text = list(labels = c("Pc","Nc")),
   points = list(pch = c(1,2)),
   lines  = list(lty = c(1,2))),
   type = "o",
   ylim = c(0,70),
   subscripts = TRUE,
   panel = function(x,y, subscripts, ...){
 panel.xyplot(x,y, ...)
 # sd
 # upper
 panel.arrows(x0 = x, x1 = x,
  y0 = y, y1 = y+ SummNdata[subscripts,
"sd"]/2, angle = 90,
length = 0.04)
 # lower
 panel.arrows(x0 = x, x1 = x,
  y0 = y, y1 = y- SummNdata[subscripts,
"sd"]/2, angle = 90,
length = 0.04)
 
 panel.x

Re: [R] Graph is without line

2013-09-24 Thread arun
Try:

plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xlab="",las=2,lwd=2.5,xaxt="n")

A.K.



- Original Message -
From: "mohan.radhakrish...@polarisft.com" 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, September 24, 2013 8:46 AM
Subject: [R] Graph is without line

Hi,
        Sometimes I get a graph like the attached one. The data type could 
have something to do with it. This graph does not use the color and does 
not draw
a line. Earlier I used to convert the factors in the data frame to another 
data type and drew the correct graphs.

Any idea why this happens ?

Thanks,
Mohan

            Var1 Freq
1     10.1.17.10  205
2     10.1.17.15  216
3     10.1.17.17   79
4     10.1.17.23   76
5     10.1.17.24  209
6      10.1.17.5  244
7      10.1.17.6  178
8      10.1.17.7  165
9      10.1.17.8  146



#prints factor
print(class(data$Var1))

plot(data$Var1,data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
title("Estimation of concurrent connections",cex.main=3)
library(plotrix)
staxlab(at=data$Var1,
  labels=as.character(data$Var1),nlines=3,srt=90)


This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

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


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


[R] Graph is without line

2013-09-24 Thread mohan . radhakrishnan
Hi,
Sometimes I get a graph like the attached one. The data type could 
have something to do with it. This graph does not use the color and does 
not draw
a line. Earlier I used to convert the factors in the data frame to another 
data type and drew the correct graphs.

Any idea why this happens ?

Thanks,
Mohan

Var1 Freq
1 10.1.17.10  205
2 10.1.17.15  216
3 10.1.17.17   79
4 10.1.17.23   76
5 10.1.17.24  209
6  10.1.17.5  244
7  10.1.17.6  178
8  10.1.17.7  165
9  10.1.17.8  146



#prints factor
print(class(data$Var1))

plot(data$Var1,data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
title("Estimation of concurrent connections",cex.main=3)
library(plotrix)
staxlab(at=data$Var1,
  labels=as.character(data$Var1),nlines=3,srt=90)


This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.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] GAM & GAMM course

2013-09-24 Thread Highland Statistics Ltd

We would like to announce the following statistics course:

Beginner's Guide to MCMC, GAM and GAMM

When: 10-14 March 2014
Where: Elche, Alicante, Spain

For details, see: http://www.highstat.com/statscourse.htm
Course flyer: http://www.highstat.com/Courses/Flyer2014_3ElcheV2.pdf


Kind regards,

Alain Zuur


--
Dr. Alain F. Zuur
First author of:

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

Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.com
URL: www.highstat.com
URL: www.brodgar.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] Date Comparing *Problem*

2013-09-24 Thread Uwe Ligges



On 23.09.2013 13:48, Rhymes wrote:

I have a problem with comparing dates. i tried it like "datesub =
subset(data, 2012-11-19 < data$date)", but this doesn't work and i don't
know why.


Errr, in R:
 2012-11-19 == 1982

You probably want to convert it to a Date object or Posix.. object, but 
since we do not know ehat data$date is.


Best,
Uwe Ligges




Hope you can help me.

here are my files:
http://uploaded.net/file/n9sxdm0v 



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

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



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


Re: [R] Rmpfr question; was: no answer to the following question

2013-09-24 Thread Uwe Ligges



On 24.09.2013 10:07, Michel wrote:

I sent this message :
Hello everyone,
R beginner, I am confronted with the need to use
Rmpf.


It helps to provide a sensible subject line and not to misspell package 
names:Rmpfr.




In my first scripts I made use of
X=read.table(file.choose(), header=FALSE,
sep=",",dec=".")
X=as.matrix(X)
to load into a matrix data  from file before matrix
use.
How can I do to load the same data in a
"mpfrMatrix".
Is it possible to use with "mpfrMatrix" the same as
operations


M1 <- mpfr(M1, precBits = )



M1%*%M2


Should work out of the box for mpfr objects.



scale(M1,TRUE,FALSE)


There is not scale function implemented in Rmpfr. HEnce you need to 
write it yourself based on the provided infrastructure from the Rmpfr 
package.


Best,
Uwe Ligges


Sorry but I'm a newbe

Thanks in advance

Michel

But no body ... may be my question appear too simple for r-help people
I'll try alone using books
Thank you anyway


[[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] Invalid Z argument error in persp.default

2013-09-24 Thread Duncan Murdoch

On 13-09-24 6:19 AM, Babak Bastan wrote:

I do the folloowing in order to get 3D Plot:

y<-1:(point/2)
x<-20:30
z<-r[1:(point/2)]
persp(x,y,z,theta = 135, phi = 30, col = "green3", scale = FALSE,
ltheta = -120, shade = 0.75,
   border = 1)


y:

[1] 1 2 3 4 5

x:

[1] 20 21 22 23 24 25

z:

[1] 4811.003.5930256.9686664.9081745.332700

but i always get the error message Error in persp.default(x, y, z, theta =
135, phi = 30, col = "green3", :invalid 'z' argument

How may I solve the issue?


See ?persp.  z should be a 5x5 matrix to match your x and y.

Duncan Murdoch

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


[R] Issue with lmerTest and dopar

2013-09-24 Thread AlexisB
Hi,

I have a problem with running a script in parallel with the foreach function
for computing linear models at every voxel of a set of 3D images. When I run
it using %do%, it runs fine and I get the correct output but when I run it
with %dopar% then my main output is not correct. The problem inside the
foreach loop seems to be in the function called "lmer" which is part of the
lmerTest package. It is used to compute linear models and the issue is that
lmer returns the p-values which are different for each test when using %do%
but they are all the same when using %dopar%, which is obviously incorrect.

Here is the foreach loop:

#To try with the first 5 voxels only, so that it works.
resultTest<-foreach (index=1:5, .combine=rbind, .packages='lmerTest',
.verbose=TRUE) %dopar% {  

i1 <- inmask[index,1]
i2 <- inmask[index,2]
i3 <- inmask[index,3]
y <- ydat[i1,i2,i3,]

# create the datafile with current voxel, with the voxelvalues and
variables of 
# interest
long <- data.frame(cbind(xdat,y))
  
# do the model you want to do on the data
fm1 <- lmer(y ~ 1 + time + (1|id), long)

# extract what you care about and save in your created array, with the
index you are
# currently running. Type fm1 to see your output, str(fm1) to see your
slots, so you 
# can find where the data you want are (which place in the order, which 
can
depend on 
# your model).
p=f...@t.pval[2]
p.time[i1,i2,i3] <- p

}

And here is the output p-values when running with %do%:

result.1 0.02976868
result.2 0.01706419
result.3 0.01509690
result.4 0.02078050
result.5 0.03950854

Output using %dopar% (I ran this one right after the %do%, you can see that
all the p-values here are the same as the last p-value ran with %do%)

result.1 0.03950854
result.2 0.03950854
result.3 0.03950854
result.4 0.03950854
result.5 0.03950854



Also, here is the lmer function (from the lmerTest package):

lmer <-function(formula, data, family = NULL, REML = TRUE,
 control = list(), start = NULL, verbose = FALSE, doFit = TRUE,
 subset, weights, na.action, offset, contrasts = NULL,
 model = TRUE, x = TRUE, ...)
{
  mc<-match.call()
  mc[[1]] <- quote(lme4::lmer)
  model<-eval.parent(mc)
  model<-as(model,"merLmerTest")
  #tryCatch(  { result = glm( y~x , family = binomial( link = "logit" )
) } , error = function(e) { print("test") } )
  t.pval <- tryCatch( {totalAnovaRandLsmeans(model=model,
ddf="Satterthwaite", isTtest=TRUE)$ttest$tpvalue}, error = function(e) {
NULL })
  if(!is.null(t.pval))
  {
mo...@t.pval <-t.pval
  }
  else
  {
model<-as(model,"mer")
  }
  return(model)
}


What I do not understand is that all the other data output by lmer is fine
and different for each voxel except for this p-value.

So if anyone has a hint on how I could solve this issue, I would greatly
appreciate.

Thank you in advance.

Best regards,

Alexis.



--
View this message in context: 
http://r.789695.n4.nabble.com/Issue-with-lmerTest-and-dopar-tp4676831.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to add a box to map plotted by a levelplot?

2013-09-24 Thread Jonsson
Thanks.That worked fine.Is there a way to print a number like 1 inside the
box plotted?



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-add-a-box-to-map-plotted-by-a-levelplot-tp4676815p4676825.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to add a box to map plotted by a levelplot?

2013-09-24 Thread Jonsson
That worked fine, thanks. But only worked when the values are positive but
when I added negative values, the box was wrong. May be the order I lat and
long should be different?any ideas



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-add-a-box-to-map-plotted-by-a-levelplot-tp4676815p4676820.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Invalid Z argument error in persp.default

2013-09-24 Thread Babak Bastan
I do the folloowing in order to get 3D Plot:

y<-1:(point/2)
x<-20:30
z<-r[1:(point/2)]
persp(x,y,z,theta = 135, phi = 30, col = "green3", scale = FALSE,
ltheta = -120, shade = 0.75,
  border = 1)


y:

[1] 1 2 3 4 5

x:

[1] 20 21 22 23 24 25

z:

[1] 4811.003.5930256.9686664.9081745.332700

but i always get the error message Error in persp.default(x, y, z, theta =
135, phi = 30, col = "green3", :invalid 'z' argument

How may I solve the issue?

[[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] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-24 Thread Jose Claudio Faria
Hi,

I prefer to build my packages on Linux!

I changed the object trPaths as below,
After R CMD build TinnRcom on Linux and did the installation
on Windows from the source code: It worked very well!

I thank all who contributed to the solution and apologize for my lack
of knowledge in this area.

trPaths <-
  file.path(ifelse(.Platform$OS.type == "windows",
   Sys.getenv("APPDATA"),
   Sys.getenv("HOME")),
"Tinn-R",
"tmp",
c('',
  'search.txt',
  'objects.txt',
  'file.r',
  'selection.r',
  'block.r',
  'lines.r',
  'reformat-input.r',
  'reformat-output.r'),
fsep='\\')

> install.packages('TinnRcom_1.0-09.tar.gz', repos=NULL, type='source')
* installing *source* package 'TinnRcom' ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (TinnRcom)

> library(TinnRcom)
Loading required package: tcltk
Loading required package: Hmisc
Loading required package: survival
Loading required package: splines
Loading required package: Formula
Hmisc library by Frank E Harrell Jr

Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
to see overall documentation.


Attaching package: ‘Hmisc’

The following object is masked from ‘package:survival’:

untangle.specials

The following objects are masked from ‘package:base’:

format.pval, round.POSIXt, trunc.POSIXt, units

Loading required package: R2HTML
Loading required package: svSocket
Loading required package: formatR

> trPaths
[1] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\"
[2] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\search.txt"
[3] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\objects.txt"
[4] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\file.r"
[5] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\selection.r"
[6] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\block.r"
[7] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\lines.r"
[8] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-input.r"
[9] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-output.r"

All the best,
-- 
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)9100.7351 - TIM
55(73)8817.6159 - OI
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\

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

2013-09-24 Thread Martin Maechler
> "M" == Michel  
> on Fri, 20 Sep 2013 17:56:58 +0200 writes:

> Hello everyone, R beginner, I am confronted with the need
> to use Rmpf.
why ?

> In my first scripts I made use of
> X=read.table(file.choose(), header=FALSE, sep=",",dec=".")  
> X=as.matrix(X)

well, the above is not at all reproducible {we don't see *nor*
have the file you chose with file.choose() !}
so that's maybe why nobody helped ...

Does the file have numbers in high precision, i.e. more than
about 15-16 digits?
I'm assuming "no" for the moment.
If "yes" was the answer, then you really need to read the data
quite differently.
In that case please, show us the first few lines  of your file.


> to load into a matrix data from file before matrix use.

> How can I do to load the same data in a "mpfrMatrix".

As you already have the regular numeric matrix X,
you can either use

M <- as(X, "mpfr") # uses default precision of 128 bits
or
M <- mpfr(X, precBits = 200)

where you choose the precision of the numbers via 'precBits'


> Is it possible to use with "mpfrMatrix" the same as
> operations

> M1 %*% M2

yes, matrix multiplications all work ... though a bit slowly.
matrix factorizations (eigen, svd, qr, solve,..) all do not
(yet; patches are welcome; I'm currently working at an LU decomposition).

>  scale(M1,TRUE,FALSE)

not directly, in the current version of Rmpfr.
But you can use the following trick:

scale.mpfrMatrix <- scale.default
environment(scale.mpfrMatrix) <- asNamespace("Rmpfr")

and then it will work.


> Sorry but I'm a newbe

let's hope, not for too long ;-) ;-)

> Thanks in advance
> Michel

You're welcome,
Martin Maechler, ETH Zurich

(maintainer of the 'Rmpfr' package.
 Yes, I know you also sent the question to me privately, 
 but only several days *after* asking on R-help; it would have
 been nice, if you had mentioned that you also asked here and
 nobody helped you.  ...)

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


[R] R function for censored linear regression

2013-09-24 Thread Andreas Wittmann

Dear R-useRs,

I'm looking for an R-function for censored linear regression. I have the 
following data


x1 <- rnorm(100)
x2 <- rnorm(100)
y <- x1 + 2*x2 + rnorm(100,0,0.5)
stat <- rep(1,100)
stat[50:100] <- 0
data <- data.frame(y,x1,x2,stat)

y is the dependent variable, x1 and x2 are the independent variables in 
a linear model. the variable y could be right-censored, this information 
is in the variable stat, where 1 denotes observed and 0 denotes 
censored. If stat is 0, then the value in y is the observed 
right-censored value and could be greater. Using the Tobit-model would 
not be the right thing here because the Tobit model assumes the same 
limit for all observations, in my data each value of y[50:100] could 
have a different limit.


If i use linear regression

lm1 <- lm(y ~ x1 + x2, data=data)
summary(lm1)

the censoring is not incorporated, so my idea is to use survreg from the 
survival package


library(survival)
s1 <- survreg(Surv(y, stat) ~ x1 + x2, data, dist='gaussian')
summary(s1)

my question is, is this the right approach for my aim? Is it right, that 
here each censored observations could have its own limit?


Thanks and best regards
Andreas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: double y - problem changing axis color after doubleYScale

2013-09-24 Thread Duncan Mackay
Hi Anna

I have never used doubleYScale and I am not sure what you want but try this

You need to do this first if columns not correct saves doing later - I
forgot to mention it for Week but as you have given the order for the
factors do it as well

SummPdata[,1] <- as.numeric(SummPdata[,1])
SummNdata[,1] <- as.numeric(SummNdata[,1])
SummPdata[,3] <- factor(SummPdata[,3], levels = c('B1', 'H2', 'H3', 'H4'))
SummNdata[,3] <- factor(SummNdata[,3], levels = c('B1', 'H2', 'H3', 'H4'))

As the data has a similar structure combine data

summData = rbind(SummPdata, SummNdata)
summData$element <- rep(c("P","N"), each = 32)

Just quickly cut and pasted the colours etc

useOuterStrips(strip  = strip.custom(#factor.levels = ,
 par.strip.text =
list(fontfamily="serif" )),
   strip.left = strip.custom(#factor.levels = ,
 par.strip.text =
list(fontfamily="serif" )),
   xyplot(mean ~ Week | Station*interaction(element,fyear),
data= summData,
cex=1.1,
par.settings = list(strip.background = list(col =
"transparent"),
add.text = list(fontfamily = "serif")),
#strip  = strip.custom(#factor.levels = ,
# par.strip.text =
list(fontfamily="serif" )),
   scales = list(alternating = c(3,3),
  fontfamily = "serif"),
ylab = list(text = "Pc", fontfamily = "serif"),
xlab=list(text = "Week", fontfamily = "serif"),
key  = list(text = list(labels = c("P","N")),
points = list(pch = c(2,20), col =
c("red","blue")),
lines  = list(lty = c(1,2)), col =
c("red","blue")),
type = "o",
ylim = c(0,70),
subscripts = TRUE,
panel = function(x,y, subscripts, ...){

  pnl = panel.number()

  panel.xyplot(x,y, type = "o", col =
c("red","blue")[ifelse(pnl <9, 1,2)], lty = c(1,2)[ifelse(pnl <9, 1,2)], pch
= c(2,20)[ifelse(pnl <9, 1,2)])
  # sd
  # upper
  panel.arrows(x0 = x, x1 = x,
   y0 = y, y1 = y+ summData[subscripts,
"sd"]/2, angle = 90, length = 0.04, col = c("red","blue")[ifelse(pnl <9,
1,2)])
  # lower
  panel.arrows(x0 = x, x1 = x,
   y0 = y, y1 = y- summData[subscripts,
"sd"]/2, angle = 90, length = 0.04, col = c("red","blue")[ifelse(pnl <9,
1,2)])

}# panel
)#
) ## useOuterStrips

You can fill in the LHS strip with a vector of names as required

If you want to amend the ylimits  see ?combineLimits  in the latticeExtra
package

Duncan


-Original Message-
From: Anna Zakrisson Braeunlich [mailto:anna.zakris...@su.se] 
Sent: Tuesday, 24 September 2013 18:28
To: Duncan Mackay
Subject: RE: [R] lattice: double y - problem changing axis color after
doubleYScale

OK, now the code works - thank you. The error bars are added beautifully!

As I am using doubleYScale, I am having the problem that the first y-axis is
covered by the left hand strip - how can I solve this? I really much prefer
using outer.strip() and have one strip vertically on the plot. It saves plot
space.

I am still having the problem of colourful y-axis when using doubleYScale()
- how can I make them black?
I have the same problem with the error bars - they are also default colour
no matter what I tell them to be.
Is there a way around this except Adobe Photoshop?

Here is the working script with dummy data (you can just run the lot if you
have time). I really appreciate your code - thanks! ...and sorry for being a
bit daft and sending a reply before thinking it through properly.

Ndata <- data.frame(
  Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40),
   sd = rep(c(1, 3, 6), each = 40)),
  fyear = rep(c('2007', '2008'), each = 100*2),
  Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
  Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))

Pdata <- data.frame(
  Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40),
   sd = rep(c(0.1, 0.2, 0.4), each = 40)),
  fyear = rep(c('2007', '2008'), each = 100*2),
  Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
  Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))

SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, 
   mean = mean(Ncellpercent), 
   sd = sd(Ncellpercent))
names(Pdata)
SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, 
   mean = mean(Ppercentcell), 
   sd = sd(Ppercentcell)) SummPdata

plotNtest <- useOuterS

Re: [R] Arcsine transformation

2013-09-24 Thread Michael Dewey

At 02:26 23/09/2013, peake wrote:

Thanks for the advice. Like I said, I am still pretty new to R, and stats
in general. I tried wading through the search results on google, but I
didn't really find anything that I could understand. I am working with
percentages as my dependent variable, and I am trying to get my
distribution as close to normal as possible. Is an arcsine transformation
even the correct choice for my data? Querying R for help usually leaves me
even more confused, so I was hoping someone could help me out by walking me
through the process.


Transforming proportions is something which people involved in 
meta-analysis of non-comparative studies often do. You might like to 
look in the manual for metafor (on CRAN) and the function escalc 
which has a range of options under non-comparative studies. You might 
also look at betareg (on CRAN).


I think you also need to find some local statistical support as your 
question is now less about R and more about statistics.





On Sun, Sep 22, 2013 at 8:00 PM, chuck.01 [via R] <
ml-node+s789695n4676708...@n4.nabble.com> wrote:

> ?asin
>
> also, try "Googling" anything you might want to do in R... it is there
>
> also, google... "R cheatsheet"  you will find several helpful sheets of
> useful functions.
>
>
>
> peake wrote
> I am tryin to perform an arcsine transformation on my data containig
> percentages as the dep. variable. Does anyone have a code that I could use
> to do that? I am relatively new to R. Thanks for your help!
>
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706p4676708.html
>  To unsubscribe from Arcsine transformation, click 
here

> .
> 
NAML

>




--
View this message in context: 
http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706p4676712.html

Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]


Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

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


Re: [R] how to add a box to map plotted by a levelplot?

2013-09-24 Thread Pascal Oettli
Hello,

One way is:
> levelplot(r, col.regions=myPal) +
> layer(sp.polygons(wrld_simpl, lwd=0.5)) +
> layer(panel.rect(2,45,8,51))

Regards,
Pascal



2013/9/24 Jonsson 

> conne2 <- file("C:\\ome1440s.bin","rb")
>  bioms<- readBin(conne2, integer(), size=1,  n=1440*720, signed=F)
> library(raster)
> library(rasterVis)
> data(wrld_simpl)
>   library(maptools) ## needed for wrld_simpl
> r <- raster(nrow=720, ncol=1440)
> r[] <- bioms;r <- ratify(r);rat <- levels(r)[[1]];
> rat$soil <- LETTERS[1:13]; levels(r) <- rat
>  myPal <- c('gray80','gray80','blanchedalmond'
>
> ,'chartreuse','yellow','navajowhite2','salmon','lightskyblue','brown4','orange','burlywood4','palegreen','forestgreen')
>
>  levelplot(r, col.regions=myPal) +
> layer(sp.polygons(wrld_simpl, lwd=0.5))
>
> I want to add a box representing this zone of latitude and longtitude:
>
>  e6 <- extent( 2  , 8 , 45   , 51  )#erop
>   plot( e6 , add = TRUE )
> but I got this
>
>  Error: invalid graphics state
> Error: invalid graphics state
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-add-a-box-to-map-plotted-by-a-levelplot-tp4676815.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

[[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] how to add a box to map plotted by a levelplot?

2013-09-24 Thread Jonsson
conne2 <- file("C:\\ome1440s.bin","rb")
 bioms<- readBin(conne2, integer(), size=1,  n=1440*720, signed=F)
library(raster)
library(rasterVis)
data(wrld_simpl)
  library(maptools) ## needed for wrld_simpl
r <- raster(nrow=720, ncol=1440)
r[] <- bioms;r <- ratify(r);rat <- levels(r)[[1]];   
rat$soil <- LETTERS[1:13]; levels(r) <- rat
 myPal <- c('gray80','gray80','blanchedalmond'
,'chartreuse','yellow','navajowhite2','salmon','lightskyblue','brown4','orange','burlywood4','palegreen','forestgreen')
   
 levelplot(r, col.regions=myPal) +
layer(sp.polygons(wrld_simpl, lwd=0.5))
 
I want to add a box representing this zone of latitude and longtitude:

 e6 <- extent( 2  , 8 , 45   , 51  )#erop
  plot( e6 , add = TRUE )
but I got this

 Error: invalid graphics state
Error: invalid graphics state



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-add-a-box-to-map-plotted-by-a-levelplot-tp4676815.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] request for help in R

2013-09-24 Thread atta ahmad
respectd sir, 
i am working on regional frequency analysis of flood flow data and want to use 
packages lmomRFA, lmom, imomco,etc andby using these i want to find RMSE , 
errorbounds and absolute biase but could not make it clear to use, please help
regards
atta muhammad asif
assistant professor
atta_...@yahoo.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] no answer to the following question

2013-09-24 Thread Michel
I sent this message :
Hello everyone,
R beginner, I am confronted with the need to use
Rmpf.
In my first scripts I made use of 
X=read.table(file.choose(), header=FALSE,
sep=",",dec=".") 
X=as.matrix(X)
to load into a matrix data  from file before matrix
use.
How can I do to load the same data in a
"mpfrMatrix".
Is it possible to use with "mpfrMatrix" the same as
operations
M1%*%M2 
scale(M1,TRUE,FALSE)
Sorry but I'm a newbe

Thanks in advance

Michel

But no body ... may be my question appear too simple for r-help people
I'll try alone using books
Thank you anyway


[[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] Creating dummy vars with contrasts - why does the returned identity matrix contain all levels (and not n-1 levels) ?

2013-09-24 Thread E Joffe
Hi David,

Thank you for your interest and advice regarding this analysis.
I went to double check that the subset process worked properly with the
select=c(-time,-status) and I can confirm that it did.

Best,
Erel

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Friday, September 20, 2013 5:12 PM
To: E Joffe
Cc: r-help@r-project.org
Subject: Re: [R] Creating dummy vars with contrasts - why does the returned
identity matrix contain all levels (and not n-1 levels) ?


On Sep 13, 2013, at 11:21 PM, E Joffe wrote:

> Hi David,
>
> First I ordered the levels of each factor in a descending order based 
> on frequency.
> Then, I used the following code to generate a matrix from the 
> dataframe with dummy variables and  subsequently run the glmnet 
> (coxnet)
>
> ## tranform categorical variables into binary variables with dummy for 
> trainSet predict_matrix <- model.matrix(~ ., data=trainSet,
>  contrasts.arg = lapply 
> (trainSet[,sapply(trainSet, is.factor)], contrasts))
>
> ## remove the status/time variables from the predictor matrix (x) for 
> glmnet predict_matrix <- subset (predict_matrix, 
> select=c(-time,-status))
>
> ## create a glmnet cox object using lasso regularization and cross 
> validation glmnet.cv <- cv.glmnet (predict_matrix, surv_obj, 
> family="cox")
>
>
> I hope I did not do anything wrong .
>
> Can't thank you enough for your advice and interest.

Thank you for outlining the process that you used. It looks "from the
outside" as though it respects the constraints on the first two argument
imposed by the more constrained input requirements of cv.glmnet. I didn't
realize that subset could accept a `-`sign as an operator inside a c()
expression, but if you are getting success then I guess it must.

--
David.



> Erel
>
>
>
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net]
> Sent: Friday, September 13, 2013 8:51 PM
> To: E Joffe
> Cc: r-help@r-project.org
> Subject: Re: [R] Creating dummy vars with contrasts - why does the  
> returned
> identity matrix contain all levels (and not n-1 levels) ?
>
>
> On Sep 13, 2013, at 9:33 AM, E Joffe wrote:
>
>> Thank you so much for your answer  !
>> As far as I understand, glmnet doesn't accept categorical variables
>> only binary factors - so I had to create dummy variables for all
>> categorical variables.
>
> I was rather puzzled by your question. The conventions used by  
> glmnet should
> prevent constrasts from being pre-specified. Only matrices are  
> accepted as
> data objects and one cannot assign contrast attributes to matrix  
> columns.
>
>> It worked perfectly.
>> Erel
>>
>>
>> Erel Joffe MD MSc
>> School of Biomedical Informatics
>> University of Texas - Health Science Center in Houston
>> 832.287.0829 (c)
>>
>> -Original Message-
>> From: David Winsemius [mailto:dwinsem...@comcast.net]
>> Sent: Friday, September 13, 2013 3:05 PM
>> To: E Joffe
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Creating dummy vars with contrasts - why does the
>> returned identity matrix contain all levels (and not n-1 levels) ?
>>
>>
>> On Sep 13, 2013, at 4:15 AM, E Joffe wrote:
>>
>>> Hello,
>>>
>>>
>>>
>>> I have a problem with creating an identity matrix for glmnet by  
>>> using
>>> the contrasts function.
>>
>> Why do you want to do this?
>>
>>> I have a factor with 4 levels.
>>>
>>> When I create dummy variables I think there should be n-1 variables
>>> (in this case 3) - so that the contrasts would be against the
>>> baseline level.
>>>
>>> This is also what is written in the help file for 'contrasts'.
>>>
>>> The problem is that the function creates a matrix with n variables
>>> (i.e. the same as the number of levels) and not n-1 (where I would
>>> have a baseline level for comparison).
>>
>> Only if you specify contrasts=FALSE does it do so and this is
>> documented in that help file.
>>>
>>>
>>>
>>> My questions are:
>>>
>>> 1.   How can I create a matrix with n-1 dummy vars ?
>>
>> See below.
>>
>>> was I supposed to
>>> define explicitly that I want contr.treatment (contrasts) ?
>>
>> No need to do so.
>>
>>>
>>> 2.   If it is not possible, how should I interpret the hazard
>>> ratios in
>>> the Cox regression I am generating (I use glmnet for variable
>>> selection and
>>> then generate a Cox regression)  - That is, if I get an HR of 3 for
>>> the
>>> variable 300mg what does it mean ? the hazard is 3 times higher of
>>> what ?
>>>
>>
>> Relative hazards are generally referenced to the "baseline hazard",
>> i.e. the hazard for a group with the omitted level for treatment
>> constrasts and the mean value for any numeric predictors.
>>
>>> Here is some code to reproduce the issue:
>>>
>>> # Create a 4 level example factor
>>>
>>> trt <- factor( sample( c("PLACEBO", "300 MG", "600 MG", "1200 MG"),
>>>
>>>  100, replace=TRUE ) )
>>
>> # If your intent is to use constrasts different than the defaults  
>> used

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-24 Thread Prof Brian Ripley

On 24/09/2013 03:51, Jose Claudio Faria wrote:

I think I found the main problem!

I am developing the package under Linux and after R CMD build,
manually compressing the folder TinnRcom inside of the folder
TinnRcom.RCheck and installing in Windows.


And how on earth did you expect the helpers here to know that you were 
subverting the R installation procedures?


For a package without compiled code (as this must be for that to work) 
it really is very simple


R CMD build TinnRcom # on Linux
install.packages('TinnRcom_xx-x.tar.gz") # on Windows: no extra tools 
are needed.



As the APPDATA environment variable does not exist in Linux, the
function Sys.getenv ("APPDATA") is returning an empty string.

I think the problem is it, now it is necessary to find a solution.
Does anyone have a clue?


You really do not want to do this at install time (or the settings will 
be for the user who installs for source, Uwe Ligges for most Windows 
users).  Use .onLoad.


We write R manuals to explain this sort of thing:  fortunes::fortune(14) 
applies.


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


Re: [R] time zones from longitude, latitude, and date

2013-09-24 Thread Prof Brian Ripley

On 23/09/2013 22:43, MacQueen, Don wrote:

The very first response, from Jeff Newmiller, included a link
http://efele.net/maps/tz/world/
which says it has offers a shapefile of timezones of the world.

An outline of a solution, then it to

   download the shapefile
   load it into R
   input your lat/long data into R
   use the over() function in the sp package

Of course there are many details amongst those steps; I would suggest
r-sig-geo would be the place for help with those details.

It remains to be seen whether the way in which the timezones are
identified in that shapefile is compatible with how timezones are
identified in R POSIXt classes (R uses the OS for this). Daylight savings
time information is, I believe, provided by the OS for at least some time
zones, but I don't know if its provided for all of them.


It needs to be.  That is why the tzone databases are so large and 
complex and change several times a year.


Actually, the info is provided by the OS except on Windows where the 
Olsen/IANA database is used (as it is by almost all other current OSes). 
 So timezone names are fairly portable.


I thought I read in this thread that these were recordings at sea: see 
the caveats at that URL (it only applies on land ...).



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