27

Possible Duplicate:
Error: could not find function … in R

I find various references to the function melt(), actually melt.data.frame() in stackoverflow for R. But when I call it in R, it gives me

Error: could not find function "melt"

How do I load that function so I can call it?

Community
  • 1
  • 1
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
  • please explain the question completely – Kishore Kumar Mar 18 '12 at 18:48
  • 1
    you need to `install.packages("reshape"); library(reshape)` – GSee Mar 18 '12 at 18:50
  • 2
    You could have found the answer by searching via [rseek.org](http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=melt&sa=Search+functions%2C+lists%2C+and+more&cof=FORID%3A11). – Joshua Ulrich Mar 18 '12 at 18:54
  • 1
    or `install.packages("sos"); library("sos"); findFn("melt.data.frame")` (but there's a recursion problem here, since you have to know how to install and load the `sos` package in order to use it to search for `melt.data.frame` ... – Ben Bolker Mar 19 '12 at 03:08
  • It's also the first Google hit for "melt cran" – Chris Beeley Mar 20 '12 at 10:55
  • Not duplicate at all. The question isn't "how to solve could not find function errors", but "where is `melt()`". – Superbest Apr 27 '15 at 09:41

1 Answers1

61

The melt function is to be found in the reshape package.

If you do not have that package installed, then you will need to install it with install.packages("reshape") before you can use it. Then, when the package is installed, make it available with library(reshape). At which point you are good to go!

Update 2018: The package in R 3.6.1. is now called reshape2.

The reshape2 notes also say:

reshape2 is retired: only changes necessary to keep it on CRAN will be made. We recommend using tidyr instead.

tidyr does not contain the melt function.

Mr. T
  • 11,960
  • 10
  • 32
  • 54
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490