0

This is my ggplot function and the resultant error

plot1 = ggplot(data= RiskReturn, aes(x = cov_matrix, y = averagereturn))
plot1 = plot1 + geom_point()
plot1 = plot1 + xlab("Risk/Variance") + 
 ylab("Daily Returns") + 
 ggtitle("Risk Return Relationship")

plot1

Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous. Error: Column x must be a 1d atomic vector or a list

My output for RiskReturn, cov_matrix and averagereturn is shown below

RiskReturn
                   1        SASINI            KQ           NMG           BBK
SASINI  4.979369e-04  8.456428e-04  5.445880e-05  1.239006e-04  9.332421e-06
KQ     -8.128663e-04  5.445880e-05  2.401885e-03 -6.811349e-04  1.821386e-05
NMG    -1.833540e-04  1.239006e-04 -6.811349e-04  4.767065e-03  3.323995e-05
BBK    -7.500765e-06  9.332421e-06  1.821386e-05  3.323995e-05  2.224748e-04
CFC     4.311257e-04  1.538035e-05 -4.279245e-07  3.245089e-05  2.275598e-05


cov_matrix
              SASINI            KQ           NMG           BBK           CFC
SASINI  8.456428e-04  5.445880e-05  1.239006e-04  9.332421e-06  1.538035e-05
KQ      5.445880e-05  2.401885e-03 -6.811349e-04  1.821386e-05 -4.279245e-07
NMG     1.239006e-04 -6.811349e-04  4.767065e-03  3.323995e-05  3.245089e-05
BBK     9.332421e-06  1.821386e-05  3.323995e-05  2.224748e-04  2.275598e-05
CFC     1.538035e-05 -4.279245e-07  3.245089e-05  2.275598e-05  5.273949e-04

averagereturn
       SASINI            KQ           NMG           BBK           CFC 
 4.979369e-04 -8.128663e-04 -1.833540e-04 -7.500765e-06  4.311257e-04 
markus
  • 25,843
  • 5
  • 39
  • 58
Simba01
  • 1
  • 1
  • 4
    `x` and `y` should be column names, i.e. vectors of your `data` argument, not dataframes . What do you want to display? – markus Oct 23 '18 at 08:29
  • What kind of plot Simba01? – TheRimalaya Oct 23 '18 at 09:59
  • Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Oct 23 '18 at 11:36

0 Answers0