Message-ID: <4B5B93F9.7070004@bitwrit.com.au>
Date: 2010-01-24T00:27:37Z
From: Jim Lemon
Subject: How to apply a function on each column of a matrix
In-Reply-To: <1264291887215-1288471.post@n4.nabble.com>
On 01/24/2010 11:11 AM, anna wrote:
>
> Here is the last code that I wrote but it would give me the same problem:
> I have the matrix mat with n columns mat.1, mat.2 ...mat.n
>
> #To be able to use lapply I convert it to a data.frame:
> mat<- data.frame(mat)
>
> lapply(mat, function, argument of function)
>
> It works but I still get for all elements the function applied for the last
> element. The elements of my results are all the same I don't understand I
> did exactly as shown on this website:
> http://www.ats.ucla.edu/stat/r/library/advanced_function_r.htm#lapply
Hi anna,
If you could post your matrix "mat" (or something else that produces the
problem you describe if "mat" is private or too big) and the commands
you used, someone will probably figure out what is going wrong.
Jim