[datatable-help] Error in eval(expr, envir, enclos) : object 'BlaBla' not found

Frank Erickson FErickson at psu.edu
Thu Aug 29 17:04:10 CEST 2013


Hi Kostia,

I think that you already have a column named "percent" that has type
"character". When you use "format", the result is a character, for
example...

If so -- use str(data) to check -- you'll need to delete it first, using
data[,percent:=NULL].

If you're confused about how data.tables work and what they are useful for
(...which I think might be the case based on your conversion to a
data.frame and use of format), you might want to go through the vignettes
and other resources here: http://datatable.r-forge.r-project.org/

Best,

Frank


On Thu, Aug 29, 2013 at 9:57 AM, Kostia Kofman <kofmank at gmail.com> wrote:

> This is the error I receive trying "BlaBla" instead of list(BlaBla)
>
>
> Error in `[.data.table`(data, , `:=`(percent, sum(freq)), by = byWhat) :
>   Type of RHS ('integer') must match LHS ('character'). To check and coerce would impact performance too much for the fastest cases. Either change the type of the target column, or coerce the RHS of := yourself (e.g. by using 1L instead of 1)
>
>
>
> On Thu, Aug 29, 2013 at 5:44 PM, Frank Erickson <FErickson at psu.edu> wrote:
>
>> Try "BlaBla" instead of list(BlaBla)
>>
>> (oops, forgot to reply to the mailing list the first time I sent this.
>> Sorry for the double email, Kostia.)
>>
>>
>> On Thu, Aug 29, 2013 at 9:36 AM, Kostia Kofman <kofmank at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm new to R and data.table and having some difficulties with a certain
>>> function that I wrote.
>>>
>>> the function code:
>>>
>>> freq_per = function(data,byWhat,month){
>>>     for (i in 1:length(month)){
>>>         data = data.table(data)
>>>         data[,percent :=sum(freq),by = byWhat]
>>>         data[,percent := (freq/percent)*100]
>>>         data = data.frame(data)
>>>         data$percent = format(round(data$percent),nsmall = 2)
>>>     }
>>>     data
>>>
>>> }
>>>
>>> I have tried to call the function with freq_per(data,list(BlaBla),month)
>>> and get the error message from the topic.
>>>
>>> I have tried to create a global variable with byWhat = list(BlaBla), it
>>> didn't work because the object 'BlaBla' not found.
>>>
>>> I also tried to use keyby instead of by with  c(colnames(data)[1]), but
>>> the results that I got are not right.
>>>
>>> anybody has an idea how to overcome the problem?
>>>
>>> Thanks.
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130829/838d57e7/attachment-0001.html>


More information about the datatable-help mailing list