[R] reshape and split

Patrick Hausmann c18g at zfn.uni-bremen.de
Fri Dec 17 11:47:58 CET 2004


Dear R-users,

I am trying to reshape the DF "dat2" in the "long" format,
but can't figure out how to use the "split"-option:

> dat2
   a.1995.z  b.1995.z  a.1996.z                    var
1 100.00000 100.00000 100.00000 Neue Anlagen insgesamt
2  40.09904  23.60890  40.88960      Neue Ausrüstungen
3  59.90096  76.39110  59.11040            Neue Bauten

This should be the result:

region	time	wz	value	var
a	1995	z	100	Neue Anlagen insgesamt
a	1995	z	40.09904	Neue Ausrüstungen
a	1995	z	59.90096	Neue Bauten
b	1995	z	100	Neue Anlagen insgesamt
b	1995	z	23.60890	Neue Ausrüstungen
b	1995	z	76.39110	Neue Bauten
a	1996	z	100	Neue Anlagen insgesamt
a	1996	z	40.88960	Neue Ausrüstungen
a	1996	z	59.11040	Neue Bauten

# Not working, sure "[.]" is missing
reshape(dat2, dir="long", varying=1:3, split=list(regexp="[0-9][a-z]",
include=T))

Thanks for any help!
Patrick




More information about the R-help mailing list