Re: [R] 'class(.) == **' [was 'Call to a function']

2015-06-25 Thread Steven Yen

Thanks Davis. But actually, the line is legitimate:

   if (inherits(wt,what="character")) wt<-data[,wt]

because, coming down with wt being characters, the part wt<-data[,wt] 
then picks up variables data$wt. The call


   wmean(mydata,wt="weight")

actually goes OK. I was hoping to figure out a way to fix the wmean 
routine some how so that I can call with


   wmean(mydata,wt=weight)

Good to know there is a better way to initialize the vector Mean and and 
a better list command. Thank you!


On 6/26/2015 2:39 AM, David Winsemius wrote:


On Jun 25, 2015, at 7:48 PM, Steven Yen wrote:


Thanks to all for the help. I have learned much about "inherit" and "class". I 
like to know about one additional option, and that is to use a calling parameter without the 
quotation marks, similar to the linear regression syntax:

lm(data=mydata,weights=wt)

Below is a simple set of codes to calculate weighted means with generated data in data 
frame "mydata". As annotated below, I like the following call to work (without 
the quotations):

wmean(mydata,wt=weight)


Let's start with the call. If you are to execute this,  then names `mydata` and 
`weight` each must have a value.



Thank you!


mydata<-matrix(1:20,ncol=2)


OK. There is a value having been assigned to `mydata`


mydata<-cbind(mydata,runif(10,0,1))


And now augmented.


colnames(mydata)<-c("y","x","weight")


And a names attribute added for its columns.


mydata<-as.data.frame(mydata)

wmean <- function(data,wt){
  if (inherits(wt,what="character")) wt<-data[,wt]
  wt<-wt/mean(wt)


Here's the problem. If `wt` was of mode "character", then you cannot divide it 
by a number, since the RHS will be evaluated first. You really should read the error 
messages!

Perhaps you meant:

wt <-  data[, wt]/mean(data[ , wt]

But if you did, then it's rather confusing (but possible) to assign the value 
to the same name as the column of the matrix.



  Mean<-NULL


Why do that? If you remove it from the workspace then you cannot assign a value 
using indexed assignment as you apparently intend to do. Should have been

Mean <- numeric( ncol(data) )



  for (i in 1:ncol(data)){
Mean[i] <- sum(data[,i]*wt)/sum(wt)


There is a bit of a confusion here. `wt` started out as a character value. I 
guess you could do this.


  }
  list("Mean: ",Mean)


Wrong syntax for lists. Suspect you want

list(Mean=Mean)



}
wmean(mydata,wt="weight") # This works
wmean(mydata,wt=weight)   # <= Like this to work


So were you planning to execute this first?

weight="weight" #?



--
Steven Yen
My e-mail alert:
https://youtu.be/9UwEAruhyhY?list=PLpwR3gb9OGHP1BzgVuO9iIDdogVOijCtO

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


[R] extracting significant response variables

2015-06-25 Thread adeela uaf
Hi,
My experiment consist of factorial structure with 25 genotypes and 3
salinity levels ( 25 cross 3) each with 3 replications.  14 responses were
taken from the experiment and I applied MANOVA but I am applying
discriminant analysis to know which response variable has significant
impact on the separation of groups. I am doing the following:
MANOVA<-manova(cbind(RL,SL,RFW,SFW,RDW,SDW,R.S..DW.,LA,NL,Na,K,Ca)~geneotype*S.Level,data=data)
For discriminant analysis, I made a group of 1 genotype with one level of
Salinity level hence a total of 75 groups.
group<-paste("g", gl(75,3,length=225))
LDA<-lda(group~RL+SL+RFW+SFW+RDW+SDW+R.S..DW.+LA+NL+Na+K+Ca+K.Na+Ca.Na,data=Sdata)

Is it appropriate way? Moreover when I am plotting discriminant scores
means with the circle of radius r=z/sqrt(replication) but the graph doesn't
make any sense as the circles are too small too see.
Thanks,
Adeela


lda.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] R lattice : labeling of matrix groups of different size with strips

2015-06-25 Thread R codeplayer
Hi Duncan,


thank you so much for your help.


2015-06-26 4:16 GMT+02:00 Duncan Mackay :
> I am not sure that changing the aspect ratio by using
> levelplot(plotMatrix[,,2],
>  aspect = 1/0.6,
>  ...)

I already experimented with different values of aspect but I newer get
the height of the groups to match


>
> will do the job as I seem to remember doing something like that when first 
> looking at your problem. There were unwanted side effects
>
> using grid.arrange is the quick way to fill the plot area, I rarely use it
>
> You may be better off by using print - I have not got your original data so I 
> can only guess
> eg
>
> print(plot2, position = c(0.2,0,0.8,0.5), more = TRUE)
> print(plot1 position = c(0,0.5,1.1), more = FALSE)

In this approach, I get a different size for the height and width of the groups.

> You may have to fiddle with the position values for plot2 to get it right.
>
> If the text of plot2 is too small then you could put a line in to get plot2
> par.settings = list(fontsize = list(text = 12.5, points = 8)),
> this is device dependent and you may need to change it
>
>  Regards
>
> Duncan
>

Thank you for your time

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of R codeplayer
> Sent: Thursday, 25 June 2015 21:01
> To: r-help@r-project.org
> Subject: Re: [R] R lattice : labeling of matrix groups of different size with 
> strips
>
> Hi Duncan,
>
>
> thank you very much for your help.
>
>
> Originally, I thought that it is possible to use a different data
> representation and then to automatically create the plots and strips
> in lattice.
>
> Based on your suggestion, I could write the code for an annotated
> levelplot of the two groups (code is shown below).
>
> An open question is how to display the two groups with the same aspect
> ratio for the rows.
>
>
>> plotMatrix
>> , , group1
>>
>>   a b c d
>> 1 1 0 0 0
>> 2 1 0 0 0
>> 3 1 1 0 0
>> 4 0 1 0 0
>> 5 0 1 1 0
>>
>> , , group2
>>
>>a  b  c  d
>> 1  0  0  1  0
>> 2  0  0  1  1
>> 3  0  0  0  1
>> 4 NA NA NA NA
>> 5 NA NA NA NA
>
> library(gridExtra)
>
> trellis.device(device = "pdf",file
> ="lattice_annotated_groups.pdf",width=8,height=5)
>
> #The aspect="fill" option was added to coerce the same height of the 2 plots
> #panel.text was used instead of grid.text to avoid using the
> latticeExtra package
>
> plot1 <- levelplot(plotMatrix[,,1],
>  page = function(n)
>  panel.text("group 1",
>  x = 0.5,
>  y = 0.96),
>  colorkey = F,
>  xlab = "",
>  ylab="",
>  aspect="fill")
>
> pm <- plotMatrix[1:3,,2]
> colnames(pm) <- rep("",ncol(pm))
>
> plot2 <-levelplot(pm,
> page = function(n)
> panel.text(
> "group 2",
>  x = 0.5,
>  y = 0.96),
> colorkey = F,
> xlab = "",
> ylab="",
> aspect="fill")
>
>
> grid.arrange(plot1,plot2,ncol=2)
> dev.off()
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] 'class(.) == **' [was 'Call to a function']

2015-06-25 Thread David Winsemius

On Jun 25, 2015, at 7:48 PM, Steven Yen wrote:

> Thanks to all for the help. I have learned much about "inherit" and "class". 
> I like to know about one additional option, and that is to use a calling 
> parameter without the quotation marks, similar to the linear regression 
> syntax:
> 
> lm(data=mydata,weights=wt)
> 
> Below is a simple set of codes to calculate weighted means with generated 
> data in data frame "mydata". As annotated below, I like the following call to 
> work (without the quotations):
> 
> wmean(mydata,wt=weight)

Let's start with the call. If you are to execute this,  then names `mydata` and 
`weight` each must have a value.

> 
> Thank you!
> 
> 
> mydata<-matrix(1:20,ncol=2)

OK. There is a value having been assigned to `mydata`

> mydata<-cbind(mydata,runif(10,0,1))

And now augmented.

> colnames(mydata)<-c("y","x","weight")

And a names attribute added for its columns.

> mydata<-as.data.frame(mydata)
> 
> wmean <- function(data,wt){
>  if (inherits(wt,what="character")) wt<-data[,wt]
>  wt<-wt/mean(wt)

Here's the problem. If `wt` was of mode "character", then you cannot divide it 
by a number, since the RHS will be evaluated first. You really should read the 
error messages!

Perhaps you meant:

wt <-  data[, wt]/mean(data[ , wt]

But if you did, then it's rather confusing (but possible) to assign the value 
to the same name as the column of the matrix.


>  Mean<-NULL

Why do that? If you remove it from the workspace then you cannot assign a value 
using indexed assignment as you apparently intend to do. Should have been

Mean <- numeric( ncol(data) )


>  for (i in 1:ncol(data)){
>Mean[i] <- sum(data[,i]*wt)/sum(wt)

There is a bit of a confusion here. `wt` started out as a character value. I 
guess you could do this.

>  }
>  list("Mean: ",Mean)

Wrong syntax for lists. Suspect you want

   list(Mean=Mean)


> }
> wmean(mydata,wt="weight") # This works
> wmean(mydata,wt=weight)   # <= Like this to work

So were you planning to execute this first?

weight="weight" #?

-- 
David.


> reg<-lm(data=mydata,weights=weight) # ? lm
> 
> On 6/24/2015 3:20 AM, Martin Maechler wrote:
>>> Steve Taylor 
>>> on Wed, 24 Jun 2015 00:56:26 + writes:
>> 
>> > Note that objects can have more than one class, in which case your == 
>> and %in% might not work as expected.
>> 
>> > Better to use inherits().
>> 
>> > cheers,
>> > Steve
>> 
>> Yes indeed, as Steve said, really do!
>> 
>> The use of   (class(.) == "")   it is error prone and
>> against the philosophy of classes (S3 or S4 or ..) in R :
>> 
>> Classes can "extend" other classes or "inherit" from them;
>> S3 examples in "base R"  are
>>  - glm() objects which are "glm"
>>but also inherit from "lm"
>>  - multivariate time-series are "mts" and "ts"
>>  - The time-date objects  POSIXt , POSIXct, POSIXlt
>> 
>> ==> do work  with  inherits(, > or  possibly   is( , )
>> 
>> 
>> We've seen this use of   
>> 
>>  class(.) == ".."(or '!=" or  %in% ...)
>> 
>> in too many places;  though it may work fine in your test cases,
>> it is wrong to be used in generality e.g. inside a function you
>> provide for more general use,
>> and is best  replaced with the use of inherits() / is()
>> everywhere  "out of principle".
>> 
>> Martin Maechler
>> ETH Zurich
>> 
> 
> -- 
> Steven Yen
> My e-mail alert:
> https://youtu.be/9UwEAruhyhY?list=PLpwR3gb9OGHP1BzgVuO9iIDdogVOijCtO
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] VCD package - Setting confidence interval for oddsratio and loddsratio

2015-06-25 Thread My List
All:

I am using oddsratio() and loddsratio() from the VCD package. How do I set
the confidence interval for the these functions.I want to set it 95 %.I
have thought that the odds ratio functions don't need confidence interval
for calculation , but yes for interpretation they use confidence intervals,
with the Z statistic.

I apologize if I am wrong in my thinking.

Thanks in Advance,
Harmeet

[[alternative HTML version deleted]]

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


Re: [R] how to change the "ff" properties of a "ff"-related R object after the original "ff" output folder has been moved

2015-06-25 Thread David Winsemius

On Jun 25, 2015, at 4:04 PM, Shi, Tao via R-help wrote:

> Hi all,
> 
> I'm new to "ff" package through the using Bioconductor package "crlmm".  Here 
> is my problem:
> 
> I've created a few R objects (e.g. an CNSet) using crlmm based on my data and 
> save them in a .RData file.  crlmm heavily uses ff package to store results 
> on a local folder.  For certain reasons, I have moved the ff output folder to 
> somewhere else.  Now when I go back to R, I can't open those CNSet, for 
> example, anymore, as the file has a property still storing the old ff output 
> folder path. 
> 
> My question is: is there a quick way to change these paths to the new one, so 
> I don't have to re-run the own analysis.
> 

The way to approach this is to create a small example that illustrates teh 
problem. In many case all will becove clear, but if not then you will have 
something that you can then post ... IN R CODE ... that will let us (most of 
whom are not ff-urers) see the problem.

--
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] 'class(.) == **' [was 'Call to a function']

2015-06-25 Thread Steven Yen
Thanks to all for the help. I have learned much about "inherit" and 
"class". I like to know about one additional option, and that is to use 
a calling parameter without the quotation marks, similar to the linear 
regression syntax:


lm(data=mydata,weights=wt)

Below is a simple set of codes to calculate weighted means with 
generated data in data frame "mydata". As annotated below, I like the 
following call to work (without the quotations):


wmean(mydata,wt=weight)

Thank you!


mydata<-matrix(1:20,ncol=2)
mydata<-cbind(mydata,runif(10,0,1))
colnames(mydata)<-c("y","x","weight")
mydata<-as.data.frame(mydata)

wmean <- function(data,wt){
  if (inherits(wt,what="character")) wt<-data[,wt]
  wt<-wt/mean(wt)
  Mean<-NULL
  for (i in 1:ncol(data)){
Mean[i] <- sum(data[,i]*wt)/sum(wt)
  }
  list("Mean: ",Mean)
}
wmean(mydata,wt="weight") # This works
wmean(mydata,wt=weight)   # <= Like this to work
reg<-lm(data=mydata,weights=weight) # ? lm

On 6/24/2015 3:20 AM, Martin Maechler wrote:

Steve Taylor 
 on Wed, 24 Jun 2015 00:56:26 + writes:


 > Note that objects can have more than one class, in which case your == 
and %in% might not work as expected.

 > Better to use inherits().

 > cheers,
 > Steve

Yes indeed, as Steve said, really do!

The use of   (class(.) == "")   it is error prone and
against the philosophy of classes (S3 or S4 or ..) in R :

Classes can "extend" other classes or "inherit" from them;
S3 examples in "base R"  are
  - glm() objects which are "glm"
but also inherit from "lm"
  - multivariate time-series are "mts" and "ts"
  - The time-date objects  POSIXt , POSIXct, POSIXlt

==> do work  with  inherits(, , )


We've seen this use of  

  class(.) == ".."(or '!=" or  %in% ...)

in too many places;  though it may work fine in your test cases,
it is wrong to be used in generality e.g. inside a function you
provide for more general use,
and is best  replaced with the use of inherits() / is()
everywhere  "out of principle".

Martin Maechler
ETH Zurich



--
Steven Yen
My e-mail alert:
https://youtu.be/9UwEAruhyhY?list=PLpwR3gb9OGHP1BzgVuO9iIDdogVOijCtO

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


Re: [R] R lattice : labeling of matrix groups of different size with strips

2015-06-25 Thread Duncan Mackay
I am not sure that changing the aspect ratio by using 
levelplot(plotMatrix[,,2],
 aspect = 1/0.6,
 ...)

will do the job as I seem to remember doing something like that when first 
looking at your problem. There were unwanted side effects

using grid.arrange is the quick way to fill the plot area, I rarely use it

You may be better off by using print - I have not got your original data so I 
can only guess
eg

print(plot2, position = c(0.2,0,0.8,0.5), more = TRUE)
print(plot1 position = c(0,0.5,1.1), more = FALSE)

You may have to fiddle with the position values for plot2 to get it right.

If the text of plot2 is too small then you could put a line in to get plot2
par.settings = list(fontsize = list(text = 12.5, points = 8)),  
this is device dependent and you may need to change it

 Regards

Duncan


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of R codeplayer
Sent: Thursday, 25 June 2015 21:01
To: r-help@r-project.org
Subject: Re: [R] R lattice : labeling of matrix groups of different size with 
strips

Hi Duncan,


thank you very much for your help.


Originally, I thought that it is possible to use a different data
representation and then to automatically create the plots and strips
in lattice.

Based on your suggestion, I could write the code for an annotated
levelplot of the two groups (code is shown below).

An open question is how to display the two groups with the same aspect
ratio for the rows.


> plotMatrix
> , , group1
>
>   a b c d
> 1 1 0 0 0
> 2 1 0 0 0
> 3 1 1 0 0
> 4 0 1 0 0
> 5 0 1 1 0
>
> , , group2
>
>a  b  c  d
> 1  0  0  1  0
> 2  0  0  1  1
> 3  0  0  0  1
> 4 NA NA NA NA
> 5 NA NA NA NA

library(gridExtra)

trellis.device(device = "pdf",file
="lattice_annotated_groups.pdf",width=8,height=5)

#The aspect="fill" option was added to coerce the same height of the 2 plots
#panel.text was used instead of grid.text to avoid using the
latticeExtra package

plot1 <- levelplot(plotMatrix[,,1],
 page = function(n)
 panel.text("group 1",
 x = 0.5,
 y = 0.96),
 colorkey = F,
 xlab = "",
 ylab="",
 aspect="fill")

pm <- plotMatrix[1:3,,2]
colnames(pm) <- rep("",ncol(pm))

plot2 <-levelplot(pm,
page = function(n)
panel.text(
"group 2",
 x = 0.5,
 y = 0.96),
colorkey = F,
xlab = "",
ylab="",
aspect="fill")


grid.arrange(plot1,plot2,ncol=2)
dev.off()

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 change the "ff" properties of a "ff"-related R object after the original "ff" output folder has been moved

2015-06-25 Thread Shi, Tao via R-help
Hi all,

I'm new to "ff" package through the using Bioconductor package "crlmm".  Here 
is my problem:

I've created a few R objects (e.g. an CNSet) using crlmm based on my data and 
save them in a .RData file.  crlmm heavily uses ff package to store results on 
a local folder.  For certain reasons, I have moved the ff output folder to 
somewhere else.  Now when I go back to R, I can't open those CNSet, for 
example, anymore, as the file has a property still storing the old ff output 
folder path. 

My question is: is there a quick way to change these paths to the new one, so I 
don't have to re-run the own analysis.

Many thanks!

Tao

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr, summarize_each, mean - dealing with NAs

2015-06-25 Thread David Winsemius

On Jun 25, 2015, at 1:25 PM, Dimitri Liakhovitski wrote:

> Hello!
> 
> I have a data frame md:
> 
>md <- data.frame(x = c(3,5,4,5,3,5), y = c(5,5,5,4,4,1), z = 
> c(1,3,4,3,5,5),
>  device1 = c("c","a","a","b","c","c"), device2 =
> c("B","A","A","A","B","B"))
>md[2,3] <- NA
>md[4,1] <- NA
>md
> 
> I want to calculate means by device1 / device2 combinations using dplyr:
> 
>library(dplyr)
>md %>% group_by(device1, device2) %>% summarise_each(funs(mean))
> 
> However, I am getting some NAs. I want the NAs to be ignored (na.rm =
> TRUE) - I tried, but the function doesn't want to accept this
> argument.


The help page for the `funs`-function has several examples:

This succeeds:

   md %>% group_by(device1, device2) %>% summarise_each(funs(mean( ., 
na.rm=TRUE


> Both these lines result in error:
> 
>md %>% group_by(device1, device2) %>% summarise_each(funs(mean),
> na.rm = TRUE)
>md %>% group_by(device1, device2) %>% summarise_each(funs(mean,
> na.rm = TRUE))
> 
> Thank you for your advice!
> 
> 
> -- 
> Dimitri Liakhovitski
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Codependents Cycles

2015-06-25 Thread Rafael Costa
Dear R users,

Where can I find the codes to test codependent cycles? This test was
presented on paper "Codependents Cycles" (Vahid and Engle, 1997).

I am looking forward  any help.

Thanks in advance ,

Rafael Costa.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] prmatrix and print.matrix

2015-06-25 Thread Therneau, Terry M., Ph.D.
The help page for prmatrix states that it only exists for backwards compatability and 
strongly hints at using print.matrix instead.

 However, there does not seem to be a print.matrix() function.

The help page for print mentions a zero.print option, but that does not appear to affect 
matrices.  This (or something like it) is what I was looking for.


Am I overlooking something?

Terry Therneau

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr, summarize_each, mean - dealing with NAs

2015-06-25 Thread Dimitri Liakhovitski
I found the answer:

md %>% group_by(device1, device2) %>% summarise_each(funs(mean(.,
na.rm = TRUE)))

On Thu, Jun 25, 2015 at 4:35 PM, Dimitri Liakhovitski
 wrote:
> Just want to clarify - I know how to do it using base R. I just want
> to figure out how to do it in dplyr. This i what I want to achieve:
>
> myvars <- c("x","y","z")
> aggregate(md[myvars], by = md[c("device1","device2")], mean, na.rm = T)
>
> Thank you!
>
> On Thu, Jun 25, 2015 at 4:25 PM, Dimitri Liakhovitski
>  wrote:
>> Hello!
>>
>> I have a data frame md:
>>
>> md <- data.frame(x = c(3,5,4,5,3,5), y = c(5,5,5,4,4,1), z = 
>> c(1,3,4,3,5,5),
>>   device1 = c("c","a","a","b","c","c"), device2 =
>> c("B","A","A","A","B","B"))
>> md[2,3] <- NA
>> md[4,1] <- NA
>> md
>>
>> I want to calculate means by device1 / device2 combinations using dplyr:
>>
>> library(dplyr)
>> md %>% group_by(device1, device2) %>% summarise_each(funs(mean))
>>
>> However, I am getting some NAs. I want the NAs to be ignored (na.rm =
>> TRUE) - I tried, but the function doesn't want to accept this
>> argument.
>> Both these lines result in error:
>>
>> md %>% group_by(device1, device2) %>% summarise_each(funs(mean),
>> na.rm = TRUE)
>> md %>% group_by(device1, device2) %>% summarise_each(funs(mean,
>> na.rm = TRUE))
>>
>> Thank you for your advice!
>>
>>
>> --
>> Dimitri Liakhovitski
>
>
>
> --
> Dimitri Liakhovitski



-- 
Dimitri Liakhovitski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr, summarize_each, mean - dealing with NAs

2015-06-25 Thread Dimitri Liakhovitski
Just want to clarify - I know how to do it using base R. I just want
to figure out how to do it in dplyr. This i what I want to achieve:

myvars <- c("x","y","z")
aggregate(md[myvars], by = md[c("device1","device2")], mean, na.rm = T)

Thank you!

On Thu, Jun 25, 2015 at 4:25 PM, Dimitri Liakhovitski
 wrote:
> Hello!
>
> I have a data frame md:
>
> md <- data.frame(x = c(3,5,4,5,3,5), y = c(5,5,5,4,4,1), z = 
> c(1,3,4,3,5,5),
>   device1 = c("c","a","a","b","c","c"), device2 =
> c("B","A","A","A","B","B"))
> md[2,3] <- NA
> md[4,1] <- NA
> md
>
> I want to calculate means by device1 / device2 combinations using dplyr:
>
> library(dplyr)
> md %>% group_by(device1, device2) %>% summarise_each(funs(mean))
>
> However, I am getting some NAs. I want the NAs to be ignored (na.rm =
> TRUE) - I tried, but the function doesn't want to accept this
> argument.
> Both these lines result in error:
>
> md %>% group_by(device1, device2) %>% summarise_each(funs(mean),
> na.rm = TRUE)
> md %>% group_by(device1, device2) %>% summarise_each(funs(mean,
> na.rm = TRUE))
>
> Thank you for your advice!
>
>
> --
> Dimitri Liakhovitski



-- 
Dimitri Liakhovitski

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr, summarize_each, mean - dealing with NAs

2015-06-25 Thread Dimitri Liakhovitski
Hello!

I have a data frame md:

md <- data.frame(x = c(3,5,4,5,3,5), y = c(5,5,5,4,4,1), z = c(1,3,4,3,5,5),
  device1 = c("c","a","a","b","c","c"), device2 =
c("B","A","A","A","B","B"))
md[2,3] <- NA
md[4,1] <- NA
md

I want to calculate means by device1 / device2 combinations using dplyr:

library(dplyr)
md %>% group_by(device1, device2) %>% summarise_each(funs(mean))

However, I am getting some NAs. I want the NAs to be ignored (na.rm =
TRUE) - I tried, but the function doesn't want to accept this
argument.
Both these lines result in error:

md %>% group_by(device1, device2) %>% summarise_each(funs(mean),
na.rm = TRUE)
md %>% group_by(device1, device2) %>% summarise_each(funs(mean,
na.rm = TRUE))

Thank you for your advice!


-- 
Dimitri Liakhovitski

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


Re: [R] Extracting data from a file containing data

2015-06-25 Thread jim holtman
try this:

> input <- read.table("C:\\Users\\jh52822\\Downloads\\Nino_indices.txt"
+ , header = TRUE
+ , as.is = TRUE
+ )
> # create factors
> input$season <- factor(c(rep("JF", 2), rep("MAM", 3), rep("JJA", 3)
+ , NA, rep("OND", 3)
+ )[input$MON], levels = c("JF", "MAM", "JJA", "OND"))
>
> # leave off the MON (-2) column from the data
> res <- aggregate(. ~ season + YR, data = input[, -2], FUN = 'mean')
> head(res,10)
   season   YR  NINO1.2   ANOMNINO3 ANOM.1NINO4 ANOM.2
 NINO3.4 ANOM.3
1  JF 1982 24.89000 -0.375 26.12500  0.125 28.25500  0.055
26.71000  0.065
2 MAM 1982 24.56000 -0.837 27.48333  0.243 28.94000  0.447
27.92000  0.303
3 JJA 1982 22.37000  0.680 26.68333  1.003 29.39333  0.620
28.26000  1.030
4 OND 1982 24.55333  2.820 27.70667  2.693 29.25333  0.660
28.88667  2.250
5  JF 1983 27.75500  2.490 28.92000  2.920 28.89500  0.695
29.24500  2.600
6 MAM 1983 28.47667  3.080 29.06333  1.823 28.89667  0.403
28.94333  1.327
7 JJA 1983 25.72333  4.033 26.88000  1.200 28.63667 -0.137
27.28000  0.050
8 OND 1983 22.25667  0.523 24.40667 -0.607 27.77667 -0.817
25.68000 -0.957
9  JF 1984 24.68000 -0.585 25.52000 -0.480 27.44500 -0.755
26.01500 -0.630
10MAM 1984 24.79667 -0.600 26.97333 -0.267 27.62000 -0.873
27.21333 -0.403
>



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Thu, Jun 25, 2015 at 11:40 AM, Peter Tuju  wrote:

> I have the data as attached. For each nino region, I want to get the mean
> of the seasons January and February (JF), March, April and may (MAM), June,
> July and August (JJA), and October, November and December (OND) as columns
> of each nino regions. and have my result as;For example;
> For NINO1.2Years JF  MAMA JJA  OND 1982 1983..
> .2012
> Any guide please!
>
>
> _
> Peter  E. Tuju
> Dar es Salaam
> T A N Z A N I A
> --
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extracting data from a file containing data

2015-06-25 Thread jim holtman
What happened to September?  Just disregard?


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Thu, Jun 25, 2015 at 11:40 AM, Peter Tuju  wrote:

> I have the data as attached. For each nino region, I want to get the mean
> of the seasons January and February (JF), March, April and may (MAM), June,
> July and August (JJA), and October, November and December (OND) as columns
> of each nino regions. and have my result as;For example;
> For NINO1.2Years JF  MAMA JJA  OND 1982 1983..
> .2012
> Any guide please!
>
>
> _
> Peter  E. Tuju
> Dar es Salaam
> T A N Z A N I A
> --
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extracting data from a file containing data

2015-06-25 Thread David L Carlson
First, create a variable (a factor) for your categories (did you really intend 
to exclude September?).

Then use the aggregate function.

?factor
?aggregate

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

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Tuju
Sent: Thursday, June 25, 2015 10:40 AM
To: r-help@r-project.org
Subject: Re: [R] Extracting data from a file containing data

I have the data as attached. For each nino region, I want to get the mean of 
the seasons January and February (JF), March, April and may (MAM), June, July 
and August (JJA), and October, November and December (OND) as columns of each 
nino regions. and have my result as;For example;
For NINO1.2Years JF  MAMA JJA  OND 1982 1983    .    . .2012
Any guide please!


_
Peter  E. Tuju
Dar es Salaam
T A N Z A N I A
--
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Extracting data from a file containing data

2015-06-25 Thread Peter Tuju
I have the data as attached. For each nino region, I want to get the mean of 
the seasons January and February (JF), March, April and may (MAM), June, July 
and August (JJA), and October, November and December (OND) as columns of each 
nino regions. and have my result as;For example;
For NINO1.2Years JF  MAMA JJA  OND 1982 1983    .    . .2012
Any guide please!


_
Peter  E. Tuju
Dar es Salaam
T A N Z A N I A
--YR MON  NINO1+2   ANOM   NINO3ANOM   NINO4ANOM NINO3.4ANOM  
1982   1   24.29   -0.17   25.870.24   28.300.00   26.720.15
1982   2   25.49   -0.58   26.380.01   28.210.11   26.70   -0.02
1982   3   25.21   -1.31   26.98   -0.16   28.410.22   27.20   -0.02
1982   4   24.50   -0.97   27.680.18   28.920.42   28.020.24
1982   5   23.97   -0.23   27.790.71   29.490.70   28.540.69
1982   6   22.890.07   27.461.03   29.760.92   28.751.10
1982   7   22.470.87   26.440.82   29.380.58   28.100.88
1982   8   21.751.10   26.151.16   29.040.36   27.931.11
1982   9   21.801.44   26.521.67   29.160.47   28.111.39
1982  10   22.942.12   27.112.19   29.380.72   28.641.95
1982  11   24.593.00   27.622.64   29.230.60   28.812.16
1982  12   26.133.34   28.393.25   29.150.66   29.212.64
1983   1   27.422.96   28.923.29   29.000.70   29.362.79
1983   2   28.092.02   28.922.55   28.790.69   29.132.41
1983   3   28.682.16   29.101.96   28.760.57   29.031.81
1983   4   28.563.09   29.121.62   28.850.35   28.911.13
1983   5   28.193.99   28.971.89   29.080.29   28.891.04
1983   6   27.444.62   28.151.72   28.880.04   28.240.59
1983   7   25.954.35   26.621.00   28.65   -0.15   27.07   -0.15
1983   8   23.783.13   25.870.88   28.38   -0.30   26.53   -0.29
1983   9   22.241.88   25.240.39   28.23   -0.46   26.44   -0.28
1983  10   21.861.04   24.61   -0.31   27.75   -0.91   25.87   -0.82
1983  11   21.900.31   24.17   -0.81   27.76   -0.87   25.58   -1.07
1983  12   23.010.22   24.44   -0.70   27.82   -0.67   25.59   -0.98
1984   1   24.18   -0.28   24.82   -0.81   27.64   -0.66   25.64   -0.93
1984   2   25.18   -0.89   26.22   -0.15   27.25   -0.85   26.39   -0.33
1984   3   26.00   -0.52   27.12   -0.02   27.21   -0.98   26.86   -0.36
1984   4   25.16   -0.31   27.34   -0.16   27.70   -0.80   27.39   -0.39
1984   5   23.23   -0.97   26.46   -0.62   27.95   -0.84   27.39   -0.46
1984   6   21.96   -0.86   25.38   -1.05   28.13   -0.71   26.86   -0.79
1984   7   21.24   -0.36   24.96   -0.66   28.35   -0.45   26.74   -0.48
1984   8   20.17   -0.48   24.50   -0.49   28.17   -0.51   26.34   -0.48
1984   9   20.370.01   24.35   -0.50   28.61   -0.08   26.43   -0.29
1984  10   20.52   -0.30   23.95   -0.97   28.28   -0.38   25.93   -0.76
1984  11   21.50   -0.09   24.03   -0.95   27.99   -0.64   25.41   -1.24
1984  12   22.58   -0.21   23.70   -1.44   27.44   -1.05   25.00   -1.57
1985   1   23.59   -0.87   24.51   -1.12   27.71   -0.59   25.43   -1.14
1985   2   24.87   -1.20   25.19   -1.18   27.55   -0.55   25.67   -1.05
1985   3   25.74   -0.78   26.11   -1.03   27.38   -0.81   26.23   -0.99
1985   4   24.25   -1.22   26.52   -0.98   27.72   -0.78   26.80   -0.98
1985   5   22.29   -1.91   26.12   -0.96   28.06   -0.73   27.11   -0.74
1985   6   21.75   -1.07   25.60   -0.83   28.08   -0.76   26.86   -0.79
1985   7   20.44   -1.16   24.74   -0.88   28.28   -0.52   26.69   -0.53
1985   8   19.29   -1.36   24.40   -0.59   28.32   -0.36   26.50   -0.32
1985   9   19.44   -0.92   24.15   -0.70   28.33   -0.36   26.25   -0.47
1985  10   19.90   -0.92   24.15   -0.77   28.28   -0.38   26.19   -0.50
1985  11   20.69   -0.90   24.28   -0.70   28.52   -0.11   26.19   -0.46
1985  12   22.40   -0.39   24.29   -0.85   28.530.04   26.11   -0.46
1986   1   24.610.15   24.73   -0.90   28.11   -0.19   25.79   -0.78
1986   2   26.06   -0.01   25.81   -0.56   27.93   -0.17   25.94   -0.78
1986   3   25.91   -0.61   26.84   -0.30   27.97   -0.22   26.65   -0.57
1986   4   24.58   -0.89   27.17   -0.33   28.21   -0.29   27.44   -0.34
1986   5   23.38   -0.82   26.68   -0.40   28.58   -0.21   27.50   -0.35
1986   6   21.98   -0.84   26.30   -0.13   28.840.00   27.690.04
1986   7   21.12   -0.48   25.700.08   28.900.10   27.370.15
1986   8   20.970.32   25.020.03   29.040.36   27.150.33
1986   9   20.440.08   25.250.40   29.180.49   27.330.61
1986  10   21.070.25   25.620.70   29.380.72   27.570.88
1986  11   22.030.44   25.920.94   29.400.77   27.731.08
1986  12   23.000.21   25.860.72   29.190.70   27.701.13
1987   1   25.300.84   26.691.06   29.020.72   27.911.3

Re: [R] quantile of a discrete random variabel --- again

2015-06-25 Thread Bert Gunter
Well, presumably you have the pmf and can create a matrix of the form:
(where mypmf is your pmf)

x <- seq_len(1000) ## or whatever your discrete support sorted in
increasing order

## for individual quantile q:

max(x[cumsum(mypmf(x)) <= q] )

## This probably could be vectorized for a vector of quantiles . I
leave that to others both cleverer and more motivated than I.

Cheers,
Bert
Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Thu, Jun 25, 2015 at 8:59 AM, L... L...  wrote:
> I thank all for your reply. My question was not well formulated.
> I will do it again:
> Suppose that the random variable X is discrete with probability mass function 
> (pmf) F (binomial, poisson, ) not necessarily available in R.
> Is there a general method to get the quantiles (as qbinom, qpois, .) or 
> which is the method(s) used to get the quantiles (used in qbinom, qpois, 
> .)?
> Regards
> ML
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] quantile of a discrete random variabel --- again

2015-06-25 Thread L... L...
I thank all for your reply. My question was not well formulated.
I will do it again:
Suppose that the random variable X is discrete with probability mass function 
(pmf) F (binomial, poisson, ) not necessarily available in R.
Is there a general method to get the quantiles (as qbinom, qpois, .) or 
which is the method(s) used to get the quantiles (used in qbinom, qpois, .)?
Regards
ML
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] CCA package

2015-06-25 Thread David Winsemius
Dear Javad;

Please stop copying r-help-owner with messages intended for r-help.

David (one of the several moderators)

On Jun 25, 2015, at 4:48 AM, javad bayat wrote:

> Dear R users;
> I am using CCA package to calculate the correlation between two data set. 
> Every time that I run my codes, I get the following error;
> "the leading minor of order 5 is not positive definite".
> Please help me to fix it.
> Many thanks.
> 
> -- 
> Best Regards
> Javad Bayat
> M.Sc. Environment Engineering
> Alternative Mail: bayat...@yahoo.com

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] quantile of a discrete random variable

2015-06-25 Thread David Winsemius

On Jun 25, 2015, at 7:26 AM, L... L... wrote:

> Dear all, is there a general method for calculating the quantile of a 
> discrete random variable? If yes, is there a R function to do this?

The `quantile` function would seem to be the first place to go. It may depend 
on the object-type of your representation of the "random variable".

?quantile # to see the help page

The default of type=7 may not be what you want, but I suspect one of the other 
types would be appropriate. You could also cobble something together along the 
lines of:

 list(x= as.numeric(names(table(x))), y=cumsum(table(x))/sum(x) )

Could use the result of ecdf(and then reversing x and y for evaluation.).

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

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] quantile of a discrete random variable

2015-06-25 Thread David L Carlson
There is a function called quantile() that provides 9 methods of computing 
quantiles, three of which are appropriate for discontinuous data. Type

?quantile

at the command prompt for details.

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

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of L... L...
Sent: Thursday, June 25, 2015 9:27 AM
To: r-help@r-project.org
Subject: [R] quantile of a discrete random variable

Dear all, is there a general method for calculating the quantile of a discrete 
random variable? If yes, is there a R function to do this?
Best regards
Marcelo Lamack


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Cannot Connect to R server

2015-06-25 Thread David Winsemius

On Jun 24, 2015, at 6:49 PM, karlmalone32 wrote:

> My RStudio has a wired problem. When I run library(the package I have
> successfully installed), RStudio has no response. After endless waiting, an
> error message comes out saying R cannot connect to the R server. Both my R
> and RStudio are perfectly updated. Anyone can help me out? I appreciate.

Have you considered posting this question in the RStudio support forum?

(Reason for lack of direct response to poster: The Nabble origin has caused a 
lot of bounce-backs that then get me disconnected from Rhelp.)

> 
> Do read these --->

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

-- 
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Broken links (???) in rw-FAQ

2015-06-25 Thread Chel Hee Lee
Thank you so much, David!   I also confirmed that the link moved is not 
found.


Chel Hee Lee

On 15-06-24 04:15 PM, David Winsemius wrote:


On Jun 24, 2015, at 10:52 AM, Chel Hee Lee wrote:


Could you also kindly check the following links in the rw-FAQ manual at 
??  The links list in 
the below seem to be broken.   I hope these links are fixed in the very near future.

Under the section 2.4 Can I customize the installation?

* Setup (http://jrsoftware.org/ishelp.php) for details.

Under the section 3.3 I want to run R in Chinese/Japanese/Korean

* 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_language_and_country_strings.asp

Under the section 2.26 There is no tilde on my keyboard!

* http://office.microsoft.com/en-us/word/HP052590631033.aspx


With regard to this one, there was a discussion of this just yesterday in 
StackOverflow (relative to Italian keyboards which don't seem to be mentioned 
in the current version of the rw-FAQ). Admittedly this material is not 
immediately relevant to a windows setup since the question was coming from a 
Linux user.

http://stackoverflow.com/questions/31015152/how-to-type-tilde-in-r

  
http://superuser.com/questions/667622/italian-keyboard-entering-the-tilde-and-backtick-characters-without-cha

Looking at some of the linked material, it appears that Windows and Linux have 
distinctly different answers to tilde-deficient keyboard concerns, so there 
might be a reason to move a more general answer to R-FAQ and perhaps include 
material in the section on Internationalization? I could find no mention of 
tilde-problems in the R-FAQ or the Admin/Setup document.



This link is in fact moved to

https://support.office.com/en-us/article/HP052590631?CorrelationId=98eaa529-e95a-4628-90ac-1a1da4526b17


That link was 404-ed when I tried it.


Under the section 2.24 Does R run under Windows Vista/7/8/Server 2008?

* 
http://windowsvistablog.com/blogs/windowsvista/archive/2007/01/23/security-features-vs-convenience.aspx

I appreciate your help!

Chel Hee Lee



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Broken links (???) in R-FAQ

2015-06-25 Thread Chel Hee Lee
Thank you so much, Jim.  Yes, I also see that the wiki 
(rwiki.sciviews.org) is not found.


Chel Hee Lee

On 15-06-25 04:54 AM, Jim Lemon wrote:

Hi Chel Hee,
The last link (for FAQ 7.39) is dead and the domain
(rwiki.sciviews.org) is not there either.

Jim


On Thu, Jun 25, 2015 at 3:45 AM, Chel Hee Lee  wrote:

Could you kindly check if the following links are working fine in the R-FAQ
page at ?  The links listed in
the below seem to be broken.  I hope these links are fixed in the very near
future.

Under the section 2.6 Are there Unix-like binaries for R?,

  * http://CRAN.R-project.org/bin/linux/debian/README

Under the section 2.10 What is CRAN?,

  * http://cran.au.R-project.org/
  * http://cran.pt.R-project.org/

Under the section 2.14 What is R-Forge?,

  * GForge 

Under the section 3.1 What is S?,

  * http://cm.bell-labs.com/cm/ms/departments/sia/Sbook/
  * http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html

Under the section 4 R Web Interfaces,
  * http://rwiki.sciviews.org/doku.php?id=faq-r#web_interfaces
  * Rserve 

Under the section 5.1.4 Add-on packages from Bioconductor,

  * Bioconductor software packages


Under the section 7.39 How do I create a plot with two y-axes?,
  * http://rwiki.sciviews.org/doku.php?id=tips:graphics-base:2yaxes

I appreciate your helps!

Chel Hee Lee

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] quantile of a discrete random variable

2015-06-25 Thread L... L...
Dear all, is there a general method for calculating the quantile of a discrete 
random variable? If yes, is there a R function to do this?
Best regards
Marcelo Lamack


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] CCA package

2015-06-25 Thread javad bayat
Dear R users;
I am using CCA package to calculate the correlation between two data set.
Every time that I run my codes, I get the following error;
"the leading minor of order 5 is not positive definite".
Please help me to fix it.
Many thanks.

-- 
Best Regards
Javad Bayat
M.Sc. Environment Engineering
Alternative Mail: bayat...@yahoo.com

[[alternative HTML version deleted]]

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


Re: [R] R lattice : labeling of matrix groups of different size with strips

2015-06-25 Thread R codeplayer
Hi Duncan,


thank you very much for your help.


Originally, I thought that it is possible to use a different data
representation and then to automatically create the plots and strips
in lattice.

Based on your suggestion, I could write the code for an annotated
levelplot of the two groups (code is shown below).

An open question is how to display the two groups with the same aspect
ratio for the rows.


> plotMatrix
> , , group1
>
>   a b c d
> 1 1 0 0 0
> 2 1 0 0 0
> 3 1 1 0 0
> 4 0 1 0 0
> 5 0 1 1 0
>
> , , group2
>
>a  b  c  d
> 1  0  0  1  0
> 2  0  0  1  1
> 3  0  0  0  1
> 4 NA NA NA NA
> 5 NA NA NA NA

library(gridExtra)

trellis.device(device = "pdf",file
="lattice_annotated_groups.pdf",width=8,height=5)

#The aspect="fill" option was added to coerce the same height of the 2 plots
#panel.text was used instead of grid.text to avoid using the
latticeExtra package

plot1 <- levelplot(plotMatrix[,,1],
 page = function(n)
 panel.text("group 1",
 x = 0.5,
 y = 0.96),
 colorkey = F,
 xlab = "",
 ylab="",
 aspect="fill")

pm <- plotMatrix[1:3,,2]
colnames(pm) <- rep("",ncol(pm))

plot2 <-levelplot(pm,
page = function(n)
panel.text(
"group 2",
 x = 0.5,
 y = 0.96),
colorkey = F,
xlab = "",
ylab="",
aspect="fill")


grid.arrange(plot1,plot2,ncol=2)
dev.off()


lattice_annotated_groups.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Collecting output of regressions in an intelligent way

2015-06-25 Thread Adams, Jean
Francesca,

You don't provide any example data, so the code that I am provided is
untested, but here is one way to put your commands into a loop.


# define range of p values you want to use
ps <- 6:10
# create an empty list to collect the results
waldchi <- vector("list", length(ps))

# loop through the p values
for(i in seq(ps)) {
  v.p <- VAR(cbind(index1, ma_fin), p=ps[i], type="both")
  print(summary(v.p)
  wald_finp.1 <- wald.test(
b=coef(V.p$varresult[[1]]),
Sigma=vcov(V.p$varresult[[1]]),
Terms=seq(from=2, by=2, length=ps[i]-1))
  waldchi[[i]] <- wald_finp.1$result$chi2
}

# combine the results
wald_fin <- do.call(rbind, waldchi)

Jean


On Thu, Jun 25, 2015 at 4:26 AM, Francesca 
wrote:

> Dear R Contributors
> I am asking for some suggestions on how to organize output of a series of
> regressions and tests in an intelligent way.
> I estimate a series of Var models with increasing numbers of lags and the
> perform a Wald test to control Granger Causality: I would like to learn a
> way to do it that allows me not to produce copy and past code.
>
> This is what I do:
> Estimate var models with increasing number of lags,
>
> V.6<-VAR(cbind(index1,ma_fin),p=6,type="both")
> V.7<-VAR(cbind(index1,ma_fin),p=7,type="both")
> V.8<-VAR(cbind(index1,ma_fin),p=8,type="both")
> V.9<-VAR(cbind(index1,ma_fin),p=9,type="both")
>
> then observe results and control significance of regressors:
>
> summary(V.6)
> summary(V.7)
> summary(V.8)
> summary(V.9)
> summary(V.10)
>
> then use the estimated var to perform the test:
>
> wald_fin7.1<-wald.test(b=coef(V.7$varresult[[1]]),
> Sigma=vcov(V.7$varresult[[1]]), Terms=c(2,4,6,8,10,12))
> wald_fin8.1<-wald.test(b=coef(V.8$varresult[[1]]),
> Sigma=vcov(V.8$varresult[[1]]), Terms=c(2,4,6,8,10,12,14))
> wald_fin9.1<-wald.test(b=coef(V.9$varresult[[1]]),
> Sigma=vcov(V.9$varresult[[1]]), Terms=c(2,4,6,8,10,12,14,16))
> wald_fin10.1<-wald.test(b=coef(V.10$varresult[[1]]),
> Sigma=vcov(V.10$varresult[[1]]), Terms=c(2,4,6,8,10,12,14,16,18))
>
> #then collect tests result in a table:
>
> wald_fin<-rbind(wald_fin7.1$result$chi2,
> wald_fin12.1$result$chi2,wald_fin21.1$result$chi2,
> wald_fin7.2$result$chi2,
> wald_fin12.2$result$chi2,wald_fin21.2$result$chi2)
>
>
> My idea is that it is possible to create all this variable with a loop
> across the objects names but it is a level of coding much higher than my
> personal knowledge and ability.
>
> I hope anyone can help
>
> Thanks in advance
>
>
> --
>
> Francesca
>
> --
> Francesca Pancotto, PhD
> Università di Modena e Reggio Emilia
> Viale A. Allegri, 9
> 40121 Reggio Emilia
> Office: +39 0522 523264
> Web: https://sites.google.com/site/francescapancotto/
> --
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Plotting legend outside of chart area

2015-06-25 Thread Antonio Serrano via R-help
First, you have to increase the bottom margin to have enough space for the 
legend.
You do it like this:
par(
mar = c(6,4,4,2)
)

>From R help:
 ‘mar’ A numerical vector of the form ‘c(bottom, left, top, right)’
  which gives the number of lines of margin to be specified on
  the four sides of the plot.  The default is ‘c(5, 4, 4, 2) +
  0.1’.
So, we have increased the first number from 5 to 6 to have mor space at the 
bottom.

Then, in the legend(), you have to add the option:
inset = c(0, -0.2),

>From R help:
   inset: inset distance(s) from the margins as a fraction of the plot
  region when legend is placed by keyword.
Change the -0.2 and the 6 in the par(mar) until you get a nice chart

 

 

Antonio Serrano
aasde...@aim.com
ن

 

 

-Original Message-
From: Samantha Allcock 
To: 'r-help@r-project.org' 
Sent: Wed, Jun 24, 2015 10:08 pm
Subject: [R] Plotting legend outside of chart area


Hello,

I am trying to add a legend to my PCA plot so that it looks neat. I
think plotting this outside of the chart area would be good but I cannot seem to
fathom the correct code for this. I wondered if anyone could help please?

The
code I am using is as follows:

grp<- with(Matan, cut(R_category_no,14,
labels=1:14))
cols <- c("grey0", "wheat", "red", "cyan", "orange",
"darkolivegreen2", "purple3",
"royalblue", "burlywood4", "orchid",
"forestgreen", "green",
"gray", "yellow1")
plot(geopca, display="sites",
scaling=3, type="n")
points(geopca, display="sites", scaling=3, col=cols[grp],
pch=16)

legend("bottomright", col=c("grey0", "wheat", "red", "cyan",
"orange", "darkolivegreen2",
"purple3", "royalblue", "burlywood4", "orchid",
"forestgreen", "green",
"gray", "yellow1"), c("Control type 1", "Control type
2",
"External/Courtyard", "Midden", "Animal Occupation",
"External fire
installations and ashy deposits",
"Internal fire installations and ashy
deposits", "Hearth make-up",
"Floors and surfaces", "Plasters and clay
features", "Storage features",
"Platforms and benches", "Mortars", "Roofs and
roofing materials"), pch=16,
cex=0.75, bty="n")

Thank you for your time in
advance


Dr Samantha Lee Allcock
Faculty of Science and
Technology
Department of Archaeology, Anthropology and Forensic
Science
Christchurch House Rm: C133
Bournemouth University
Talbot
Campus
Poole
BH12 5BB
Tel: 01202
9(62474)

sallc...@bournemouth.ac.uk
research.bournemouth.ac.uk/2014/07/inea-project-2


BU
is a Disability Two Ticks Employer and has signed up to the Mindful Employer
charter. Information about the accessibility of University buildings can be
found on the BU DisabledGo webpages This email is intended only for the person
to whom it is addressed and may contain confidential information. If you have
received this email in error, please notify the sender and delete this email,
which must not be copied, distributed or disclosed to any other person. Any
views or opinions presented are solely those of the author and do not
necessarily represent those of Bournemouth University or its subsidiary
companies. Nor can any contract be formed on behalf of the University or its
subsidiary companies via email.

[[alternative HTML version
deleted]]

__
R-help@r-project.org
mailing list -- To UNSUBSCRIBE and more,
see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] set par options once for entire R session

2015-06-25 Thread Jim Lemon
Hi Martin,
Depending upon what device parameters you want to set, you can write a
wrapper for the device call that includes the parameters:

my.x11<-function() {
 x11(family="sans",font=2)
}

Then just call the wrapper instead of the device function. You could
make a little package with all of the devices you wish to use and just
load the package at the beginning of your R session.

Jim


On Thu, Jun 25, 2015 at 1:40 AM, MacQueen, Don  wrote:
> The Details section of ?par starts of with:
>
>  "Each device has its own set of graphical parameters."
>
> (So this is not Mac-specific.)
>
> Strictly speaking, the options you set with par() are not "reset" when you
> open a new graphics device. Rather, when a new device is opened, it is
> initialized with default values of graphics parameters.
>
> If you can find where those default values are stored (in a brief search I
> did not find them), then perhaps you can change them at session startup
> time.
>
> I haven't tested this, but you might be able to make things a little more
> convenient by defining a function
>
>   mypar <- function() par( {set whatever values you want} )
>
> Then whenever you open a new device, immediately call that function:
>
> pdf()
> mypar()
> plot(x,y)
> dev.off()
>
> png()
> mypar()
> plot(x,y)
> dev.of()
>
> And so on.
>
>
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 6/23/15, 8:54 AM, "R-help on behalf of Martin Batholdy via R-help"
>  wrote:
>
>>Hi,
>>
>>I would like to set plot-options via par() and keep them for all plots
>>that are created thereafter.
>>Currently after each plot device the parameters I can set with par() are
>>reseted to their default value, at least on a Mac (R 3.2.1).
>>
>>Is there a way to define the parameters for plotting once at the
>>beginning and then keep them for an entire R session?
>>
>>
>>Thank you!
>>
>>__
>>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Broken links (???) in R-FAQ

2015-06-25 Thread Jim Lemon
Hi Chel Hee,
The last link (for FAQ 7.39) is dead and the domain
(rwiki.sciviews.org) is not there either.

Jim


On Thu, Jun 25, 2015 at 3:45 AM, Chel Hee Lee  wrote:
> Could you kindly check if the following links are working fine in the R-FAQ
> page at ?  The links listed in
> the below seem to be broken.  I hope these links are fixed in the very near
> future.
>
> Under the section 2.6 Are there Unix-like binaries for R?,
>
>  * http://CRAN.R-project.org/bin/linux/debian/README
>
> Under the section 2.10 What is CRAN?,
>
>  * http://cran.au.R-project.org/
>  * http://cran.pt.R-project.org/
>
> Under the section 2.14 What is R-Forge?,
>
>  * GForge 
>
> Under the section 3.1 What is S?,
>
>  * http://cm.bell-labs.com/cm/ms/departments/sia/Sbook/
>  * http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html
>
> Under the section 4 R Web Interfaces,
>  * http://rwiki.sciviews.org/doku.php?id=faq-r#web_interfaces
>  * Rserve 
>
> Under the section 5.1.4 Add-on packages from Bioconductor,
>
>  * Bioconductor software packages
> 
>
> Under the section 7.39 How do I create a plot with two y-axes?,
>  * http://rwiki.sciviews.org/doku.php?id=tips:graphics-base:2yaxes
>
> I appreciate your helps!
>
> Chel Hee Lee
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Collecting output of regressions in an intelligent way

2015-06-25 Thread Francesca
Dear R Contributors
I am asking for some suggestions on how to organize output of a series of
regressions and tests in an intelligent way.
I estimate a series of Var models with increasing numbers of lags and the
perform a Wald test to control Granger Causality: I would like to learn a
way to do it that allows me not to produce copy and past code.

This is what I do:
Estimate var models with increasing number of lags,

V.6<-VAR(cbind(index1,ma_fin),p=6,type="both")
V.7<-VAR(cbind(index1,ma_fin),p=7,type="both")
V.8<-VAR(cbind(index1,ma_fin),p=8,type="both")
V.9<-VAR(cbind(index1,ma_fin),p=9,type="both")

then observe results and control significance of regressors:

summary(V.6)
summary(V.7)
summary(V.8)
summary(V.9)
summary(V.10)

then use the estimated var to perform the test:

wald_fin7.1<-wald.test(b=coef(V.7$varresult[[1]]),
Sigma=vcov(V.7$varresult[[1]]), Terms=c(2,4,6,8,10,12))
wald_fin8.1<-wald.test(b=coef(V.8$varresult[[1]]),
Sigma=vcov(V.8$varresult[[1]]), Terms=c(2,4,6,8,10,12,14))
wald_fin9.1<-wald.test(b=coef(V.9$varresult[[1]]),
Sigma=vcov(V.9$varresult[[1]]), Terms=c(2,4,6,8,10,12,14,16))
wald_fin10.1<-wald.test(b=coef(V.10$varresult[[1]]),
Sigma=vcov(V.10$varresult[[1]]), Terms=c(2,4,6,8,10,12,14,16,18))

#then collect tests result in a table:

wald_fin<-rbind(wald_fin7.1$result$chi2,
wald_fin12.1$result$chi2,wald_fin21.1$result$chi2,
wald_fin7.2$result$chi2,
wald_fin12.2$result$chi2,wald_fin21.2$result$chi2)


My idea is that it is possible to create all this variable with a loop
across the objects names but it is a level of coding much higher than my
personal knowledge and ability.

I hope anyone can help

Thanks in advance


-- 

Francesca

--
Francesca Pancotto, PhD
Università di Modena e Reggio Emilia
Viale A. Allegri, 9
40121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Setting two default CRAN servers under Windows/RStudio

2015-06-25 Thread Sigbert Klinke
Hi,

I tried the following:

local({r <- getOption("repos")
   r["CRAN"]   <- "http://local.cran.server/";
   r["MIRROR"] <- "http://cran.mirror/";
   options(repos=r)
})

But: R seems always to take the "CRAN" entry first, therefore I put our
local mirror there.

If a R session starts and the "CRAN" server is not available then a
package is taken from the "MIRROR" server. If the server comes up during
the session then the next install.packages will use the "CRAN" server.

But if the "CRAN" server becomes unavailable during a session then the
"MIRROR" server is not checked and I get an error message "download of
package 'xyz' failed".

Any ideas?

Sigbert

Am 19.06.2015 um 15:32 schrieb Thierry Onkelinx:
> We have this in our Rprofile.site This works fine. It checks each mirror
> and installs (or updates) the latest version available on all mirrors. e.g.
> abc 0.1 on RStudio and abc 0.2 on RForge, then abc 0.2 from RForge gets
> installed/updated.
> 
> options(
>   repos = c(
> RStudio = "http://cran.rstudio.com/";,
> RForge = "http://r-forge.r-project.org";,
> Belgium = "http://www.freestatistics.org/cran/";,
> CRAN = "http://cran.at.r-project.org/";,
> Oxford = "http://www.stats.ox.ac.uk/pub/RWin";
>   ),
>   install.packages.check.source = "no"
> )


-- 
http://u.hu-berlin.de/sk

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