Error in is.data.frame(x) : 'list' object cannot be coerced to type 'double'

hi,

how to fix following error, I have uploaded data (excel file) in cloud,

Error in is.data.frame(x) :
'list' object cannot be coerced to type 'double'
In addition: Warning messages:
1: In (function () : Only one RStudio graphics device is permitted
2: In mean.default(Yi11) :
argument is not numeric or logical: returning NA
3: In mean.default(Yi21) :
argument is not numeric or logical: returning NA
4: In mean.default(Yi12) :
argument is not numeric or logical: returning NA
5: In mean.default(Yi22) :
argument is not numeric or logical: returning NA

Hi, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

Dear andresrcs,
Thank for guidance, below is the reprex output. Note that I have uploaded PK data in cloud.

library(BE)
#> Loading required package: rtf
be2x2(PK,Columns=c("AUClast", "Cmax", "Tmax"))
#> Error in "data.frame" %in% class(Data): object 'PK' not found

Created on 2022-11-26 with reprex v2.0.2

But I have no idea what the cloud or if I may have access to .

It is better to supply some sample data here. A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(PK , 100)) should supply the data we need. Just copy and paste the output here

Dear jrkrideau,
I am using Posit Cloud and uploaded excel file (PK) in to Posit cloud.
Output of dput(PK) data are as given below,
dput(PK)
structure(list(SUBJ = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7,
7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15,
16, 16), GRP = c("RT", "RT", "TR", "TR", "RT", "RT", "TR", "TR",
"TR", "TR", "RT", "RT", "TR", "TR", "RT", "RT", "RT", "RT", "TR",
"TR", "RT", "RT", "TR", "TR", "TR", "TR", "RT", "RT", "RT", "RT",
"TR", "TR"), TRT = c("R", "T", "R", "T", "R", "T", "R", "T",
"R", "T", "R", "T", "R", "T", "R", "T", "R", "T", "R", "T", "R",
"T", "R", "T", "R", "T", "R", "T", "R", "T", "R", "T"), PRD = c(1,
2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2,
2, 1, 2, 1, 1, 2, 1, 2, 2, 1), Tmax = c(2.75, 1, 2, 2, 2.5, 1.75,
1, 1.5, 4, 4, 2.5, 1.25, 2.75, 2, 3.5, 1.5, 4, 2.75, 2.5, 1.5,
2, 1.5, 2.75, 2.75, 1.75, 3, 3, 1.75, 2.75, 2.5, 2.75, 2.75),
Cmax = c(2673.125, 2520.408, 4668.821, 3778.97, 4175.048,
3373.79, 822.973, 1367.424, 2677.174, 1582.741, 3331.205,
2207.168, 2691.059, 1377.758, 1757.573, 1530.071, 2899.56,
2846.365, 2704.127, 2205.365, 2817.364, 3315.127, 4563.51,
3896.76, 3202.77, 2317.181, 2005.194, 2400.555, 3769.855,
3652.5, 3544.573, 3497.54), AUClast = c(17272.208125, 12678.48675,
23885.931, 18334.148625, 17178.58525, 15860.488, 2194.57025,
5388.654, 19267.699125, 11494.539625, 24041.2175, 18926.747125,
17465.043375, 10221.3745, 14569.908875, 10284.832875, 18918.59875,
16175.322125, 19105.02725, 17631.031375, 21082.636875, 24391.54975,
19194.505375, 19323.102125, 20873.78375, 13931.143125, 13330.9295,
14374.033375, 21283.004375, 22096.778875, 22903.332625, 19843.245875
), AUCinf = c(17326.320000199, 12722.6295797388, 24063.8281009675,
18388.583463318, 17197.6429222744, 15889.9464433894, 2238.65419665474,
5504.23527601736, 19484.9353565792, 11563.1493108054, 24271.4880980023,
19153.4163363009, 17657.7933460095, 10337.668252529, 14756.5554993777,
10476.4235677571, 19056.5485154194, 16352.3323036496, 19185.6031773575,
17653.8430367784, 21256.582662224, 24939.8105410683, 19253.570721027,
19381.4472403048, 21117.0181443779, 14050.7255327278, 13357.0560663814,
14396.4317003585, 21343.1426628951, 22163.1733648032, 22950.4177537099,
19878.9463679562)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -32L))

library(BE)
#> Loading required package: rtf
be2x2(as.data.frame(PK),Columns=c("AUClast", "Cmax", "Tmax"))

This should work given your example PK; the issue was that your PK is a tibble; which has slightly different element unpacking behaviour than a plain data.frame and it seems be2x2 wasn't designed to account for that.

To understand the difference consider the following:


library(tidyverse)
a1 <- data.frame(a=1)
b2 <- tibble(b=2)


a1[["a"]]
b2[["b"]]

using [[ ]] to unpack from the frame or tibble leads to the same , a simple vector result
whereas

a1["a"]
b2["b"]

using single square bracket to get a column from a frame, but 'wrapped' results in the plain data.frame returning a named vector, and the tibble returning a tibble. bex2x didnt know what to do with the tibble result it saw, (failed to cast it to a numeric)

1 Like

Thanks for your suggestion, now its working fine

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.