I have following dataset:
Artist Song.Rank Song.Title Word WordCount SentimentScore.text SentimentScore.sentiment
1 Placeholder 60 More Placeholders alright 40 alright Neutral
2 Placeholder 60 More Placeholders bad 79 bad Negative
3 Placeholder 60 More Placeholders bad 192 bad Negative
4 Placeholder 60 More Placeholders better 125 better Positive
5 Placeholder 60 More Placeholders brand 24 brand Neutral
6 Placeholder 60 More Placeholders break 106 break Negative
7 Placeholder 60 More Placeholders cause 18 cause Neutral
8 Placeholder 60 More Placeholders come 59 come Neutral
This dataset exists of data from an xlsx file. Only the last column Sentiment
is something I added myself by using the RSentiment
package.
When trying to insert it into a csv, I get the following message:
> write.csv(dataset,"calculated.csv")
Error in if (inherits(X[[j]], "data.frame") && ncol(xj) > 1L) X[[j]] <- as.matrix(X[[j]]) :
missing value where TRUE/FALSE needed
After a bit of research, I found out that this happens because my dataset contains a nested dataframe, but the suggested solutions Like This didn't help. (in this case, I got a invalid subscript type 'closure'
error.)
EDIT: I saw a lot of posts where this was asked:
> str(dataset)
'data.frame': 28 obs. of 6 variables:
$ Artist : chr "Placeholder" "Placeholder" "Placeholder" "Placeholder" ...
$ Song.Rank : num 60 60 60 60 60 60 60 60 60 60 ...
$ Song.Title : chr "More Placeholder" "More Placeholder" "More Placeholder" "More Placeholder" ...
$ Word : chr "alright" "bad" "bad" "better" ...
$ WordCount : num 40 79 192 125 24 106 18 59 138 146 ...
$ SentimentScore:'data.frame': 28 obs. of 2 variables:
..$ text : Factor w/ 23 levels "alright","bad",..: 1 2 2 3 4 5 6 7 8 9 ...
..$ sentiment: Factor w/ 3 levels "Negative","Neutral",..: 2 1 1 3 2 1 2 2 2 2 ...