简体   繁体   中英

reshape long format to wide format by ""COUNT".. How can I make it?

I'm a R beginner

I have a dataframe as following below

在此处输入图片说明

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

在此处输入图片说明

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?

我们可以用

as.data.frame.matrix(table(incomegr=edu.q$incomegr,edu.q$langgr))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM