Re: [R] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Ramnik Bansal
Taking this question further.

If I use a complex number or a numeric as an operand in logical
operations, to me it APPEARS that these two types are first coerced to
LOGICAL internally and then THIS logical output is further used as the
operand.

For eg.
> x <- 4+5i; c(x & F, x & T, x | F, x | T)
[1] FALSE  TRUE  TRUE  TRUE

This output is consistent with
> x <- 4+5i; c(as.logical(x) & F, as.logical(x) & T, as.logical(x) | F, 
> as.logical(x) | T)
[1] FALSE  TRUE  TRUE  TRUE

This consistency makes me draw an on-the-surface conclusion that in
the case of logical operations if the operand is not of type 'logical'
it is first coerced into 'logical'.

But this doesn't seem to be true because if that was the case it
should have worked with character operands as well, albeit following
the rules of NA in logical operations ( as per R help manual)

For e.g.
> x <- "abc"; c(as.logical(x) & F, as.logical(x) & T, as.logical(x) | F, 
> as.logical(x) | T)
[1] FALSENANA  TRUE

Whereas
> x <- "abc"; c(x & F, x & T, x | F, x | T)
Error in x & F :
  operations are possible only for numeric, logical or complex types

So my question basically is :
What does R actually do in the case of complex numbers Vs characters
as operands in logical operations ?

And adding some more:

consistent with above behavior with character,
> NA_character_ & FALSE
Error in NA_character_ & FALSE :
  operations are possible only for numeric, logical or complex types

R documentation on the other hand mentions:
Logical computations treat NA as a missing TRUE/FALSE value and so may
return TRUE or FALSE if the expression does not depend on the NA
operand.

Isn't NA mentioned in the R documentation to be interpreted as NA
irrespective of the type? Else, shouldn't the R documentation mention
"Logical computations treat NA except NA_character_ as a missing..."


Thanks,
Ramnik

ps: I hope I have phrased my question well enough this time not to end
up inviting the wrath of some R-Gods around on a mere R-mortal that I
am at this stage :) The more am becoming familiar with R, the more am
loving it and definitely don't intend to offend R Gods!

On Fri, May 19, 2017 at 6:57 PM, Ted Harding  wrote:
> [I unadvertently sent my reply below to Jeremie, instead of R-help.
> Also, I havve had an additional thought which may clarify things
> for R users].
> [Original reply]:
> The point about this is that (as Rolf wrote) FALSE & (anything)
> is FALSE, provided logical NA is either TRUE ot FALSE but,
> because the "NA" says that it is not known which it is,
> it could be "anything". And, indeed, if "NA" is given the
> "missing" meaning and if we assume that a missing logical value
> did indeed have a value (necessarily either TRUE or FALSE),
> then it follows logically that FALSE & NA = FALS£.
>
> On the other hand, if with the "missing" interpretation of "NA"
> we don't even know that it is a logical, then it might be fair
> enough to say FALSE & NA = NA.
> Ted.
>
> [Additional thought]:
> Testing to see what would happen if the NA were not loigical,
> I put myself (not being logical ... ) on the line, facing up to R:
>X <- "Ted"
>FALSE & X
>Error in FALSE & X :
>operations are possible only for numeric, logical or complex types
> So R will refuse to deal with any variable which cannot partake in
> a logical expression.
>
> Ted.
>
> On Fri, 2017-05-19 at 14:24 +0200, Jérémie Juste wrote:
>> My apologies if I was not clear enough,
>>
>> TRUE & NA could be either TRUE or FALSE and consequently is NA.
>> why is   FALSE & NA = FALSE?  NA could be TRUE or FALSE, so FALSE & NA
>> should be NA?
>>
>>
>> On Fri, May 19, 2017 at 2:13 PM, Rolf Turner 
>> wrote:
>>
>> > On 20/05/17 00:01, Jérémie Juste wrote:
>> >
>> >> Hello,
>> >>
>> >> Rolf said,
>> >>
>> >> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
>> >> either TRUE or FALSE and consequently is NA.
>> >>
>> >> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
>> >>
>> >>
>> >> According to this logic why is
>> >>
>> >> FALSE & NA
>> >>
>> >> [1] FALSE
>> >>
>> >
>> > Huh
>> >
>> >
>> > cheers,
>> >
>> > Rolf Turner
>> >
>> > --
>> > Technical Editor ANZJS
>> > Department of Statistics
>> > University of Auckland
>> > Phone: +64-9-373-7599 ext. 88276
>> >
>>
>>
>>
>> --
>> Jérémie Juste
>>
>>   [[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 

Re: [R] train function in caret package

2017-05-19 Thread Elahe chalabi via R-help
Any answer?! 

On Friday, May 19, 2017 6:33 AM, Elahe chalabi via R-help 
 wrote:
 

 Hi all,

I'm running train function from caret package on my data set patientdata:

    model=train(type~., data=patientdata, method="lvq", preProcess="scale", 
trControl=control)
and I get this error:

    Error in comp(expr, env = envir, options = list(suppressUndefined = TRUE)) 
: 

    could not find function "mayCallBrowser"
Does anyone know how should I solve it?!

Thanks for any help!
Elahe

__
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] [EXTERNAL] Re: had non-zero exit status

2017-05-19 Thread Pramod Anugu
I tried using latest R-3-4.0. ./configure works but when I type make it does 
not work.

From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Friday, May 19, 2017 4:27 PM
To: Pramod Anugu 
Cc: r-help@R-project.org
Subject: [EXTERNAL] Re: [R] had non-zero exit status

Try using a more recent version of R - 3.4.0 is the current version and 3.1.0 
is considered pretty old now.  'R_DoubleColonSymbol' is in 
RHOME/include/Rinternals.h in R-3.3.0 but not in R-2.15.0.  I don't know 
exactly when it was added.

Bill Dunlap
TIBCO Software
wdunlap 
tibco.com

On Fri, May 19, 2017 at 8:04 AM, Pramod Anugu 
> wrote:
Hi , When installing  a tidyr package. I get an error message to install rlang 
package and I try to install rlang I get
"installation of package 'rlang' had non-zero exit status"
Please advise.

Ran
install.packages("tidyr", dependencies=TRUE)

getting below error message. Please advise. R version 3.1.0
pic  -g -O2  -c splice.c -o splice.o
In file included from splice.c:2:
vector.h: In function 'namespace_rlang_sym':
vector.h:94: error: 'R_DoubleColonSymbol' undeclared (first use in this
function)
vector.h:94: error: (Each undeclared identifier is reported only once
vector.h:94: error: for each function it appears in.)
make: *** [splice.o] Error 1
ERROR: compilation failed for package 'rlang'
* removing '/usr/local/lib64/R/library/rlang'
ERROR: dependency 'rlang' is not available for package 'tibble'
* removing '/usr/local/lib64/R/library/tibble'
ERROR: dependencies 'tibble', 'dplyr' are not available for package 'tidyr'
* removing '/usr/local/lib64/R/library/tidyr'


Individuals who have received this information in error or are not authorized 
to receive it must promptly return or dispose of the information and notify the 
sender. Those individuals are hereby notified that they are strictly prohibited 
from reviewing, forwarding, printing, copying, distributing or using this 
information in any way.

[[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] had non-zero exit status

2017-05-19 Thread William Dunlap via R-help
Try using a more recent version of R - 3.4.0 is the current version and
3.1.0 is considered pretty old now.  'R_DoubleColonSymbol' is in
RHOME/include/Rinternals.h in R-3.3.0 but not in R-2.15.0.  I don't know
exactly when it was added.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, May 19, 2017 at 8:04 AM, Pramod Anugu  wrote:

> Hi , When installing  a tidyr package. I get an error message to install
> rlang package and I try to install rlang I get
> "installation of package 'rlang' had non-zero exit status"
> Please advise.
>
> Ran
> install.packages("tidyr", dependencies=TRUE)
>
> getting below error message. Please advise. R version 3.1.0
> pic  -g -O2  -c splice.c -o splice.o
> In file included from splice.c:2:
> vector.h: In function 'namespace_rlang_sym':
> vector.h:94: error: 'R_DoubleColonSymbol' undeclared (first use in this
> function)
> vector.h:94: error: (Each undeclared identifier is reported only once
> vector.h:94: error: for each function it appears in.)
> make: *** [splice.o] Error 1
> ERROR: compilation failed for package 'rlang'
> * removing '/usr/local/lib64/R/library/rlang'
> ERROR: dependency 'rlang' is not available for package 'tibble'
> * removing '/usr/local/lib64/R/library/tibble'
> ERROR: dependencies 'tibble', 'dplyr' are not available for package 'tidyr'
> * removing '/usr/local/lib64/R/library/tidyr'
>
>
> Individuals who have received this information in error or are not
> authorized to receive it must promptly return or dispose of the information
> and notify the sender. Those individuals are hereby notified that they are
> strictly prohibited from reviewing, forwarding, printing, copying,
> distributing or using this information in any way.
>
> [[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.


[R] had non-zero exit status

2017-05-19 Thread Pramod Anugu
Hi , When installing  a tidyr package. I get an error message to install rlang 
package and I try to install rlang I get
"installation of package 'rlang' had non-zero exit status"
Please advise.

Ran
install.packages("tidyr", dependencies=TRUE)

getting below error message. Please advise. R version 3.1.0
pic  -g -O2  -c splice.c -o splice.o
In file included from splice.c:2:
vector.h: In function 'namespace_rlang_sym':
vector.h:94: error: 'R_DoubleColonSymbol' undeclared (first use in this
function)
vector.h:94: error: (Each undeclared identifier is reported only once
vector.h:94: error: for each function it appears in.)
make: *** [splice.o] Error 1
ERROR: compilation failed for package 'rlang'
* removing '/usr/local/lib64/R/library/rlang'
ERROR: dependency 'rlang' is not available for package 'tibble'
* removing '/usr/local/lib64/R/library/tibble'
ERROR: dependencies 'tibble', 'dplyr' are not available for package 'tidyr'
* removing '/usr/local/lib64/R/library/tidyr'


Individuals who have received this information in error or are not authorized 
to receive it must promptly return or dispose of the information and notify the 
sender. Those individuals are hereby notified that they are strictly prohibited 
from reviewing, forwarding, printing, copying, distributing or using this 
information in any way.

[[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] [FORGED] p-value=0 running log-rank test

2017-05-19 Thread William Dunlap via R-help
This is a minor problem with the print method for "survdiff" objects.  It
acts like it computes the p-value with
   1 - pchisq( chisq, df)
instead of
pchisq( chisq, df, lower.tail = FALSE)
The former will give zero when the latter gives a number less than about
10^-16.

Most people would accept 0 instead of 10^-16, but the 6-sigma folks worry
about probabilities of 10^-10 so perhaps it is worth making the easy change.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, May 18, 2017 at 10:14 PM, Rolf Turner 
wrote:

>
> This is not an R question.
>
> Your question indicates that you really need to learn some statistics.
>
> To answer the very last part:
>
> > pchisq(430,3,lower=FALSE)
> [1] 7.020486e-93
>
> And if that is not 0 to all intents and purposes, then God help us all.
>
> cheers,
>
> Rolf Turner
>
> On 19/05/17 12:48, Anne Karin da Mota Borges wrote:
>
>> Dear all,
>>
>> I have a question concerning the p-value. When running log-rank test I get
>> a p-value = 0.
>> What is it mean? Can this be true? Why aren´t there decimal points? Is
>> there a way to find out the exact p-value?
>>
>> Here is the output:
>>
>> survdiff(Surv(tempo2,status)~tphist, data=base,rho=0)
>>>
>> Call:
>> survdiff(formula = Surv(tempo2, status) ~ tphist, data = base,
>> rho = 0)
>>
>>N Observed Expected (O-E)^2/E (O-E)^2/V
>> tphist=1 513   19   40.87911.710  9.00e+01
>> tphist=2  4943.892 0.003  3.27e-03
>> tphist=3  2391.68631.717  3.29e+01
>> tphist=4  18   150.543   385.172  3.91e+02
>>
>>  Chisq= 430  on 3 degrees of freedom, p= 0
>>
>> Thank you in advance.
>>
>
> __
> 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/posti
> ng-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] PROBLEM USING DICTIONARY WITH TM PACKAGE

2017-05-19 Thread Patrick Casimir
Thanks Jeff. I will try elsewhere.


Patrick Casimir, PhD
Health Analytics, Data Science, Big Data Expert & Independent Consultant
C: 954.614.1178


From: Jeff Newmiller 
Sent: Friday, May 19, 2017 11:04:22 AM
To: r-help@r-project.org; Patrick Casimir; r-help@r-project.org
Subject: Re: [R] PROBLEM USING DICTIONARY WITH TM PACKAGE

Considering the deafening silence after three repeats, one explanation could be 
that you are asking the wrong group of people. It is also possible that your 
failure to follow the Posting Guide with regard to using plain text email and a 
reproducible example [1][2] means that readers who are not experts do not feel 
inclined to follow along with you and help you think of solutions. Keep in mind 
that supporting  contributed packages like tm is technically not on topic here, 
though people often do feel the urge to help solve problems with them anyway.

With regard to asking the wrong group of people I would suggest asking the 
maintainer of the tm package what they recommend. See the help for the 
maintainer function or read the CRAN Web page for that package.

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html
--
Sent from my phone. Please excuse my brevity.

On May 19, 2017 7:12:45 AM PDT, Patrick Casimir  wrote:
>Dear Members & Experts,
>
>
>Since the Dictionary () function is no longer available with the tm
>package. How do I use other functions to do the same as below? I want
>to capture a list of specific terms from a corpus. By example, if my
>corpus has 102 files. I want to see a list with occurrences of
>prostatic, adenocarcinoma, grade in all 102 files. When I use the
>function Dictionary (), I got the error: Error: could not find function
>"Dictionary"
>
>
>> d <- Dictionary(c("prostatic", "adenocarcinoma", "grade"))
>> inspect(DocumentTermMatrix(docs, list(dictionary = d)))
>
>
>But if I use the codes below using inspect, the dictionary only returns
>the terms for 10 files instead of 102. I need a way to get my
>dictionary to capture and return those terms for all 102 files or
>whatever other terms I select. I know I am close but inspect () is not
>the right function.
>
>
>> myTerms <- c("prostatic", "adenocarcinoma", "grade")
>> inspect(DocumentTermMatrix(docs, list(dictionary = myTerms)))
>
> <>
> Non-/sparse entries: 292/14
> Sparsity   : 5%
> Maximal term length: 14
> Weighting  : term frequency (tf)
> Sample :
>Terms
> Docsadenocarcinoma grade prostatic
>   Patient14.txt 11 6 3
>   Patient15.txt  712 2
>   Patient16.txt 1316 4
>   Patient19.txt  513 2
>   Patient24.txt 1112 4
>   Patient25.txt  8 9 4
>   Patient41.txt  810 4
>   Patient46.txt  810 3
>   Patient8.txt   912 2
>   Patient9.txt   823 2
>
>
>Thanks
>
>
>
>Patrick Casimir, PhD
>Health Analytics, Data Science, Big Data Expert & Independent
>Consultant
>C: 954.614.1178
>
>
>
>   [[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] mixed Model: asreml-r versus nmle,lme4 or coxme

2017-05-19 Thread Brigitte Mangin
Thank's  Thierry, but as i mentioned, it is not a constant depending only of 
the data, since with the same observed trait:


the difference (between asreml and R packages) is equal to 29.40 in the model 
with a fixed effect (Type)

and the difference is equal to 32.16 in the model with only mu.


And that, it is a big concern.



De : Thierry Onkelinx 
Envoy� : vendredi 19 mai 2017 16:40
� : Brigitte Mangin
Cc : r-h...@lists.r-project.org
Objet : Re: [R] mixed Model: asreml-r versus nmle,lme4 or coxme

Dear Brigitte,

Maybe because the log likelihood is calculated differently. Note that the log 
likelihood contains a constant which only depends on the data. So one can 
safely omit that part for model comparison, assuming that use you the same 
formula to calculate the likelihood for all models.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data. ~ John 
Tukey

2017-05-19 14:30 GMT+02:00 Brigitte Mangin 
>:



Hi,

Did somebody know why asreml does not provide the same REML loglikehood  as 
coxme, lme4 or lmne.
Here is a simple example showing the differences:


###
library(lme4)
library(coxme)
library(asreml)
library(nlme)

data(ergoStool, package="nlme") # use a data set from nlme

fit1 <- lmekin(effort ~ Type+(1|Subject), data=ergoStool,method="REML")
fit1$loglik #-60.56539
fit2 <- lmer(effort ~ Type+(1|Subject), data=ergoStool,REML=TRUE)
logLik(fit2) #'log Lik.' -60.56539 (df=6)
fit3<-asreml(fixed=effort ~ Type,random=~Subject,data=ergoStool,
na.method.X="omit",na.method.Y="omit")
fit3$loglik #-31.15936
fit4<-lme(effort ~ Type,random=~1|Subject, data = ergoStool,method="REML")
fit4$logLik  #-60.56539

fit1 <- lmekin(effort ~ (1|Subject), data=ergoStool,method="REML")
fit1$loglik #-78.91898
fit2 <- lmer(effort ~ (1|Subject), data=ergoStool,REML=TRUE)
logLik(fit2) #'log Lik.' -78.91898 (df=3)
fit3<-asreml(fixed=effort ~ 1,random=~Subject,data=ergoStool,
na.method.X="omit",na.method.Y="omit")
fit3$loglik #-46.75614
fit4<-lme(effort ~ 1,random=~1|Subject, data = ergoStool,method="REML")
fit4$logLik #-78.91898



If it was just a constant value between the two models (with or without the 
fixed effect) it would not be important. But it is not.
I checked that the variance component estimators were equal.

Thanks



[[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] PROBLEM USING DICTIONARY WITH TM PACKAGE

2017-05-19 Thread Jeff Newmiller
Considering the deafening silence after three repeats, one explanation could be 
that you are asking the wrong group of people. It is also possible that your 
failure to follow the Posting Guide with regard to using plain text email and a 
reproducible example [1][2] means that readers who are not experts do not feel 
inclined to follow along with you and help you think of solutions. Keep in mind 
that supporting  contributed packages like tm is technically not on topic here, 
though people often do feel the urge to help solve problems with them anyway.

With regard to asking the wrong group of people I would suggest asking the 
maintainer of the tm package what they recommend. See the help for the 
maintainer function or read the CRAN Web page for that package. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html
-- 
Sent from my phone. Please excuse my brevity.

On May 19, 2017 7:12:45 AM PDT, Patrick Casimir  wrote:
>Dear Members & Experts,
>
>
>Since the Dictionary () function is no longer available with the tm
>package. How do I use other functions to do the same as below? I want
>to capture a list of specific terms from a corpus. By example, if my
>corpus has 102 files. I want to see a list with occurrences of
>prostatic, adenocarcinoma, grade in all 102 files. When I use the
>function Dictionary (), I got the error: Error: could not find function
>"Dictionary"
>
>
>> d <- Dictionary(c("prostatic", "adenocarcinoma", "grade"))
>> inspect(DocumentTermMatrix(docs, list(dictionary = d)))
>
>
>But if I use the codes below using inspect, the dictionary only returns
>the terms for 10 files instead of 102. I need a way to get my
>dictionary to capture and return those terms for all 102 files or
>whatever other terms I select. I know I am close but inspect () is not
>the right function.
>
>
>> myTerms <- c("prostatic", "adenocarcinoma", "grade")
>> inspect(DocumentTermMatrix(docs, list(dictionary = myTerms)))
>
> <>
> Non-/sparse entries: 292/14
> Sparsity   : 5%
> Maximal term length: 14
> Weighting  : term frequency (tf)
> Sample :
>Terms
> Docsadenocarcinoma grade prostatic
>   Patient14.txt 11 6 3
>   Patient15.txt  712 2
>   Patient16.txt 1316 4
>   Patient19.txt  513 2
>   Patient24.txt 1112 4
>   Patient25.txt  8 9 4
>   Patient41.txt  810 4
>   Patient46.txt  810 3
>   Patient8.txt   912 2
>   Patient9.txt   823 2
>
>
>Thanks
>
>
>
>Patrick Casimir, PhD
>Health Analytics, Data Science, Big Data Expert & Independent
>Consultant
>C: 954.614.1178
>
>
>
>   [[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] PROBLEM USING DICTIONARY WITH TM PACKAGE

2017-05-19 Thread Patrick Casimir
Dear Members & Experts,


Since the Dictionary () function is no longer available with the tm package. 
How do I use other functions to do the same as below? I want to capture a list 
of specific terms from a corpus. By example, if my corpus has 102 files. I want 
to see a list with occurrences of prostatic, adenocarcinoma, grade in all 102 
files. When I use the function Dictionary (), I got the error: Error: could not 
find function "Dictionary"


> d <- Dictionary(c("prostatic", "adenocarcinoma", "grade"))
> inspect(DocumentTermMatrix(docs, list(dictionary = d)))


But if I use the codes below using inspect, the dictionary only returns the 
terms for 10 files instead of 102. I need a way to get my dictionary to capture 
and return those terms for all 102 files or whatever other terms I select. I 
know I am close but inspect () is not the right function.


> myTerms <- c("prostatic", "adenocarcinoma", "grade")
> inspect(DocumentTermMatrix(docs, list(dictionary = myTerms)))

 <>
 Non-/sparse entries: 292/14
 Sparsity   : 5%
 Maximal term length: 14
 Weighting  : term frequency (tf)
 Sample :
Terms
 Docsadenocarcinoma grade prostatic
   Patient14.txt 11 6 3
   Patient15.txt  712 2
   Patient16.txt 1316 4
   Patient19.txt  513 2
   Patient24.txt 1112 4
   Patient25.txt  8 9 4
   Patient41.txt  810 4
   Patient46.txt  810 3
   Patient8.txt   912 2
   Patient9.txt   823 2


Thanks



Patrick Casimir, PhD
Health Analytics, Data Science, Big Data Expert & Independent Consultant
C: 954.614.1178



[[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] Problem with choose.files(default=..., multi=FALSE)

2017-05-19 Thread Duncan Murdoch

On 10/05/2017 6:46 AM, Keith Jewell wrote:

Thanks for confirming that I wasn't being stupid :-}

When using default=pathlong I get the _correct_ starting directory...
(M:\test\Averyveryveryveryverylongfoldername\Averyveryveryveryverylongfoldername\Averyveryveryveryverylongfoldername)

... both in the environment I indicated originally (Windows Server 2008
R2 x64) and also in Windows 10 x64


This should now be fixed in R-patched and R-devel, as of revision 72703. 
 The issue was that the Windows API function returned its results in a 
slightly different format when multi=FALSE.  When there was no default 
or a short one, the two formats happened to look identical so we didn't 
notice this, but they differed when the default was longer than the result.


Duncan Murdoch



Keith Jewell

On 09/05/2017 17:49, Duncan Murdoch wrote:

On 09/05/2017 12:06 PM, Keith Jewell wrote:

I'm very hesitant to suggest that there's a bug in such a venerable R
function, but I can't see what I'm doing wrong. Any comments are welcome


Yes, it looks like a bug.  One other thing I find a little strange: the
starting directory seems wrong when I have the pathlong default.  Did
you see that?  (I'm in Windows 10, not the same version as you.)

Duncan Murdoch



When using choose.files() where:
 default = something
 multi = FALSE
 selected file path is shorter than the default
... then the returned value is at least as long as the default,
characters from default appearing (wrongly) at the end of the returned
value.

Example, in which all but the first choose.files() select
"M:\\test\\target.dat". Note the last result.

 > pathlong <- choose.files(caption = "long")
 > pathlong # long file name to use as default for short selection
[1]
"M:\\test\\Averyveryveryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\target.dat"

 > choose.files(caption = "short")  # no default without multi works
[1] "M:\\test\\target.dat"
 > choose.files(default=pathlong, caption = "short") # default without
multi= works
[1] "M:\\test\\target.dat"
 > choose.files(caption = "short", multi = FALSE) # multi = FALSE
without default works
[1] "M:\\test\\target.dat"
 > choose.files(default=pathlong, caption = "short", multi = TRUE) #
multi = TRUE with default works
[1] "M:\\test\\target.dat"
 > choose.files(default=pathlong, caption = "short", multi = FALSE) #
multi = FALSE with default fails
[1]
"M:\\test\\target.dat\\ryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\target.dat"


 > # in case it's relevant
 > sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C

[5] LC_TIME=English_United Kingdom.1252

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

other attached packages:
  [1] CBRIutils_1.0   stringr_1.2.0   svSocket_0.9-57 TinnR_1.0-5
R2HTML_2.3.2
  [6] Hmisc_4.0-3 ggplot2_2.2.1   Formula_1.2-1   survival_2.41-3
lattice_0.20-35

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-2  htmlTable_1.9   digest_0.6.12
htmltools_0.3.6
  [5] splines_3.4.0   scales_0.4.1grid_3.4.0
checkmate_1.8.2
  [9] devtools_1.12.0 knitr_1.15.1munsell_0.4.3
compiler_3.4.0
[13] tibble_1.3.0nnet_7.3-12 acepack_1.4.1
Matrix_1.2-10
[17] svMisc_0.9-70   plyr_1.8.4  base64enc_0.1-3
data.table_1.10.4
[21] stringi_1.1.5   magrittr_1.5gtable_0.2.0
colorspace_1.3-2
[25] foreign_0.8-68  cluster_2.0.6   gridExtra_2.2.1
htmlwidgets_0.8
[29] withr_1.0.2 lazyeval_0.2.0  backports_1.0.5
memoise_1.1.0
[33] rpart_4.1-11Rcpp_0.12.10latticeExtra_0.6-28
 >

__
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] train function in caret package

2017-05-19 Thread Elahe chalabi via R-help
Hi all,

I'm running train function from caret package on my data set patientdata:

model=train(type~., data=patientdata, method="lvq", preProcess="scale", 
trControl=control)
and I get this error:

Error in comp(expr, env = envir, options = list(suppressUndefined = TRUE)) 
: 

 could not find function "mayCallBrowser"
Does anyone know how should I solve it?!

Thanks for any help!
Elahe

__
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] mixed Model: asreml-r versus nmle,lme4 or coxme

2017-05-19 Thread Brigitte Mangin



Hi,

Did somebody know why asreml does not provide the same REML loglikehood  as 
coxme, lme4 or lmne.
Here is a simple example showing the differences:


###
library(lme4)
library(coxme)
library(asreml)
library(nlme)

data(ergoStool, package="nlme") # use a data set from nlme

fit1 <- lmekin(effort ~ Type+(1|Subject), data=ergoStool,method="REML")
fit1$loglik #-60.56539
fit2 <- lmer(effort ~ Type+(1|Subject), data=ergoStool,REML=TRUE)
logLik(fit2) #'log Lik.' -60.56539 (df=6)
fit3<-asreml(fixed=effort ~ Type,random=~Subject,data=ergoStool,
na.method.X="omit",na.method.Y="omit")
fit3$loglik #-31.15936
fit4<-lme(effort ~ Type,random=~1|Subject, data = ergoStool,method="REML")
fit4$logLik  #-60.56539

fit1 <- lmekin(effort ~ (1|Subject), data=ergoStool,method="REML")
fit1$loglik #-78.91898
fit2 <- lmer(effort ~ (1|Subject), data=ergoStool,REML=TRUE)
logLik(fit2) #'log Lik.' -78.91898 (df=3)
fit3<-asreml(fixed=effort ~ 1,random=~Subject,data=ergoStool,
na.method.X="omit",na.method.Y="omit")
fit3$loglik #-46.75614
fit4<-lme(effort ~ 1,random=~1|Subject, data = ergoStool,method="REML")
fit4$logLik #-78.91898



If it was just a constant value between the two models (with or without the 
fixed effect) it would not be important. But it is not.
I checked that the variance component estimators were equal.

Thanks



[[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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Ted Harding
[I unadvertently sent my reply below to Jeremie, instead of R-help.
Also, I havve had an additional thought which may clarify things
for R users].
[Original reply]:
The point about this is that (as Rolf wrote) FALSE & (anything)
is FALSE, provided logical NA is either TRUE ot FALSE but,
because the "NA" says that it is not known which it is,
it could be "anything". And, indeed, if "NA" is given the
"missing" meaning and if we assume that a missing logical value
did indeed have a value (necessarily either TRUE or FALSE),
then it follows logically that FALSE & NA = FALS£.

On the other hand, if with the "missing" interpretation of "NA"
we don't even know that it is a logical, then it might be fair
enough to say FALSE & NA = NA.
Ted.

[Additional thought]:
Testing to see what would happen if the NA were not loigical,
I put myself (not being logical ... ) on the line, facing up to R:
   X <- "Ted"
   FALSE & X
   Error in FALSE & X : 
   operations are possible only for numeric, logical or complex types
So R will refuse to deal with any variable which cannot partake in
a logical expression.

Ted.

On Fri, 2017-05-19 at 14:24 +0200, Jérémie Juste wrote:
> My apologies if I was not clear enough,
> 
> TRUE & NA could be either TRUE or FALSE and consequently is NA.
> why is   FALSE & NA = FALSE?  NA could be TRUE or FALSE, so FALSE & NA
> should be NA?
> 
> 
> On Fri, May 19, 2017 at 2:13 PM, Rolf Turner 
> wrote:
> 
> > On 20/05/17 00:01, Jérémie Juste wrote:
> >
> >> Hello,
> >>
> >> Rolf said,
> >>
> >> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
> >> either TRUE or FALSE and consequently is NA.
> >>
> >> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
> >>
> >>
> >> According to this logic why is
> >>
> >> FALSE & NA
> >>
> >> [1] FALSE
> >>
> >
> > Huh
> >
> >
> > cheers,
> >
> > Rolf Turner
> >
> > --
> > Technical Editor ANZJS
> > Department of Statistics
> > University of Auckland
> > Phone: +64-9-373-7599 ext. 88276
> >
> 
> 
> 
> -- 
> Jérémie Juste
> 
>   [[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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Jeff Newmiller
FALSE & FALSE -> FALSE
FALSE & TRUE -> FALSE

Why do you need to know what the second value is? It doesn't matter what it 
is... the answer is FALSE. 
-- 
Sent from my phone. Please excuse my brevity.

On May 19, 2017 5:24:06 AM PDT, "Jérémie Juste"  wrote:
>My apologies if I was not clear enough,
>
>TRUE & NA could be either TRUE or FALSE and consequently is NA.
>why is   FALSE & NA = FALSE?  NA could be TRUE or FALSE, so FALSE & NA
>should be NA?
>
>
>On Fri, May 19, 2017 at 2:13 PM, Rolf Turner 
>wrote:
>
>> On 20/05/17 00:01, Jérémie Juste wrote:
>>
>>> Hello,
>>>
>>> Rolf said,
>>>
>>> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
>>> either TRUE or FALSE and consequently is NA.
>>>
>>> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
>>>
>>>
>>> According to this logic why is
>>>
>>> FALSE & NA
>>>
>>> [1] FALSE
>>>
>>
>> Huh
>>
>>
>> cheers,
>>
>> Rolf Turner
>>
>> --
>> Technical Editor ANZJS
>> Department of Statistics
>> University of Auckland
>> Phone: +64-9-373-7599 ext. 88276
>>
>
>
>
>-- 
>Jérémie Juste
>
>   [[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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Duncan Murdoch

On 19/05/2017 8:48 AM, S Ellison wrote:

SQL, for example, generally takes the view that any
expression involving 'missing' is 'missing'.


Well, then SQL gets it wrong.


Well, that's a view. But paraphrasing an  R Turner from a few lines away in the 
same email:


One should be very, very circumspect about presuming to know better than
SQL


It's a choice. I understand and respect R's. But I can also understand why 
someone might have expected something different.


You're right about SQL.  But for R, it's pretty simple to read the help 
page on NA, and it is quite explicit about this:


"Logical computations treat NA as a missing TRUE/FALSE value, and so may 
return TRUE or FALSE if the expression does not depend on the NA operand."


I'm surprised nobody on this thread has quoted that before.

Duncan Murdoch

__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread peter dalgaard

> On 19 May 2017, at 14:24 , Jérémie Juste  wrote:
> 
> My apologies if I was not clear enough,
> 
> TRUE & NA could be either TRUE or FALSE and consequently is NA.
> why is   FALSE & NA = FALSE?  NA could be TRUE or FALSE, so FALSE & NA
> should be NA?
> 

At the risk of flogging a dead horse:

FALSE & TRUE = FALSE
FALSE & FALSE = FALSE

FALSE & x = FALSE, whatever the value of x, hence 

FALSE & NA = FALSE

Get it?  

-pd


> 
> On Fri, May 19, 2017 at 2:13 PM, Rolf Turner 
> wrote:
> 
>> On 20/05/17 00:01, Jérémie Juste wrote:
>> 
>>> Hello,
>>> 
>>> Rolf said,
>>> 
>>> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
>>> either TRUE or FALSE and consequently is NA.
>>> 
>>> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
>>> 
>>> 
>>> According to this logic why is
>>> 
>>>FALSE & NA
>>> 
>>> [1] FALSE
>>> 
>> 
>> Huh
>> 
>> 
>> cheers,
>> 
>> Rolf Turner
>> 
>> --
>> Technical Editor ANZJS
>> Department of Statistics
>> University of Auckland
>> Phone: +64-9-373-7599 ext. 88276
>> 
> 
> 
> 
> -- 
> Jérémie Juste
> 
>   [[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.

-- 
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread S Ellison
> > SQL, for example, generally takes the view that any 
> > expression involving 'missing' is 'missing'.
> 
> Well, then SQL gets it wrong.

Well, that's a view. But paraphrasing an  R Turner from a few lines away in the 
same email:

> One should be very, very circumspect about presuming to know better than
> SQL

It's a choice. I understand and respect R's. But I can also understand why 
someone might have expected something different.

S


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Jérémie Juste
My apologies if I was not clear enough,

TRUE & NA could be either TRUE or FALSE and consequently is NA.
why is   FALSE & NA = FALSE?  NA could be TRUE or FALSE, so FALSE & NA
should be NA?


On Fri, May 19, 2017 at 2:13 PM, Rolf Turner 
wrote:

> On 20/05/17 00:01, Jérémie Juste wrote:
>
>> Hello,
>>
>> Rolf said,
>>
>> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
>> either TRUE or FALSE and consequently is NA.
>>
>> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
>>
>>
>> According to this logic why is
>>
>> FALSE & NA
>>
>> [1] FALSE
>>
>
> Huh
>
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>



-- 
Jérémie Juste

[[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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Rolf Turner

On 20/05/17 00:01, Jérémie Juste wrote:

Hello,

Rolf said,

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.


According to this logic why is

FALSE & NA

[1] FALSE


Huh

cheers,

Rolf Turner

--
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Rolf Turner

On 19/05/17 23:38, S Ellison wrote:

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.

As I said *think* about it; don't just go with your immediate knee-jerk
(simplistic) reaction.


Hmm... not sure that was quite fair to the OP.


The OP complained that the logical operators in R are inconsistent. 
This is an arrogant and presumptuous assertion that deserves a 
reprimand.  One should be very, very circumspect about presuming to know 
better than R.



Yes, FALSE &
== FALSE. But 'NA' does not mean 'anything'; it means 'missing' (see
?'NA').


Well, duh.  Yes, I know what NA means.  If it's missing, you don't know 
what it's value is.  But it doesn't *matter* what its value is; FALSE &

 is FALSE.  So FALSE & NA is FALSE, irrespective of what NA
"really" is.


It is much less obvious that FALSE &  should generate a
non-missing value. SQL, for example, generally takes the view that any
expression involving 'missing' is 'missing'.


Well, then SQL gets it wrong.


And R's behaviour can look odd if the vagaries of real data intervene:
b1 <- c(A=TRUE, C=FALSE)
b2 <- c(A=FALSE, B=FALSE, C=TRUE)
b1['B'] & b2['B']
#Which returns
# 
# FALSE

which - particularly since it appears without warning 


Everything appears without warning.  Nobody expected the Spanish 
Inquisition.



 - is not an obviously sensible outcome.


Why not?  It's obviously sensible to me, and to anyone else who is 
thinking.  Since b1['B'] is NA (b1 doesn't have an entry named 'B') and 
b2['B'] is FALSE we get NA & FALSE which is FALSE.  Where's the problem?


The "" in the output that you show is the *name* of the 'B' entry of 
b1, and since there isn't one, it doesn't have a name.  So the name is 
missing whence it is rendered as "" (missing character).



I am not suggesting a change to R's logical operations, which have
clearly been thought through (that is evident from NA ==
FALSE == FALSE). But R's behaviour looks to me like a choice among
difficult alternatives, rather than the only possible choice. I'd
give the OP some credit for that.


You seem to be arguing for the sake of arguing.  It's really quite 
straightforward *if* you *think* about it.


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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Jérémie Juste
Hello,

Rolf said,

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.


According to this logic why is

> FALSE & NA
>
[1] FALSE
?

Best regards,

Jeremie

On Fri, May 19, 2017 at 1:38 PM, S Ellison  wrote:

> > TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
> > either TRUE or FALSE and consequently is NA.
> >
> > OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
> >
> > As I said *think* about it; don't just go with your immediate knee-jerk
> > (simplistic) reaction.
>
> Hmm... not sure that was quite fair to the OP. Yes,  FALSE &  ==
> FALSE. But 'NA' does not mean 'anything'; it means 'missing' (see ?'NA').
> It is much less obvious that FALSE &  should generate a
> non-missing value. SQL, for example, generally  takes the view that any
> expression involving 'missing' is 'missing'.
>
> And R's behaviour can look odd if the vagaries of real data intervene:
> b1 <- c(A=TRUE, C=FALSE)
> b2 <- c(A=FALSE, B=FALSE, C=TRUE)
> b1['B'] & b2['B']
> #Which returns
> # 
> # FALSE
>
> which - particularly since it appears without warning - is not an
> obviously sensible outcome.
>
> I am not suggesting a change to R's logical operations, which have clearly
> been thought through (that is evident from NA == FALSE == FALSE).
> But R's behaviour looks to me like a choice among difficult alternatives,
> rather than the only possible choice. I'd give the OP some credit for that.
>
> S Ellison
>
>
> S Ellison
>
>
>
>
>
>
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:18}}

__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread S Ellison
> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
> either TRUE or FALSE and consequently is NA.
> 
> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.
>
> As I said *think* about it; don't just go with your immediate knee-jerk
> (simplistic) reaction.

Hmm... not sure that was quite fair to the OP. Yes,  FALSE &  == 
FALSE. But 'NA' does not mean 'anything'; it means 'missing' (see ?'NA'). It is 
much less obvious that FALSE &  should generate a non-missing value. 
SQL, for example, generally  takes the view that any expression involving 
'missing' is 'missing'. 

And R's behaviour can look odd if the vagaries of real data intervene:
b1 <- c(A=TRUE, C=FALSE)
b2 <- c(A=FALSE, B=FALSE, C=TRUE)
b1['B'] & b2['B']
#Which returns
#  
# FALSE 

which - particularly since it appears without warning - is not an obviously 
sensible outcome. 

I am not suggesting a change to R's logical operations, which have clearly been 
thought through (that is evident from NA == FALSE == FALSE). But R's 
behaviour looks to me like a choice among difficult alternatives, rather than 
the only possible choice. I'd give the OP some credit for that.

S Ellison


S Ellison







***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Rolf Turner


On 19/05/17 21:48, Ramnik Bansal wrote:


Hi,

I need to understand the inconsistent behaviour of & and I operators when
used with NA.

The code below explains this inconsistency


TRUE & NA

[1] NA


FALSE & NA

[1] FALSE


TRUE & NA

[1] NA


FALSE | NA

[1] NA


TRUE | NA

[1] TRUE


TRUE == NA

[1] NA


FALSE == NA

[1] NA


What inconsistency?  It all makes complete sense.  Think about it.

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.

Und so weiter.

As I said *think* about it; don't just go with your immediate knee-jerk 
(simplistic) reaction.


cheers,

Rolf Turner

--
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] Logical Operators' inconsistent Behavior

2017-05-19 Thread Thierry Onkelinx
& -> AND -> results only TRUE if both inputs are TRUE. Hence: FALSE AND
unknown = FALSE, TRUE AND unknown = unknown
| -> OR -> results in TRUE as soon as one of the inputs is TRUE. Hence FASE
or unknown = unknown, TRUE or unknown = TRUE
TRUE == NA and FALSE == NA compares TRUE/FALSE against unknown hence the
output is unknown.

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2017-05-19 11:48 GMT+02:00 Ramnik Bansal :

> Hi,
>
> I need to understand the inconsistent behaviour of & and I operators when
> used with NA.
>
> The code below explains this inconsistency
>
> > TRUE & NA
> [1] NA
>
> > FALSE & NA
> [1] FALSE
>
> > TRUE & NA
> [1] NA
>
> > FALSE | NA
> [1] NA
>
> > TRUE | NA
> [1] TRUE
>
> > TRUE == NA
> [1] NA
>
> > FALSE == NA
> [1] NA
>
> [[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.


[R] Logical Operators' inconsistent Behavior

2017-05-19 Thread Ramnik Bansal
Hi,

I need to understand the inconsistent behaviour of & and I operators when
used with NA.

The code below explains this inconsistency

> TRUE & NA
[1] NA

> FALSE & NA
[1] FALSE

> TRUE & NA
[1] NA

> FALSE | NA
[1] NA

> TRUE | NA
[1] TRUE

> TRUE == NA
[1] NA

> FALSE == NA
[1] NA

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