Reputation: 828
I'm getting some issues plotting from a simple data.frame using ggplot. I know that the plot call should work as I have a similar small data.frame that works perfectly.
Plotting leads to the following error:
Don't know how to automatically pick scale for object of type list.
Defaulting to continuous.
Error: geom_errorbar requires the following missing aesthetics: ymin, ymax
I have looked at the structure and there are difference but I'm not able to fix them (i'm guessing something needs to be done to flatten the df?). The second data.frame works fine but the first doesn't.
Why is this happening, and how can I fix it please?
> str(df3.temp.swim)
'data.frame': 3 obs. of 4 variables:
$ treatment: chr "both" "hyp" "nor"
$ R :List of 3
..$ : num 0.435
..$ : num 0.403
..$ : num 0.65
$ CI.lower :List of 3
..$ : num 0.283
..$ : num 0.169
..$ : num 0.475
$ CI.upper :List of 3
..$ : num 0.578
..$ : num 0.614
..$ : num 0.781
>
>
>
> str(df3.temp.vuln)
'data.frame': 3 obs. of 4 variables:
$ treatment: chr "both" "hyp" "nor"
$ R : num 0.1634 0.0447 0.985
$ CI.lower : num 0.0397 0 0.9683
$ CI.upper : num 0.234 0.137 0.993
Upvotes: 0
Views: 131
Reputation: 31
The problem seems to be that 3 of the members of the list df3.temp.swim
are themselves of class list
.
Therefore,
df3.temp.swim <- sapply(df3.temp.swim, unlist)
should work as well.
Upvotes: 1
Reputation: 828
Managed to work it out. I'll post just in case someone else is struggling with this.
What you need to do is to use the 'unnest()' function from tidyr. This worked:
unnest(df)
Cheers
Upvotes: 0