<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Try "BlaBla" instead of list(BlaBla)</span><br><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">(oops, forgot to reply to the mailing list the first time I sent this. Sorry for the double email, Kostia.)</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 29, 2013 at 9:36 AM, Kostia Kofman <span dir="ltr"><<a href="mailto:kofmank@gmail.com" target="_blank">kofmank@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>I'm new to R and data.table and having some difficulties with a certain function that I wrote.<br>
</div><br></div>the function code:<br><br>freq_per = function(data,byWhat,month){<br>
for (i in 1:length(month)){<br> data = data.table(data)<br> data[,percent :=sum(freq),by = byWhat]<br> data[,percent := (freq/percent)*100]<br> data = data.frame(data)<br> data$percent = format(round(data$percent),nsmall = 2)<br>
}<br> data<br> <br>}<br><br></div>I have tried to call the function with freq_per(data,list(BlaBla),month) and get the error message from the topic.<br><br>I have tried to create a global variable with byWhat = list(BlaBla), it didn't work because the object 'BlaBla' not found.<br>
<br></div>I also tried to use keyby instead of by with c(colnames(data)[1]), but the results that I got are not right.<br><br></div>anybody has an idea how to overcome the problem?<br><br></div>Thanks.<br><div><div><div>
<div><div><div><div><br><br></div></div></div></div></div></div></div></div>
<br>_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br></blockquote></div><br></div>