Reputation: 465
I try to group by my customize movieLense dataset
groupBy<- data.table(unifiedTbl)
x<- groupBy[,list(rating=sum(rating)
,Unknown=sum(unknown)
,Action=sum(Action)
,Adventure = sum(Adventure)
,Animation = sum(Animation)
,"Children's" = sum(Children's)
),by=list(user_id,age,occupation)]
but because of Children's I received some error which related to specified character If I remove below part of my code every things is OK
,"Children's" = sum(Children's)
Now my question is how can I address to this column with full name? how can I fix my codes?
Upvotes: 1
Views: 1200
Reputation: 132706
You can use backticks with names that aren't valid syntax:
`Children's` = sum(`Children's`)
And of course, I'd recommend creating valid names instead:
setnames(groupBy, make.names(names(groupBy)))
Upvotes: 5