I have the following code to create a dataframe:
df <- data.frame(
label = c(lower = model$"0.025quant"[[1]],
mean = model$mean[[1]],
upper = model$"0.975quant"[[1]]),
cyl = c("East", "East", "East"),
x = c(4.5, 4.5, 4.5),
y = c(0.075, 4, 4.5)
)
The problem is only in the “label” part of df. The values of model$"0.025quant"[1] which are extracted and put into the “label” column are decimals, like 0.0005334041. First, I want them to be rounded to three decimal places in df, like 0.001. Second, I want the values under “label” column to look like the following “lower=0.001”, “mean=0.005”, “upper=0.020”. Something like that:
But only with the rest of the columns “cyl”, “x” and “y”.
In other words, first, the values need to be extracted from the list “model”, then put in a rounded form into df, and finally look like the labels ““lower=0.001”, etc.
Guys, do you think this is something feasible to do in R? Could you suggest how my code should be modified so as to produce the desired dataframe?