-4

I need to use this data.frame to analyse data Investment using package lattice.

Requirement is to use data.frame. Instead of the variable Investment I need to put variables which have influence to the Investment. I need to draw different graphs. I tried to draw one, but it's not what I need, because my code doesn't use data.frame at all.

library(lattice)
xyplot(Investment~GNP,data=Investment)
is.data.frame(Investment)

How can I change my code according to requirments? Thank you in advance.

enter image description here

Community
  • 1
  • 1
LuckyProgrammer
  • 79
  • 1
  • 1
  • 8
  • 3
    Sorry, I dont understand - what is the problem? – user20650 Oct 28 '17 at 13:08
  • 3
    You use `as.data.frame`, so I think you meet the "use data frame" requirement. But maybe you should talk to a professor or TA instead about your course requirements - I'm just a person on the internet. – Gregor Thomas Oct 28 '17 at 13:12

1 Answers1

1
data(Investment, package="sandwich")
Investment <- as.data.frame(Investment)

Here you have converted your data into data frame (as.data.frame) if you wnat to access different columns in data frame you can select by using operator $ example:

Investment$column_name

plotting can be done by using plot function in which also you can select variables by using $ operator like

plot(Investment$column1,Investment$column2)

as.data.frame converts other formats of data into data frame data.frame itself intializes a data frame

For creating new data frame you can use data.frame()

Hope it helps

RAVI TEJA M
  • 151
  • 4