cbind/join complex dataframes of different lengths without identifier

Thank you so much in advance for any help--

I am trying to rbind/join two dataframes that do not have a unique identifier- the format is complex because of how they were webscraped.

df1 contains assay results, with 1 row for each assay occurring on a day, and a row (ID, Name, Concentration) separating out assays that happened on different days. df2 contains 1 row for the date of the assays. I need to bind the relevant assay date (df2) to each of the assay results (df1).

df1 = data.frame(matrix(0, 13, 3))
df1$X1 = c("ID","1","2","3","4","5","ID","1","2","3","ID","1","2")
df1$X2 = c("Name","Jose","Mary","Doug","Luisa","Pam","Name","Jose","Doug","Lou","Name","Luisa","Pam")
df1$X3 = c("Concentration","4.2","2.3","7.3","1.4","0.5","Concentration","0.1","2.3","2.1","Concentration","9.0","1.4")


df2 = data.frame(matrix(0, 3, 3))
names(df2) = c("X4", "X5", "X6")
df2$X4 = c("Monday", "Tuesday", "Friday")
df2$X5 = c("January", "February", "March")
df2$X6 = c("12", "4", "21") 
df2

In the end I want the dataframe to look like this: [desired outcome: (https://ift.tt/LqwnYOa)

So far I have tried to create an identifier for all assays that occurred on the same day (separated by the ID, Name, Concentration rows), but have not been successful because the number of assays per day varies greatly (in reality I have >200,000 assays from dozens of days).

Thanks for any help!



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation