[datatable-help] Strange key behaviour with character string (involving spaces)
Matthew Dowle
mdowle at mdowle.plus.com
Fri Aug 19 17:49:07 CEST 2011
Hi,
The paste added another space, so there are two spaces ;)
> test["a 1"]
Var1 Var2
[1,] a 1 1
[2,] a 1 2
[3,] a 1 3
[4,] a 1 4
[5,] a 1 5
[6,] a 1 6
[7,] a 1 7
[8,] a 1 8
[9,] a 1 9
[10,] a 1 10
>
> Hi,
>
> I noticed some unexpected behaviour:
>
>
>> key(test) <- "Var1"
>> test["a 1"]
> Var1 Var2
> [1,] a 1 NA
>> test <- data.table(expand.grid(c(paste("a ", 1:10), "b"),1:10))
>> key(test) <- "Var1"
>> test["b"]
> Var1 Var2
> [1,] b 1
> [2,] b 2
> [3,] b 3
> [4,] b 4
> [5,] b 5
> [6,] b 6
> [7,] b 7
> [8,] b 8
> [9,] b 9
> [10,] b 10
>> test["a 1"]
> Var1 Var2
> [1,] a 1 NA
>>
>
>
> That is, subsetting a keyed data.table by a string that contains a
> space seems to break it? Am I missing something?
>
> Timothee
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
More information about the datatable-help
mailing list