reshape

12 views
Skip to first unread message

Sharon Zohar

unread,
Apr 7, 2014, 10:04:14 AM4/7/14
to israel-r-...@googlegroups.com
Hi,
I'm trying to reshape this dataset:

Medium Age visits
organic 18-24 23205
organic 25-34 40208
search 18-24 89
search 25-34 168


into this:

Age visits_organic visits_search
18-24 23205 89
25-34 40208 168


can't figure the correct arguments to be inserted in the reshape function..

Thanks in advance,
Sharon

Tal Galili

unread,
Apr 7, 2014, 10:05:37 AM4/7/14
to israel-r-...@googlegroups.com
Please use the
dput
function to create the R object - and we'll try and help...



----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------



--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

amit gal

unread,
Apr 7, 2014, 11:05:16 AM4/7/14
to israel-r-...@googlegroups.com
dcast(data=my.df,formula=Age~Medium)



On Mon, Apr 7, 2014 at 5:04 PM, Sharon Zohar <sharo...@gmail.com> wrote:

--

amit gal

unread,
Apr 7, 2014, 11:06:07 AM4/7/14
to israel-r-...@googlegroups.com
dcast() is a function in the reshape2 package, my.df is the name of the data.frame holding the data

Sharon Zohar

unread,
Apr 8, 2014, 2:22:16 AM4/8/14
to israel-r-...@googlegroups.com
Thanks Amit,
I've installed the package but neither 'dcast', nor 'cast' can be found (as a function)..
strange.. 

Anyway, thanks a lot for replying =)
dcast(data=my.df,formula=Age~Medium)



To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.

Sharon Zohar

unread,
Apr 8, 2014, 2:28:55 AM4/8/14
to israel-r-...@googlegroups.com
Found it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
After installing the package reshape,
this solution works:

Thanks everyone!

amit gal

unread,
Apr 8, 2014, 3:33:57 AM4/8/14
to israel-r-...@googlegroups.com
1) did you install the "reshape2" package or "reshape" package (without the 2). you need reshape2
2) did you remember to call the library (e.g. use library(reshape2) before using it)?




To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages