Joseph Noirre
Joseph Noirre

Reputation: 387

dplyr mutate throws "Error: invalid subscript type 'closure'" error

I'm trying to use the sentiment_by in sentimentR with dplyr's mutate

This for example works: content <- mutate(content, word_count = sentiment_by(story)$word_count)

but

This for example works: content.sd <- mutate(content, word_count = sentiment_by(story)$sd)

gives the error Error: invalid subscript type 'closure'

but sentiment_by(content$story[1]) works

Any help would be greatly appreciated.

Upvotes: 2

Views: 3136

Answers (1)

Joseph Noirre
Joseph Noirre

Reputation: 387

You can use the following instead

content <- mutate(content, stdev = sentiment_by(story)[["sd"]])

Upvotes: 3

Related Questions