I'm definitely a noob, though I have used R for various small tasks for several years.
For the life of me, I cannot figure out how to get the results from the "Desc" function into something I can work with. When I save the x<-Desc(mydata) the class(x) shows up as "Desc." In R studio it is under Values and says "List of 1." Then when I click on x it says ":List of 25" in the first line. There is a list of data in this object, but I cannot for the life of me figure out how to grab any of it.
Clearly I have a severe misunderstanding of the R data structures, but I have been searching for the past 90 minutes to no avail so figured I would reach out.
In short, I just want to pull certain aspects (N, mean, UB, LB, median) of the descriptive statistics provided from the Desc results for multiple datasets and build a little table that I can then work with.
Thanks for the help.
Say you have a dataframe,
x
, where:You could set:
And access the info on any given column like:
And any other stats Desc comes up with. The
$
is the key here, it's how you access the named fields of thelist
that Desc returns.Edit: In case you pass a single column (as the asker does), or simply a vector to
Desc
, you are then returned a 1 item list. The same principle applies but the usual syntax is different. Now you would use:In the future, the way to attack this is to either look in the environment window in RStudio and play around trying to figure out how to access the fields, check the source code on github or elsewhere, or (best first choice) use
str(desc.x)
, which gives us:"List of 1" means you access it by
desc.x[[1]]
, and below that follow the$
s. When you see something likenum[1:3]
that means it's an atomic vector so you access the first member likevar$field$numbers[1]