Edward Are you sure mymatrix is, in fact, a matrix and note a dataframe (which is a list)? I get:
> is.matrix(mymatrix) [1] FALSE > is.data.frame(mymatrix) [1] TRUE > samples <- mymatrix[1,] > llgm <- dgamma(samples, scale=1, shape=2, log = TRUE) Error in dgamma(x, shape, scale, log) : Non-numeric argument to mathematical function That is, the same error as you when mymatrix is a dataframe. But convert it to a matrix and: > mymatrix <- as.matrix(mymatrix) > is.matrix(mymatrix) [1] TRUE > is.data.frame(mymatrix) [1] FALSE > samples <- mymatrix[1,] > llgm <- dgamma(samples, scale=1, shape=2, log = TRUE) > llgm V1 V2 V3 V4 V5 V6 -99.25657 -84.01700 -237.40735 -201.26922 -170.53122 -159.29770 HTH .... Peter Alspach > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Edward Wijaya > Sent: Wednesday, 21 May 2008 2:17 p.m. > To: r-help@r-project.org > Subject: [R] Converting Data Types > > Hi, > > How can I convert the matrices to list. > > For example I have this snippet: > > samples<-mymatrix[1,] > print(samples) > > which prints: > > V1 V2 V3 V4 V5 V6 > 1 103.9 88.5 242.9 206.6 175.7 164.4 > > > How can I convert the object "samples" such that it prints: > [1] 103.9 88.5 242.9 206.6 175.7 164.4 > > The reason I ask this because I can't use the former > "samples" object with this function: > > llgm <- dgamma(samples, scale=1, shape=2, log = TRUE) > > which gives this error: > e 1374Error in dgamma(x, shape, scale, log) : > Non-numeric argument to mathematical function > > Regards, > Edward > > ______________________________________________ > 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. > The contents of this e-mail are privileged and/or confidential to the named recipient and are not to be used by any other person and/or organisation. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. ______________________________________________ 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.