I have a dataframe as follows:
##DUMMY DATAFRAME
text = c("This is neutral")
Col2 = 0
Col3 = 0
Col4 = 0
Col5 = 0
Col6 = 0
Col7 = 0
Col8 = 0
Col9 = 0
Col10 = 0
Col11 = 0
Col12 = 0
Col13 = 0
Col14 = 0
Col15 = 0
Col16 = 0
df = data.frame(text, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11, Col12, Col13, Col14, Col15, Col16)
df
text Col2 Col3 Col4 Col5 Col6 Col7 Col8 Col9 Col10 Col11 Col12 Col13 Col14 Col15 Col16
1 This is neutral 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I want to check the length of a list and if the length = 0, return the dataframe above, if not return a different dataframe. What happens is that it only takes the first element, not the entire dataframe.
new_df <- ifelse(length(example_of_empty_list) == 0, df, different_df)
This output will only give me
[[1]]
[1] This is neutral
Levels: This is neutral
I want my output to rather be then entire dataframe rather than the first element.
How would I go about doing this?