Thanks you Petr. This worked. Regards, Shivi
Sent from Yahoo Mail for iPhone On Monday, August 27, 2018, 14:31, PIKAL Petr <petr.pi...@precheza.cz> wrote: Hi the output seems to me rather weird. Unles you have NaNs in input data frame you should not get NaN as a result. Anyway, your aggregate will give you NA or NaN even when there is only one NA or NaN in your input data frame. So I suggest to use sentiments_per_Category <- aggregate(relative_sentiment_frequencies, by = list(Category = df$Case.Category), mean, na.rm=TRUE) This should strip all NAs before calculating mean in each category. Complete cases removes all lines with at least one NA in your data frame, which probably results to empty data frame. Cheers Petr > -----Original Message----- > From: R-help <r-help-boun...@r-project.org> On Behalf Of Shivi Bhatia > Sent: Saturday, August 25, 2018 4:01 PM > To: R-help <r-help@r-project.org> > Subject: [R] NaN in Scoring Sentiment > > Hi All- I am running a sentiment scoring model and the code is as below: > sentiments_per_Category <- aggregate(relative_sentiment_frequencies, > by = list(Category = df$Case.Category), >mean) > > while i run the head command most of the values are NaN. i then used > complete.cases on my data frame df[complete.cases(df),] but it does not seems > to work. Please advice if there is a way to handle NaN. > > Regards, Shivi > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/ Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.