I want to change a data frame to a custom json format at the end. The labels are created from the Date and Pressure column, with name being the value and column name being the group name and need.
Below is a way to generate the data frame being used to replicate this question
df<-setNames(
data.frame(
t(data.frame(c("",1,2,0,20,"2b9c5fb7-72a4-4482-baa1-34cc37522d24","Yes","210521"),c("",2,3,20,40,"7f615aea-330f-4c67-8101-0ae501c793cd","No","210522")))
,row.names = NULL,stringsAsFactors = FALSE
),
c("notes","instanceNum","modifyCount","startTime","endTime","uniqueId","Pressure","Date")
)
Here is is the custom json format required. Any guidance appreciated
{
"labels": [
{
"name": "Yes",
"group": "Pressure"
},
{
"name": "210521",
"group": "Date"
}
],
"notes": "",
"instanceNum": 1,
"modifyCount": 2,
"startTime": 0,
"endTime": 20,
"uniqueId": "2b9c5fb7-72a4-4482-baa1-34cc37522d24"
},
{
"labels": [
{
"name": "No",
"group": "Pressure"
},
{
"name": "210522",
"group": "Date"
}
],
"notes": "",
"instanceNum": 2,
"modifyCount": 3,
"startTime": 20,
"endTime": 40,
"uniqueId": "7f615aea-330f-4c67-8101-0ae501c793cd"
}