[R] [R-pkgs] package JMbayes -- version 0.5-0

2014-01-17 Thread D. Rizopoulos
*** Apologies for cross posting *** Dear Colleagues, Dear R-users, I would like to announce the release of the new version of package JMbayes available from CRAN (http://CRAN.R-project.org/package=JMbayes). This package fits joint models for longitudinal and time-to-event data under a

Re: [R] Counting various elemnts in a vactor

2013-03-26 Thread D. Rizopoulos
try this: df - c(F, C, F, B, D, A, D, D, A, F, D, F, B, C) tab - table(df) tab rep(names(tab), 100 * tab) I hope it helps. Best, Dimitris On 3/26/2013 9:12 AM, Katherine Gobin wrote: Dear R forum I have a vector say as given below df = c(F, C, F, B, D, A, D, D, A, F, D, F, B,

Re: [R] transpose lists

2013-03-08 Thread D. Rizopoulos
two possibilities are: lis - list(c(12.1,0.1,12.0,1.1), c(3.44,3.00,33.10,23.00)) # 1st m - do.call(rbind, lis) split(m, col(m)) # 2nd lapply(seq_along(lis[[1]]), function (i) sapply(lis, [, i)) I hope it helps. Best, Dimitris On 3/8/2013 11:06 AM, ishi soichi wrote: Thanks. The

Re: [R] Script for conditional sums of vectors

2013-02-04 Thread D. Rizopoulos
try this: a - c(1,1,1,1,1,1,2,2,2,2,2,2) b - c(1,1,1,2,3,4,1,1,2,2,3,4) c - c(400,200,300,100,500,300,200,100,500,400,200,100) DF - data.frame(a, b, c) with(DF, tapply(c, list(a, b), sum)) I hope it helps. Best, Dimitris On 2/4/2013 10:29 AM, Benjamin Gillespie wrote: Hi guys, I hope you

Re: [R] How to create a random matrix with conditions

2013-01-28 Thread D. Rizopoulos
You didn't say how you want these variables to be distributed, but in case you want a multivariate normal, then have a look at function mvrnorm() from package MASS, and especially at the 'empirical' argument, e.g., library(MASS) # assumed covariance matrix V - cbind(c(2, 1), c(1, 1.2)) V x1

Re: [R] problems with coercing a factor to be numeric

2013-01-23 Thread D. Rizopoulos
Check R FAQ 7.10: How do I convert factors to numeric? I hope it helps. Best, Dimitris On 1/23/2013 10:33 AM, Francesco Sarracino wrote: Dear R listers, I am trying to compute the mean of a dummy variable that is encoded as a factor. However, even though the levels of my factor are 0 - 1,

Re: [R] problems with coercing a factor to be numeric

2013-01-23 Thread D. Rizopoulos
to numeric? as.numeric(as.character(pp)) and as.numeric(levels(pp))[as.integer(pp)] However, whatever I do, I get Warning message: NAs introduced by coercion and the output is a vector of NA. Any ideas? f. On 23 January 2013 10:39, D. Rizopoulos d.rizopou...@erasmusmc.nl mailto:d.rizopou

Re: [R] Concatenate two lists, list by list

2013-01-23 Thread D. Rizopoulos
you just need: mapply(c, Part1$dataset, Part2$dataset, SIMPLIFY = FALSE) I hope it helps. Best, Dimitris On 1/23/2013 11:01 AM, Alaios wrote: Thanks a lot Petr, for the answer unfortunately that would convert everything to a matrix num [1:32002, 1:3] 0 0 0 0 0 0 0 0 0 0 ... but if you

Re: [R] Concatenate two lists, list by list

2013-01-23 Thread D. Rizopoulos
... - attr(*, dim)= int [1:2] 3 2 I am sorry that I can not find reproducible example to show you Alex *From:* D. Rizopoulos d.rizopou...@erasmusmc.nl *To:* Alaios ala...@yahoo.com *Cc:* PIKAL Petr petr.pi

Re: [R] Simple use of dcast (reshape2 package)

2013-01-22 Thread D. Rizopoulos
you could try the following: DF - read.table(textConnection( Target Eaten ID 50 TPP 0 1 51 TPP 1 2 52 TPP 3 3 53 TPP 1 4 54 TPP 2 5 50.1GPA 9 1 51.1GPA11 2 52.1GPA 8 3 53.1GPA 8 4 54.1GPA10 5),

Re: [R] apply calculations to elements in a vector

2012-11-16 Thread D. Rizopoulos
Try this: x - c(10, 20, 30) head(x, -1) + tail(x, -1) I hope it helps. Best, Dimitris On 11/16/2012 3:50 PM, e-letter wrote: Readers, If a vector consists of: 10 20 30 how to create a new vector based upon the results of calculations to the elements, e.g. addition of successive

Re: [R] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread D. Rizopoulos
Another alternative is: aa - array(0, dim = c(3,3,3)) a - matrix(1, 3, ) for (i in 1:3) { a[i, ] - -a[i, ] aa[, , i] - a } aa I hope it helps. Best, Dimitris From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of

Re: [R] Selected matrices of an array and put into a list

2012-11-12 Thread D. Rizopoulos
One approach is: BB - rnorm(6*5*27) dim(BB) - c(6, 5, 27) lapply(2:27, function (i) BB[, , i]) I hope it helps. Best, Dimitris On 11/12/2012 8:56 AM, Haris Rhrlp wrote: Dear R users, I have an array that has matrices that i want BB[16,5,2:27] i want to put each of the 26 matrices into a

Re: [R] simple coversion of matrix rows to matrix columns

2012-11-07 Thread D. Rizopoulos
try this: a - matrix(1:30, ncol= 3 ) t(a) I hope it helps. Best, Dimitris On 11/7/2012 12:50 PM, Andras Farkas wrote: Dear All I would like to convert matrix rows to columns. I am thinking the t() function should help, but am having a hard time converting the matrix into the

Re: [R] averaging a list of matrices element wise

2012-11-05 Thread D. Rizopoulos
If you don't have any NAs, then one way is: n - 3 r - 5 s - 6 raw - lapply(seq_len(n), function(i){ matrix(rnorm(r * s), ncol = r) }) Reduce(+, raw) / length(raw) I hope it helps. Best, Dimitris On 11/5/2012 11:32 AM, ONKELINX, Thierry wrote: Dear all, I have a list of n matrices

Re: [R] convert list without same component length to matrix

2012-11-01 Thread D. Rizopoulos
try this: l - list(c(1,2,3,7), c(3,4,5,6,3), c(4,2,5,7), c(2,4,6,3,2), c(3,5,7,2)) sapply(l, head, 4) I hope it helps. Best, Dimitris On 11/1/2012 9:11 AM, Al Ehan wrote: Hi, I have this lame question. I want to convert a list (each with varies in length) to matrix with same row length

[R] [R-pkgs] New Package 'JMbayes' for the Joint Modeling of Longitudinal and Survival Data under a Bayesian approach

2012-09-19 Thread D. Rizopoulos
Dear R-users, I would like to announce the release of the new package JMbayes available from CRAN (http://CRAN.R-project.org/package=JMbayes). This package fits shared parameter models for the joint modeling of normal longitudinal responses and event times under a Bayesian approach using