In R, I have a data frame with several values. I would like to have a data frame that transforms the data frame into a data frame with just one row with all the values. I have a data frame like this:
df <- data.frame(A = c("time", "time", "time"),
B = c("place", "place", "place"),
C = c(NA, 1, NA),
D = c(NA, NA, 2),
E = c(3, NA, NA),
`F` = c(4,4, NA),
G = c(NA, 5, NA))
A B C D E F G
1 time place NA NA 3 4 NA
2 time place 1 NA NA 4 5
3 time place NA 2 NA NA NA
And I want a dataframe like this:
A B C D E F G
1 time place 1 2 3 4 5
I tried using the function reshape like here: Turning one row into multiple rows in r
And tried the function unique but than I lose a lot of data: Selecting unique rows in matrix using R