-3

I'm a R beginner

I have a dataframe as following below

enter image description here

I want reshape dataframe above like this .. by "Dataframe format"

enter image description here

I know i can make it by 'table function' table(incomegr=edu.q$incomegr,edu.q$langgr) but this format is 'table' not 'dataframe'

ie, i want make each 'incomegr', 'Gr9', 'Gr8' as dataframe columns.

How can I make it?

s.alem
  • 12,579
  • 9
  • 44
  • 72
SUNGWOO
  • 1
  • 3

1 Answers1

0

We can use

as.data.frame.matrix(table(incomegr=edu.q$incomegr,edu.q$langgr))
akrun
  • 874,273
  • 37
  • 540
  • 662