On Wed, Oct 13, 2010 at 11:51 AM, Maas James Dr (MED) <j.m...@uea.ac.uk> wrote: > I've tried hard to find a way to exponentiate each element of a whole matrix > such that if I start with A > > A = [ 2 3 > 2 4] > > I can get back B > > B = [ 7.38 20.08 > 7.38 54.60] > > I've tried > > B <- exp(A) but no luck.
Your matrix notation looks unlike R. We prefer cut n paste examples here. In which case: > A=matrix(1:4,2,2) > A [,1] [,2] [1,] 1 3 [2,] 2 4 > exp(A) [,1] [,2] [1,] 2.718282 20.08554 [2,] 7.389056 54.59815 > B=exp(A) > B [,1] [,2] [1,] 2.718282 20.08554 [2,] 7.389056 54.59815 so, works for me (as I expected it would). Either you've redefined the exp function or you've accidentally started matlab instead. Barry ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.