Hi all!
The following code (executed in console)...
somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 =
16:20);
somevar %>% gather(key = var, value = val, which(names(somevar) ==
"somestring"):length(somevar)) %>% head(2);
throws...
Error in which(names(somevar) == "somestring") :
could not find function "which"
if I change which(names(somevar) == "somestring") with 0 I'll get
Error in length(somevar) :
could not find function "length"
So it looks like base package is not loaded. Still if type 'which' in
console I get
function (x, arr.ind = FALSE, useNames = TRUE)
{
wh <- .Internal(which(x))
if (arr.ind && !is.null(d <- dim(x)))
arrayInd(wh, d, dimnames(x), useNames = useNames)
else wh
}
<bytecode: 0x0000000006c6e258>
<environment: namespace:base>
base (that contains which function) package is installed. R version is 3.4.1 and
system is Win8
Where should I look to understand how to fix the problem?
Thank you in advance!
Eugeny
[[alternative HTML version deleted]]
Inline. -- Bert On Thu, Aug 24, 2017 at 4:32 AM, Eugeny Melamud <Eugeny.Melamud at lanit-tercom.com> wrote:> Hi all! > > The following code (executed in console)... > somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 = 16:20); > somevar %>% gather(key = var, value = val, which(names(somevar) == "somestring"):length(somevar)) %>% head(2); > throws... > Error in which(names(somevar) == "somestring") : > could not find function "which" > > if I change which(names(somevar) == "somestring") with 0 I'll get > Error in length(somevar) : > could not find function "length" > > So it looks like base package is not loaded. Still if type 'which' in console I getNope. data.frame() is in the base package and ran just fine. Possibly check your usage of the "%>%" construction (which I don't use and so can't help with). Cheers, Bert> function (x, arr.ind = FALSE, useNames = TRUE) > { > wh <- .Internal(which(x)) > if (arr.ind && !is.null(d <- dim(x))) > arrayInd(wh, d, dimnames(x), useNames = useNames) > else wh > } > <bytecode: 0x0000000006c6e258> > <environment: namespace:base> > > base (that contains which function) package is installed. R version is 3.4.1 and system is Win8 > > Where should I look to understand how to fix the problem? > > Thank you in advance! > Eugeny > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
Try putting !!! (three exclamation symbols) in front of which(...)==.... The non-standard evaluation in the tidyverse can cause confusion. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Aug 24, 2017 at 4:32 AM, Eugeny Melamud < Eugeny.Melamud at lanit-tercom.com> wrote:> Hi all! > > The following code (executed in console)... > somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 > 16:20); > somevar %>% gather(key = var, value = val, which(names(somevar) => "somestring"):length(somevar)) %>% head(2); > throws... > Error in which(names(somevar) == "somestring") : > could not find function "which" > > if I change which(names(somevar) == "somestring") with 0 I'll get > Error in length(somevar) : > could not find function "length" > > So it looks like base package is not loaded. Still if type 'which' in > console I get > function (x, arr.ind = FALSE, useNames = TRUE) > { > wh <- .Internal(which(x)) > if (arr.ind && !is.null(d <- dim(x))) > arrayInd(wh, d, dimnames(x), useNames = useNames) > else wh > } > <bytecode: 0x0000000006c6e258> > <environment: namespace:base> > > base (that contains which function) package is installed. R version is > 3.4.1 and system is Win8 > > Where should I look to understand how to fix the problem? > > Thank you in advance! > Eugeny > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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]]
Looks like a bug to me. I think you need to correspond with the package (tidyr?) maintainer, perhaps by putting a bug report on GitHub. Next time please make your example reproducible by including the necessary "library" function calls. -- Sent from my phone. Please excuse my brevity. On August 24, 2017 4:32:05 AM PDT, Eugeny Melamud <Eugeny.Melamud at lanit-tercom.com> wrote:>Hi all! > >The following code (executed in console)... >somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 >16:20); >somevar %>% gather(key = var, value = val, which(names(somevar) =>"somestring"):length(somevar)) %>% head(2); >throws... > Error in which(names(somevar) == "somestring") : > could not find function "which" > >if I change which(names(somevar) == "somestring") with 0 I'll get > Error in length(somevar) : > could not find function "length" > >So it looks like base package is not loaded. Still if type 'which' in >console I get > function (x, arr.ind = FALSE, useNames = TRUE) > { > wh <- .Internal(which(x)) > if (arr.ind && !is.null(d <- dim(x))) > arrayInd(wh, d, dimnames(x), useNames = useNames) > else wh > } > <bytecode: 0x0000000006c6e258> > <environment: namespace:base> > >base (that contains which function) package is installed. R version is >3.4.1 and system is Win8 > >Where should I look to understand how to fix the problem? > >Thank you in advance! >Eugeny > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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.
Or perhaps two exclamation points would be better ('unquote' in the
tidyverse lexicon, 3 bangs is 'unquote-splice').
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Aug 24, 2017 at 10:20 AM, William Dunlap <wdunlap at tibco.com>
wrote:
> Try putting !!! (three exclamation symbols) in front of which(...)==....
>
> The non-standard evaluation in the tidyverse can cause confusion.
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Thu, Aug 24, 2017 at 4:32 AM, Eugeny Melamud <
> Eugeny.Melamud at lanit-tercom.com> wrote:
>
>> Hi all!
>>
>> The following code (executed in console)...
>> somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15,
v4 >> 16:20);
>> somevar %>% gather(key = var, value = val, which(names(somevar)
=>> "somestring"):length(somevar)) %>% head(2);
>> throws...
>> Error in which(names(somevar) == "somestring") :
>> could not find function "which"
>>
>> if I change which(names(somevar) == "somestring") with 0
I'll get
>> Error in length(somevar) :
>> could not find function "length"
>>
>> So it looks like base package is not loaded. Still if type
'which' in
>> console I get
>> function (x, arr.ind = FALSE, useNames = TRUE)
>> {
>> wh <- .Internal(which(x))
>> if (arr.ind && !is.null(d <- dim(x)))
>> arrayInd(wh, d, dimnames(x), useNames = useNames)
>> else wh
>> }
>> <bytecode: 0x0000000006c6e258>
>> <environment: namespace:base>
>>
>> base (that contains which function) package is installed. R version is
>> 3.4.1 and system is Win8
>>
>> Where should I look to understand how to fix the problem?
>>
>> Thank you in advance!
>> Eugeny
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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]]
This was a change in tidyr 0.7.0 that is causing a lot of confusion, so we are preparing tidyr 0.7.1 which will back this change out. If you want a work around in the meantime, you can express your operation a bit more elegantly as: library(tidyr) df <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 = 16:20) df %>% gather(key = var, value = val, somestring:ncol(df)) %>% head(2) Hadley On Thu, Aug 24, 2017 at 6:32 AM, Eugeny Melamud <Eugeny.Melamud at lanit-tercom.com> wrote:> Hi all! > > The following code (executed in console)... > somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 = 16:20); > somevar %>% gather(key = var, value = val, which(names(somevar) == "somestring"):length(somevar)) %>% head(2); > throws... > Error in which(names(somevar) == "somestring") : > could not find function "which" > > if I change which(names(somevar) == "somestring") with 0 I'll get > Error in length(somevar) : > could not find function "length" > > So it looks like base package is not loaded. Still if type 'which' in console I get > function (x, arr.ind = FALSE, useNames = TRUE) > { > wh <- .Internal(which(x)) > if (arr.ind && !is.null(d <- dim(x))) > arrayInd(wh, d, dimnames(x), useNames = useNames) > else wh > } > <bytecode: 0x0000000006c6e258> > <environment: namespace:base> > > base (that contains which function) package is installed. R version is 3.4.1 and system is Win8 > > Where should I look to understand how to fix the problem? > > Thank you in advance! > Eugeny > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.-- http://hadley.nz