Re: [R] searching for a specific row name in R

2018-08-13 Thread Bert Gunter
These seem to be basic R questions. You should spend time with an R
tutorial or two for this sort of thing. This list is here to help, but you
also need to do homework on your own if you have not already done so.

Cheers,
Bert






Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Aug 13, 2018 at 8:36 PM, Deepa  wrote:

> Hi Don,
>
> When there is a list of identifier names that I want to check, the only way
> is to loop over each entry stored in the list of identifier names or is
> there is there any other shortcut?
>
> Many thanks for the response?
>
> On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don  wrote:
>
> > Or to return a logical value, i.e., TRUE if the column contains the
> value,
> > FALSE if it does not:
> >
> >   any( x[,2] == 'A501' )
> >
> > -Don
> > --
> > Don MacQueen
> > Lawrence Livermore National Laboratory
> > 7000 East Ave., L-627
> > Livermore, CA 94550
> > 925-423-1062
> > Lab cell 925-724-7509
> >
> >
> >
> > On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
> > r-help-boun...@r-project.org on behalf of alkau...@fastmail.fm> wrote:
> >
> > Hello Deepa,
> >
> > sum(x[,2] == "A501")
> > or
> > which(x[,2] == "A501")
> > .
> > Best,
> > Albrecht
> >
> >
> > --
> >   Albrecht Kauffmann
> >   alkau...@fastmail.fm
> >
> > Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> > > Hello Everyone,
> > >
> > > I have a 1000 x 20 matrix. The second column of the matrix has the
> > names
> > > of identifiers. How do I check when a certain identifier is present
> > in
> > > the set of 1000 identifier names present in the second column. For
> > > instance, let the names of identifiers be A1,A2,...A1000. I want to
> > > check whether A501 is present .How can this be checked?
> > >
> > > Any help will be highly appreciated.
> > >
> > >
> > >   [[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.
> >
> >
> >
>
> [[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] searching for a specific row name in R

2018-08-13 Thread Deepa
I have a hundred identifier names that I want to check from the second
column of a matrix with 6000 entries in the column.
Instead of using  R > c("d", "v", "4", "s") %in% letters , is there an
alternative?

I have the hundred identifier names that are of my interest stored in an
array.




On Tue, Aug 14, 2018 at 9:16 AM, Boris Steipe 
wrote:

> Use the %in% operator:
>
> help('%in%')
>
> e.g.
>
> R > c("d", "v", "4", "s") %in% letters
> [1]  TRUE  TRUE FALSE  TRUE
>
>
> B.
>
>
> > On 2018-08-13, at 23:36, Deepa  wrote:
> >
> > Hi Don,
> >
> > When there is a list of identifier names that I want to check, the only
> way
> > is to loop over each entry stored in the list of identifier names or is
> > there is there any other shortcut?
> >
> > Many thanks for the response?
> >
> > On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don 
> wrote:
> >
> >> Or to return a logical value, i.e., TRUE if the column contains the
> value,
> >> FALSE if it does not:
> >>
> >>  any( x[,2] == 'A501' )
> >>
> >> -Don
> >> --
> >> Don MacQueen
> >> Lawrence Livermore National Laboratory
> >> 7000 East Ave., L-627
> >> Livermore, CA 94550
> >> 925-423-1062
> >> Lab cell 925-724-7509
> >>
> >>
> >>
> >> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
> >> r-help-boun...@r-project.org on behalf of alkau...@fastmail.fm> wrote:
> >>
> >>Hello Deepa,
> >>
> >>sum(x[,2] == "A501")
> >>or
> >>which(x[,2] == "A501")
> >>.
> >>Best,
> >>Albrecht
> >>
> >>
> >>--
> >>  Albrecht Kauffmann
> >>  alkau...@fastmail.fm
> >>
> >>Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> >>> Hello Everyone,
> >>>
> >>> I have a 1000 x 20 matrix. The second column of the matrix has the
> >> names
> >>> of identifiers. How do I check when a certain identifier is present
> >> in
> >>> the set of 1000 identifier names present in the second column. For
> >>> instance, let the names of identifiers be A1,A2,...A1000. I want to
> >>> check whether A501 is present .How can this be checked?
> >>>
> >>> Any help will be highly appreciated.
> >>>
> >>>
> >>>  [[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.
> >>
> >>
> >>
> >
> >   [[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] searching for a specific row name in R

2018-08-13 Thread Boris Steipe
Use the %in% operator:

help('%in%')

e.g.

R > c("d", "v", "4", "s") %in% letters
[1]  TRUE  TRUE FALSE  TRUE


B.


> On 2018-08-13, at 23:36, Deepa  wrote:
> 
> Hi Don,
> 
> When there is a list of identifier names that I want to check, the only way
> is to loop over each entry stored in the list of identifier names or is
> there is there any other shortcut?
> 
> Many thanks for the response?
> 
> On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don  wrote:
> 
>> Or to return a logical value, i.e., TRUE if the column contains the value,
>> FALSE if it does not:
>> 
>>  any( x[,2] == 'A501' )
>> 
>> -Don
>> --
>> Don MacQueen
>> Lawrence Livermore National Laboratory
>> 7000 East Ave., L-627
>> Livermore, CA 94550
>> 925-423-1062
>> Lab cell 925-724-7509
>> 
>> 
>> 
>> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
>> r-help-boun...@r-project.org on behalf of alkau...@fastmail.fm> wrote:
>> 
>>Hello Deepa,
>> 
>>sum(x[,2] == "A501")
>>or
>>which(x[,2] == "A501")
>>.
>>Best,
>>Albrecht
>> 
>> 
>>--
>>  Albrecht Kauffmann
>>  alkau...@fastmail.fm
>> 
>>Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
>>> Hello Everyone,
>>> 
>>> I have a 1000 x 20 matrix. The second column of the matrix has the
>> names
>>> of identifiers. How do I check when a certain identifier is present
>> in
>>> the set of 1000 identifier names present in the second column. For
>>> instance, let the names of identifiers be A1,A2,...A1000. I want to
>>> check whether A501 is present .How can this be checked?
>>> 
>>> Any help will be highly appreciated.
>>> 
>>> 
>>>  [[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.
>> 
>> 
>> 
> 
>   [[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] searching for a specific row name in R

2018-08-13 Thread Deepa
Hi Don,

When there is a list of identifier names that I want to check, the only way
is to loop over each entry stored in the list of identifier names or is
there is there any other shortcut?

Many thanks for the response?

On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don  wrote:

> Or to return a logical value, i.e., TRUE if the column contains the value,
> FALSE if it does not:
>
>   any( x[,2] == 'A501' )
>
> -Don
> --
> Don MacQueen
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
> Lab cell 925-724-7509
>
>
>
> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
> r-help-boun...@r-project.org on behalf of alkau...@fastmail.fm> wrote:
>
> Hello Deepa,
>
> sum(x[,2] == "A501")
> or
> which(x[,2] == "A501")
> .
> Best,
> Albrecht
>
>
> --
>   Albrecht Kauffmann
>   alkau...@fastmail.fm
>
> Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> > Hello Everyone,
> >
> > I have a 1000 x 20 matrix. The second column of the matrix has the
> names
> > of identifiers. How do I check when a certain identifier is present
> in
> > the set of 1000 identifier names present in the second column. For
> > instance, let the names of identifiers be A1,A2,...A1000. I want to
> > check whether A501 is present .How can this be checked?
> >
> > Any help will be highly appreciated.
> >
> >
> >   [[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.
>
>
>

[[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] Mysterious seg fault --- SOLVED

2018-08-13 Thread Rolf Turner

On 13/08/18 23:39, peter dalgaard wrote:

It's odd, possibly a bug, that you don't get

Error: object 'nphi' not found

but I can't offhand see where the evaluation of args to .C/.Fortran is supposed 
to take place.


If it is indeed a bug then it would be nice an it were fixed.  If that 
is possible.  Way beyond my level of comprehension but.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Fast matrix multiplication

2018-08-13 Thread Peter Langfelder
On Mon, Aug 13, 2018 at 12:18 PM Ista Zahn  wrote:
>
> On Mon, Aug 13, 2018 at 2:41 PM Ravi Varadhan  wrote:
> >
> > Hi Ista,
> > Thank you for the response.  I use Windows.  Is there a pre-compiled 
> > version of openBLAS for windows that would make it easy for me to use it?
>
> Not sure. If you want an easy way I would use MRO. More info at
> https://mran.microsoft.com/rro#intelmkl1

OpenBLAS is provided as a binary for Windows, see http://www.openblas.net/ .

You may need to compile R from source though, unless you can use an
equivalent of the linux trick to replace libRblas.so with a symlink to
the compiled openBLAS library.

Peter

__
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] Fast matrix multiplication

2018-08-13 Thread Ista Zahn
On Mon, Aug 13, 2018 at 2:41 PM Ravi Varadhan  wrote:
>
> Hi Ista,
> Thank you for the response.  I use Windows.  Is there a pre-compiled version 
> of openBLAS for windows that would make it easy for me to use it?

Not sure. If you want an easy way I would use MRO. More info at
https://mran.microsoft.com/rro#intelmkl1

--Ista

> Thanks,
> Ravi
>
> -Original Message-
> From: Ista Zahn 
> Sent: Friday, August 10, 2018 12:20 PM
> To: Ravi Varadhan 
> Cc: r-help@r-project.org
> Subject: Re: [R] Fast matrix multiplication
>
>
> Hi Ravi,
>
> You can achieve substantial speed up by using a faster BLAS (e.g., OpenBLAS 
> or MKL), especially on systems with multiple CPUs. On my (6 year old, but 8 
> core) system your example takes 3.9 seconds with using the reference BLAS and 
> only 0.9 seconds using OpenBLAS.
>
> Best,
> Ista
> On Fri, Aug 10, 2018 at 11:46 AM Ravi Varadhan  wrote:
> >
> > Hi,
> >
> > I would like to compute:  A %*% B %*% t(A)
> >
> >
> >
> > A is a mxn matrix and B is an nxn symmetric, positive-definite matrix, 
> > where m is large relative to n (e.g., m=50,000 and n=100).
> >
> >
> >
> > Here is a sample code.
> >
> >
> >
> > M <- 1
> >
> > N <- 100
> >
> > A <- matrix(rnorm(M*N), M, N)
> >
> > B <- crossprod(matrix(rnorm(N*N), N, N)) # creating a symmetric
> > positive-definite matrix
> >
> >
> >
> > # method 1
> >
> > system.time(D <- A %*% B %*% t(A))
> >
> >
> >
> > # I can obtain speedup by using a Cholesky decomposition of B
> >
> > # method 2
> >
> > system.time({
> >
> > C <- t(chol(B))
> >
> > E <- tcrossprod(A%*%C)
> >
> > })
> >
> >
> >
> > all.equal(D, E)
> >
> >
> >
> > I am wondering how to obtain more substantial speedup.  Any suggestions 
> > would be greatly appreciated.
> >
> >
> >
> > Thanks,
> >
> > Ravi
> >
> >
> >
> > [[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] Assistance on Installing Rattle

2018-08-13 Thread Michael Dewey

Dear Shivi

You are running R 3.5.1 according to your session info. Why are you 
installing a version for R 3.3? Note that the up-to-date version depends 
on R > 3.4.0 so it is no surprise that you get problems.


Michael

On 13/08/2018 16:07, Shivi Bhatia wrote:

Hi Michael,

I was able to install RGtk2 
from install.packages("https://cran.r-project.org/bin/windows/contrib/3.3/RGtk2_2.20.31.zip;, 
repos=NULL) but after installing this and trying to install rattle i get 
this error:
Error : package 'RGtk2' was installed by an R version with different 
internals; it needs to be reinstalled for use with this R version

ERROR: lazy loading failed for package 'rattle'

I tried installing rattle from install.packages("rattle", 
repos="https://rattle.togaware.com;, type="source").


Regards, Shivi


On Sun, Aug 12, 2018 at 7:20 PM Michael Dewey > wrote:


Dear Shivi

What error message do you get when you try to install RGtk2?

Michael

On 12/08/2018 11:49, Shivi Bhatia wrote:
 > Hi Eric,
 >
 > Thank you for the reply. I am adding the session details below,
hope it
 > helps:
 > R version 3.5.1 (2018-07-02)
 > Platform: x86_64-w64-mingw32/x64 (64-bit)
 > Running under: Windows >= 8 x64 (build 9200)
 >
 > Matrix products: default
 > locale:
 > [1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252
 > LC_MONETARY=English_India.1252
 > [4] LC_NUMERIC=C                   LC_TIME=English_India.1252
 >
 > attached base packages:
 > [1] stats     graphics  grDevices utils     datasets  methods   base
 >
 > Thanks.
 >
 > On Sat, Aug 11, 2018 at 9:38 PM Eric Berger
mailto:ericjber...@gmail.com>> wrote:
 >
 >> Hi Shivi,
 >> I have no experience with the rattle package but I just
installed it with
 >> no problem.
 >> I am using a Windows 10 machine with R version 3.4.2.
 >>
 >> I suggest you provide additional information so that others may
have ideas.
 >> e.g. your operating system version and output from sessionInfo()
(in R)
 >>
 >> Best,
 >> Eric
 >>
 >>
 >> On Sat, Aug 11, 2018 at 6:55 PM, Shivi Bhatia
mailto:shivipm...@gmail.com>>
 >> wrote:
 >>
 >>> Hi,
 >>>
 >>> Need assistance on installing Rattle.
 >>>
 >>> I have followed the instructions on https://rattle.togaware.com/
 >>> but still facing error installing the package.
 >>> ERROR: dependency 'RGtk2' is not available for package 'rattle'.
 >>> Have tried installing RGt2 from multiple sources and its still
failing.
 >>>
 >>> One of the suggestion on stack overflow was to downgrade the R
version
 >>> here
 >>> :
 >>>
 >>>

https://stackoverflow.com/questions/24913643/downgrade-r-version-no-issues-with-bioconductor-installation
 >>> Request assistance.
 >>>
 >>> Regards, Shivi
 >>>
 >>>          [[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.
 >

-- 
Michael

http://www.dewey.myzen.co.uk/home.html



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
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] Typo in print.aov

2018-08-13 Thread peter dalgaard
That's a bug... no other place in the sources has "coeffficients". The net 
result is that the NULL case is used even when colnames _are_ present. It does 
make a difference, e.g. to examples(manova). I am fixing this in r-devel since 
the urgency must be rather low.

- Peter D.

> On 13 Aug 2018, at 14:27 , Andrews, Chris  wrote:
> 
> 
> While looking at the code of print.aov for a different reason, I noticed that 
> 'coefficient' was spelled with 3 'f's in one location.  Perhaps this is on 
> purpose but in another location it has just 2 'f's.  This has not caused me 
> any problem (that I know of) but I found it curious.
> 
> Chris
> 
> 
> 
> R version 3.5.1 (2018-07-02) -- "Feather Spray"
> Copyright (C) 2018 The R Foundation for Statistical Computing
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> 
> 
> 
> 
>> getAnywhere(print.aov)
> A single object matching 'print.aov' was found
> It was found in the following places
>  registered S3 method for print from namespace stats
>  namespace:stats
> with value
> 
> function (x, intercept = FALSE, tol = sqrt(.Machine$double.eps), 
>...) 
> {
>if (!is.null(cl <- x$call)) {
>cat("Call:\n   ")
>dput(cl, control = NULL)
>}
>qrx <- if (x$rank) 
>qr(x)
>asgn <- x$assign[qrx$pivot[1L:x$rank]]
>effects <- x$effects
>if (!is.null(effects)) 
>effects <- as.matrix(effects)[seq_along(asgn), , drop = FALSE]
>rdf <- x$df.residual
>resid <- as.matrix(x$residuals)
>wt <- x$weights
>if (!is.null(wt)) 
>resid <- resid * sqrt(wt)
>RSS <- colSums(resid^2)
>uasgn <- unique(asgn)
>nmeffect <- c("(Intercept)", attr(x$terms, "term.labels"))[1 + 
>uasgn]
>nterms <- length(uasgn)
>nresp <- NCOL(effects)
>df <- numeric(nterms)
>ss <- matrix(NA, nterms, nresp)
>if (nterms) {
>for (i in seq(nterms)) {
>ai <- asgn == uasgn[i]
>df[i] <- sum(ai)
>ef <- effects[ai, , drop = FALSE]
>ss[i, ] <- if (sum(ai) > 1) 
>colSums(ef^2)
>else ef^2
>}
>keep <- df > 0L
>if (!intercept && uasgn[1L] == 0) 
>keep[1L] <- FALSE
>nmeffect <- nmeffect[keep]
>df <- df[keep]
>ss <- ss[keep, , drop = FALSE]
>nterms <- length(df)
>}
>cat("\nTerms:\n")
>if (nterms == 0L) {
>if (rdf > 0L) {
>ss <- RSS
>ssp <- sapply(ss, format)
>if (!is.matrix(ssp)) 
>ssp <- t(ssp)
>tmp <- as.matrix(c(ssp, format(rdf)))
>if (length(ss) > 1L) {
>rn <- colnames(x$fitted.values)
>if (is.null(rn)) 
>  rn <- paste("resp", seq_along(ss))
>}
>else rn <- "Sum of Squares"
>dimnames(tmp) <- list(c(rn, "Deg. of Freedom"), "Residuals")
>print(tmp, quote = FALSE, right = TRUE)
>cat("\n")
>rs <- sqrt(RSS/rdf)
>cat(if (length(rs) > 1L) 
>"Residual standard errors:"
>else "Residual standard error:", sapply(rs, format))
>cat("\n")
>}
>else print(matrix(0, 2L, 1L, dimnames = list(c("Sum of Squares", 
>"Deg. of Freedom"), "")))
>}
>else {
>if (rdf > 0L) {
>nterms <- nterms + 1L
>df <- c(df, rdf)
>ss <- rbind(ss, RSS)
>nmeffect <- c(nmeffect, "Residuals")
>}
>ssp <- apply(zapsmall(ss), 2L, format)
>tmp <- t(cbind(ssp, format(df)))
>if (ncol(effects) > 1L) {
>rn <- colnames(x$coeffficients) ### 
> <--- HERE
>if (is.null(rn)) 
>rn <- paste("resp", seq(ncol(effects)))
>}
>else rn <- "Sum of Squares"
>dimnames(tmp) <- list(c(rn, "Deg. of Freedom"), nmeffect)
>print(tmp, quote = FALSE, right = TRUE)
>rank <- x$rank
>cat("\n")
>if (rdf > 0L) {
>rs <- sqrt(RSS/rdf)
>cat(if (length(rs) > 1L) 
>"Residual standard errors:"
>else "Residual standard error:", sapply(rs, format))
>cat("\n")
>}
>coef <- as.matrix(x$coefficients)[, 1L]  ## 
>  <- NOT HERE
>R <- qrx$qr
>R <- R[1L:min(dim(R)), , drop = FALSE]
>R[lower.tri(R)] <- 0
>if (rank < (nc <- length(coef))) {
>cat(paste(nc - rank, "out of", nc, "effects not estimable\n"))
>R <- R[, 1L:rank, drop = FALSE]
>}
>d2 <- sum(abs(diag(R)))
>diag(R) <- 0
>if (sum(abs(R))/d2 > tol) 
>cat("Estimated effects may be unbalanced\n")
>else cat("Estimated effects are balanced\n")
>if (nzchar(mess <- naprint(x$na.action))) 
>cat(mess, "\n", sep = "")
>}
>invisible(x)
> }
> 
> 
> 
> 
> 

Re: [R] Assistance on Installing Rattle

2018-08-13 Thread Shivi Bhatia
Hi Michael,

I was able to install RGtk2 from install.packages("
https://cran.r-project.org/bin/windows/contrib/3.3/RGtk2_2.20.31.zip;,
repos=NULL) but after installing this and trying to install rattle i get
this error:
Error : package 'RGtk2' was installed by an R version with different
internals; it needs to be reinstalled for use with this R version
ERROR: lazy loading failed for package 'rattle'

I tried installing rattle from install.packages("rattle", repos="
https://rattle.togaware.com;, type="source").

Regards, Shivi


On Sun, Aug 12, 2018 at 7:20 PM Michael Dewey 
wrote:

> Dear Shivi
>
> What error message do you get when you try to install RGtk2?
>
> Michael
>
> On 12/08/2018 11:49, Shivi Bhatia wrote:
> > Hi Eric,
> >
> > Thank you for the reply. I am adding the session details below, hope it
> > helps:
> > R version 3.5.1 (2018-07-02)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows >= 8 x64 (build 9200)
> >
> > Matrix products: default
> > locale:
> > [1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252
> > LC_MONETARY=English_India.1252
> > [4] LC_NUMERIC=C   LC_TIME=English_India.1252
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods   base
> >
> > Thanks.
> >
> > On Sat, Aug 11, 2018 at 9:38 PM Eric Berger 
> wrote:
> >
> >> Hi Shivi,
> >> I have no experience with the rattle package but I just installed it
> with
> >> no problem.
> >> I am using a Windows 10 machine with R version 3.4.2.
> >>
> >> I suggest you provide additional information so that others may have
> ideas.
> >> e.g. your operating system version and output from sessionInfo() (in R)
> >>
> >> Best,
> >> Eric
> >>
> >>
> >> On Sat, Aug 11, 2018 at 6:55 PM, Shivi Bhatia 
> >> wrote:
> >>
> >>> Hi,
> >>>
> >>> Need assistance on installing Rattle.
> >>>
> >>> I have followed the instructions on https://rattle.togaware.com/
> >>> but still facing error installing the package.
> >>> ERROR: dependency 'RGtk2' is not available for package 'rattle'.
> >>> Have tried installing RGt2 from multiple sources and its still failing.
> >>>
> >>> One of the suggestion on stack overflow was to downgrade the R version
> >>> here
> >>> :
> >>>
> >>>
> https://stackoverflow.com/questions/24913643/downgrade-r-version-no-issues-with-bioconductor-installation
> >>> Request assistance.
> >>>
> >>> Regards, Shivi
> >>>
> >>>  [[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.
> >
>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html
>

[[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] searching for a specific row name in R

2018-08-13 Thread MacQueen, Don via R-help
Or to return a logical value, i.e., TRUE if the column contains the value, 
FALSE if it does not:

  any( x[,2] == 'A501' )

-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" 
 wrote:

Hello Deepa,

sum(x[,2] == "A501")
or
which(x[,2] == "A501")
.
Best,
Albrecht


-- 
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> Hello Everyone,
> 
> I have a 1000 x 20 matrix. The second column of the matrix has the names 
> of identifiers. How do I check when a certain identifier is present in 
> the set of 1000 identifier names present in the second column. For 
> instance, let the names of identifiers be A1,A2,...A1000. I want to 
> check whether A501 is present .How can this be checked?
> 
> Any help will be highly appreciated.
> 
> 
>   [[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-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] Typo in print.aov

2018-08-13 Thread Andrews, Chris


While looking at the code of print.aov for a different reason, I noticed that 
'coefficient' was spelled with 3 'f's in one location.  Perhaps this is on 
purpose but in another location it has just 2 'f's.  This has not caused me any 
problem (that I know of) but I found it curious.

Chris



R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)




> getAnywhere(print.aov)
A single object matching 'print.aov' was found
It was found in the following places
  registered S3 method for print from namespace stats
  namespace:stats
with value

function (x, intercept = FALSE, tol = sqrt(.Machine$double.eps), 
...) 
{
if (!is.null(cl <- x$call)) {
cat("Call:\n   ")
dput(cl, control = NULL)
}
qrx <- if (x$rank) 
qr(x)
asgn <- x$assign[qrx$pivot[1L:x$rank]]
effects <- x$effects
if (!is.null(effects)) 
effects <- as.matrix(effects)[seq_along(asgn), , drop = FALSE]
rdf <- x$df.residual
resid <- as.matrix(x$residuals)
wt <- x$weights
if (!is.null(wt)) 
resid <- resid * sqrt(wt)
RSS <- colSums(resid^2)
uasgn <- unique(asgn)
nmeffect <- c("(Intercept)", attr(x$terms, "term.labels"))[1 + 
uasgn]
nterms <- length(uasgn)
nresp <- NCOL(effects)
df <- numeric(nterms)
ss <- matrix(NA, nterms, nresp)
if (nterms) {
for (i in seq(nterms)) {
ai <- asgn == uasgn[i]
df[i] <- sum(ai)
ef <- effects[ai, , drop = FALSE]
ss[i, ] <- if (sum(ai) > 1) 
colSums(ef^2)
else ef^2
}
keep <- df > 0L
if (!intercept && uasgn[1L] == 0) 
keep[1L] <- FALSE
nmeffect <- nmeffect[keep]
df <- df[keep]
ss <- ss[keep, , drop = FALSE]
nterms <- length(df)
}
cat("\nTerms:\n")
if (nterms == 0L) {
if (rdf > 0L) {
ss <- RSS
ssp <- sapply(ss, format)
if (!is.matrix(ssp)) 
ssp <- t(ssp)
tmp <- as.matrix(c(ssp, format(rdf)))
if (length(ss) > 1L) {
rn <- colnames(x$fitted.values)
if (is.null(rn)) 
  rn <- paste("resp", seq_along(ss))
}
else rn <- "Sum of Squares"
dimnames(tmp) <- list(c(rn, "Deg. of Freedom"), "Residuals")
print(tmp, quote = FALSE, right = TRUE)
cat("\n")
rs <- sqrt(RSS/rdf)
cat(if (length(rs) > 1L) 
"Residual standard errors:"
else "Residual standard error:", sapply(rs, format))
cat("\n")
}
else print(matrix(0, 2L, 1L, dimnames = list(c("Sum of Squares", 
"Deg. of Freedom"), "")))
}
else {
if (rdf > 0L) {
nterms <- nterms + 1L
df <- c(df, rdf)
ss <- rbind(ss, RSS)
nmeffect <- c(nmeffect, "Residuals")
}
ssp <- apply(zapsmall(ss), 2L, format)
tmp <- t(cbind(ssp, format(df)))
if (ncol(effects) > 1L) {
rn <- colnames(x$coeffficients) ### 
<--- HERE
if (is.null(rn)) 
rn <- paste("resp", seq(ncol(effects)))
}
else rn <- "Sum of Squares"
dimnames(tmp) <- list(c(rn, "Deg. of Freedom"), nmeffect)
print(tmp, quote = FALSE, right = TRUE)
rank <- x$rank
cat("\n")
if (rdf > 0L) {
rs <- sqrt(RSS/rdf)
cat(if (length(rs) > 1L) 
"Residual standard errors:"
else "Residual standard error:", sapply(rs, format))
cat("\n")
}
coef <- as.matrix(x$coefficients)[, 1L]  ## 
 <- NOT HERE
R <- qrx$qr
R <- R[1L:min(dim(R)), , drop = FALSE]
R[lower.tri(R)] <- 0
if (rank < (nc <- length(coef))) {
cat(paste(nc - rank, "out of", nc, "effects not estimable\n"))
R <- R[, 1L:rank, drop = FALSE]
}
d2 <- sum(abs(diag(R)))
diag(R) <- 0
if (sum(abs(R))/d2 > tol) 
cat("Estimated effects may be unbalanced\n")
else cat("Estimated effects are balanced\n")
if (nzchar(mess <- naprint(x$na.action))) 
cat(mess, "\n", sep = "")
}
invisible(x)
}




**
Electronic Mail is not secure, may not be read every day, and should not be 
used for urgent or sensitive issues 

__
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] Mysterious seg fault --- SOLVED

2018-08-13 Thread peter dalgaard
It's odd, possibly a bug, that you don't get 

Error: object 'nphi' not found

but I can't offhand see where the evaluation of args to .C/.Fortran is supposed 
to take place.

-pd

> On 13 Aug 2018, at 11:54 , Rolf Turner  wrote:
> 
> 
> On 13/08/18 20:45, Henrik Bengtsson wrote:
> 
>> On Mon, Aug 13, 2018 at 3:51 AM Rolf Turner  wrote:
>>> 
>>> 
>>> OK everybody!  You can relax.  :-) I managed to spot the loony.  After
>>> mucking around with valgrind, and before trying gdb, I had one more look
>>> at my code and *finally* saw the stupid thing that I had been doing.
>>> 
>>> In the call to .Fortran() I had a line
>>> 
>>>  nphi=as.integer(nphi),
>>> 
>>> but "nphi" was nowhere defined (!!!) in the R code.  The name "nphi"
>>> appeared as an argument in the Fortran subroutine in question, but was
>>> nowhere actually *used*!!!
>> Didn't R CMD check pick this up, that is, didn't it report that 'nphi'
>> is a "global" variable?
> 
> No it didn't.  The name only appears in the call to .Fortran().  I think if 
> it appeared in a call to an ordinary garden-variety R function then a warning 
> would have been issued.
> 
> Such a lapse would be hard for R CMD check to pick up.  E.g
> 
>   nphi=integer(1),
> 
> would be OK in a call to .Fortran (which would allow a value of nphi, 
> calculated within the called subroutine, to be *returned*) whereas
> 
>   nphi=as.integer(nphi),
> 
> causes trouble when nphi has never been defined (as I found out after a great 
> expenditure of time and torn-out hair).  In the former instance it doesn't 
> matter an FTCF whether nphi has been defined or not.
> 
> cheers,
> 
> Rolf
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
> __
> 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.

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

__
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] Mysterious seg fault --- SOLVED

2018-08-13 Thread Rolf Turner



On 13/08/18 20:45, Henrik Bengtsson wrote:


On Mon, Aug 13, 2018 at 3:51 AM Rolf Turner  wrote:



OK everybody!  You can relax.  :-) I managed to spot the loony.  After
mucking around with valgrind, and before trying gdb, I had one more look
at my code and *finally* saw the stupid thing that I had been doing.

In the call to .Fortran() I had a line

  nphi=as.integer(nphi),

but "nphi" was nowhere defined (!!!) in the R code.  The name "nphi"
appeared as an argument in the Fortran subroutine in question, but was
nowhere actually *used*!!!


Didn't R CMD check pick this up, that is, didn't it report that 'nphi'
is a "global" variable?


No it didn't.  The name only appears in the call to .Fortran().  I think 
if it appeared in a call to an ordinary garden-variety R function then a 
warning would have been issued.


Such a lapse would be hard for R CMD check to pick up.  E.g

   nphi=integer(1),

would be OK in a call to .Fortran (which would allow a value of nphi, 
calculated within the called subroutine, to be *returned*) whereas


   nphi=as.integer(nphi),

causes trouble when nphi has never been defined (as I found out after a 
great expenditure of time and torn-out hair).  In the former instance it 
doesn't matter an FTCF whether nphi has been defined or not.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Mysterious seg fault --- SOLVED

2018-08-13 Thread Henrik Bengtsson
On Mon, Aug 13, 2018 at 3:51 AM Rolf Turner  wrote:
>
>
> OK everybody!  You can relax.  :-) I managed to spot the loony.  After
> mucking around with valgrind, and before trying gdb, I had one more look
> at my code and *finally* saw the stupid thing that I had been doing.
>
> In the call to .Fortran() I had a line
>
>  nphi=as.integer(nphi),
>
> but "nphi" was nowhere defined (!!!) in the R code.  The name "nphi"
> appeared as an argument in the Fortran subroutine in question, but was
> nowhere actually *used*!!!

Didn't R CMD check pick this up, that is, didn't it report that 'nphi'
is a "global" variable?

/Henrik

>
> It seems that passing a non-existent value as an argument to a Fortran
> subroutine can *sometimes* confuse it.  Understandably.
>
> I think that this "nphi" was a left-over from an earlier version of the
> code.  I must have changed the code so that nphi was no longer needed,
> but then forgot to remove it from some places.  Psigh!  I hate myself
> sometimes.
>
> Anyhow, thanks to all those who took the time and made the effort to try
> to help me.
>
> cheers,
>
> Rolf
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> __
> 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] searching for a specific row name in R

2018-08-13 Thread Albrecht Kauffmann
Hello Deepa,

sum(x[,2] == "A501")
or
which(x[,2] == "A501")
.
Best,
Albrecht


-- 
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> Hello Everyone,
> 
> I have a 1000 x 20 matrix. The second column of the matrix has the names 
> of identifiers. How do I check when a certain identifier is present in 
> the set of 1000 identifier names present in the second column. For 
> instance, let the names of identifiers be A1,A2,...A1000. I want to 
> check whether A501 is present .How can this be checked?
> 
> Any help will be highly appreciated.
> 
> 
>   [[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.