[R] Disabling Auto-complete
Allan Engelhardt (CYBAEA)
allane at cybaea.com
Mon Sep 26 11:41:34 CEST 2011
The $ operator does partial matching by default so for example
> print(b$u)
[1] 1
The [[ operator does not
> print(b[["unit"]])
NULL
> print(b[["unit1"]])
[1] 1
See help("$") for more details and also the warnPartialMatch* arguments
in help("options").
Try
testfunction <- function(x) if (exists("unit", x) && x[["unit"]]==1)
cat("All is well\n")
Hope this helps
Allan
On 26/09/11 10:23, Vikram Bahure wrote:
> Hi,
>
> I am a new user to R.
>
> I am having the following problem while using R:
> The defined function is having following a$unit as input but if I define
> a$unit1 then still I am getting the output which is not desired.
> __________________________
> *Function:*
> testfunction<-function(a){
> stopifnot(a$unit==1)
> cat("All is well")
> }
> b<-list(unit1=1 )
> testfunction(b)
> ---------------------------------------------
> *Output:*
>> testfunction<-function(a){
> stopifnot(a$unit==1)
> cat("All is well")
> }
> b<-list(unit1=1 )
> testfunction(b)
> testfunction<-function(a){
> + stopifnot(a$unit==1)
> + cat("All is well")
> + }
>> b<-list(unit1=1 )
>> testfunction(b)
> All is well>
> __________________________
>
> If it is a auto complete problem, it would be nice if you could let me know
> how to disable it, else you could throw some light on the what the problem
> is exactly.
>
> Regards
> Vikram
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list