Convert R object to a data frame
"Sorkin, John" <[email protected]> Thu, 4 Jun 2026 20:57:01 +0000
| Newsgroups | gmane.comp.lang.r.general |
|---|---|
| Message-ID | <DM6PR03MB50495796B4548FCBFF20686FE2102@DM6PR03MB5049.namprd03.prod.outlook.com> |
I have an R object created lapply function within a by a by function =
results_by_date <- by(
data,
data[,"Date"],
function(subdata) {
lapply(
alertlevels,
check_cutpoints2,
data=3Dsubdata,
mycolumn=3Dcolumn
)
}
)
which has the following structure
$ 2020-08-14:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 0
$ 2020-08-15:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 1
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 0
$ 2020-08-16:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 15
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 6
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 6
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 6
$ 2020-08-17:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 58
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 20
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 7
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 2
$ 2020-08-18:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 79
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 45
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 16
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 6
$ 2020-08-19:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 187
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 100
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 61
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 38
$ 2020-08-20:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 121
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 31
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 13
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 4
$ 2020-08-21:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 17
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 8
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 5
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 3
$ 2020-08-22:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 35
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 12
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 6
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 2
$ 2020-08-23:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 32
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 15
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 8
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 4
$ 2020-08-24:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 15
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 5
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 1
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 0
$ 2020-08-25:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 43
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 26
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 13
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 5
$ 2020-08-26:List of 4
..$ :List of 2
.. ..$ criticalvalue : num 0.1
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.2
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.3
.. ..$ NumPeopleExposed: int 0
..$ :List of 2
.. ..$ criticalvalue : num 0.4
.. ..$ NumPeopleExposed: int 0
- attr(*, "dim")=3D int 13
- attr(*, "dimnames")=3DList of 1
..$ data[, "Date"]: chr [1:13] "2020-08-14" "2020-08-15" "2020-08-16" "20=
20-08-17" ...
- attr(*, "call")=3D language by.data.frame(data =3D data, INDICES =3D dat=
a[, "Date"], FUN =3D function(subdata) { lapply(alertlevels, check_cutp=
| __truncated__ ...
- attr(*, "class")=3D chr "by"
NULL
I would like to convert the object to a dataframe. Can anyone suggest how I=
might accomplish this task?
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical =
Center Geriatrics Research, Education, and Clinical Center;=A0
Former PI Biostatistics and Informatics Core,=A0University of Maryland Scho=
ol of Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;
Division of Gerontology, Geriatrics and Palliative Medicine,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382