Rstudio console and Rmd chunk return different outputs while using plyr package


I am trying to run

data  = aaply(laply(datlist, as.matrix), c(2,3), mean)

using plyr package and noticed that the result is returned in different format when the code is running from console vs. Rmd chunk.

The code runs fine in console- it returns a matrix while the code returns a list when running from Rmd.

I tried to specify plyr package by adding plyr:: before both aaply and laply but to no avail. Is there a workaround to this issue?

Many thanks,
Julia S

Hi @shinhm91,
Welcome to the RStudio Community Forum.

I think you will have to post an example of what the object datlist contains before we can troubleshoot this problem. Maybe make a Reproducible Example, and show what output is required:

You are asking aaply() to do calculations on dimensions 2 and 3, whereas as.matrix() will only produce a 2D object (or am I missing something?).


1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.