How to use custom column names (using “by”) Data.Table without using “: =”?

I know I can do this

a <- dt[,sum(x), by=y ]

I can do this too

dt[,z:=sum(x), by=y] # this would modify dt

But I don’t know why I can’t do this:

a <- dt[,z=sum(x), by=y]

< p>How to perform "summarization" with custom column names?

Is this the only option?

a <- copy(dt)
a[,z:=sum(x), by=y]

You are looking for the list() in the j parameter:

a < -dt[,list(z=sum(x)), by=y]

I know I can do this

a <- dt[,sum(x), by=y]

I can do this too

dt [,z:=sum(x), by=y] # this would modify dt

But I don’t know why I can’t do this:

 a <- dt[,z=sum(x), by=y]

How to perform "summarization" using custom column names?

Is this the only option?

a <- copy(dt)
a[,z:=sum(x), by=y]

You are looking for the list() in the j parameter:

a <- dt[,list(z=sum(x) ), by=y]

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2353 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.