I am trying to add an empty row before every specific value (intercept):
(I put three linear regression model summaries into a dataframe, I want to use NA to make the dataframe looks better)
For example, my dataframe is like this.
var coefficient p_Value
(intercept) -17,22 0.2
speed 3.82 0.001
(intercept) -172,23 0.02
youtube 13.42 0.001
facebook 5.44 0.5
(intercept) 3.22 0.02
youtube 4.98 0.001
facebook 4.33 0.5
newspaper 1.22 0.11
I want result like this:
var coefficient p_Value
(intercept) -17,22 0.2
speed 3.82 0.001
NA NA NA
(intercept) -172,23 0.02
youtube 13.42 0.001
facebook 5.44 0.5
NA NA NA
(intercept) 3.22 0.02
youtube 4.98 0.001
facebook 4.33 0.5
newspaper 1.22 0.11
I know I could hard code empty rows based on the row locations, but I am looking for a better way. Instead of hard coding, I might have a much more complex and more extended data frame in the future. I do not want to split it into different list or separate dataframe, because eventually I will write this dataframe to csv, so that with NA I could easily see different models by only read csv.
Thank you for your time.