I have a data set (that has been imported from a .json file) that currently looks like this:
ID <- c(1)
Name <- c("John")
Name.1 <- c("Irene")
Address <- c("1 Brick Lane")
Address.1 <- c("2 Wood Street")
df <- data.frame(ID, Name, Name.1, Address, Address.1)
ID | Name | Address | Name.1 | Address.1
------ | ------| ------ | ------ | ------
1 | John | 1 Brick Lane | Irene | 2 Wood Street
However, I would like to manipulate it to look like this:
ID <- c(1)
Name <- c("John", "Irene")
Address <- c("1 Brick Lane", "2 Wood Street")
df <- data.frame(ID, Name, Address)
ID | Name | Address
------ | ------| ------
1 | John | 1 Brick Lane
1 | Irene | 2 Wood Street
Also, not all people have the same information fields. For example, John's date of birth might be in the data but Irene's is not.
In my real data set there would be about 30 different columns in the final data frame. Your help would be greatly appreciated!