[R] Help needed for this error

Peter Ehlers ehlers at ucalgary.ca
Wed May 30 21:19:44 CEST 2012


On 2012-05-30 06:48, Sarah Goslee wrote:
> Hi,
>
> On Wed, May 30, 2012 at 7:48 AM, Dinesh Vakamudi
> <dinesh.vakamudi at gmail.com>  wrote:
>>> results<- mra(x$w1mcp, filter = "d4", n.levels = 3, boundary =
>> "periodic", method = "dwt")
>>> write.csv(results, "c:/mydata.csv")
>
> I have no idea what mra() is - from what package did it come? I see
> there's a package named mra, but it doesn't seem to have a function
> named mra().
>
> Something to do with wavelets, it seems, but which of the many wavelet packages?
>
>> Error in as.data.frame.default(x[[i]], optional = TRUE) :
>>   cannot coerce class 'structure("mra", package = "wavelets")' into a
>> data.frame
>>
>> I am not able to access data stored in results.
>
> Sure you can. Just type results at an R prompt. You can access just
> about anything. What you can't do is save a list of unknown structure
> to a csv file.
>
> What are you trying to do with your results? Save them to view later?
> Look at a particular portion of the results in other software? There
> are ways to accomplish all these tasks, but you need to provide more
> information than an unknown function and an impossible conversion.
>
> Sarah

Just to add to Sarah's comments:
It's always advisable to use an _informative_ subject line which
should indicate what package/function is being asked about.

In this case, the help page for wavelets:::mra clearly states that
the function returns an S4 object with certain slots. If you don't
know how to extract information from the object, try googling
"R extract S4" and you'll soon be led to advice.

Anyway, here you probably want to look at str(results), probably
followed by something like results at D or results at D[[1]], etc.

Peter Ehlers
--



More information about the R-help mailing list