[R] apply to a matrix and insert in the middle of an array

2011-10-09 Thread Maas James Dr (MED)
If possible I'd like to produce a function that applies a formula to a column in a matrix (essentially calculating the mse) and then inserts it between values of a an array ... confusing I know, here is an example of what I'm trying to accomplish: ## create a matrix (a -

[R] procedure Power in module Math

2011-09-04 Thread Maas James Dr (MED)
Hi All, I'm attempting to compile and run a BUGS model using OpenBUGS from R and getting this message. I've googled around not found much, it may well be a problem with OpenBUGS and not R. Any suggestions or clues as to how to find the problem would be welcome. I'm wondering if I'm missing

[R] extract value from mer object ?

2011-05-17 Thread Maas James Dr (MED)
What is the easiest way to extract a value from a 'mer' object from glmer? The first I need is the trtpair Std.Dev. which in this case is 0.17542? I've managed to get the fixed effects numbers from summary(fednmaout)@coeffs but no luck with the Random effects stuff. TIA Jim fednmaout

[R] howto calculate column means in data frame

2011-04-10 Thread Maas James Dr (MED)
Long story short, I have a big iterative procedure that produces a long list of data.frames such as the one called results here. Is there an easy way to produce a similar list of data.frames comprised of the mean of each of the columns in results, such that it ends up like the one I've shown in

[R] extract variance for random effects from mer object

2011-04-07 Thread Maas James Dr (MED)
I get an output from a glmer package, but would like to extract the variance of the Random effects, in this case called trtpair and the value is 0. Can I extract it directly or do I need to do some further calculations on the mer object to get it? Thanks Jim class(fednmaout) [1] mer

[R] save ordinary numerical calculations as pdf

2011-03-30 Thread Maas James Dr (MED)
I'd like to save some calculation outputs as a pdf, to incorporate with others in a document. I've tried pdf(filename) name_of_object_to_output dev.off() but it doesn't seem to work, appears that this pdf function is for graphics? Is there a way to output numerical objects to pdf? Thanks J

[R] creating character vector

2011-03-14 Thread Maas James Dr (MED)
Is there a way to convince R to create a character vector without using the quotes? This works ex1 - c(first,second) but when I try this it doesn't ext - as.character(c(first,second)) it complains. I have many variables to put into character vectors so dispensing with the quotes would be

[R] creating list of lists

2011-03-12 Thread Maas James Dr (MED)
Question 1: I have a long list of variable names such as first - c(one,two,three) and what I want to do is create a list of lists ... where the names of each of overall lists components are one,two, and three. This is the same result as second - list(one=list(),two=list(),three=list()) Is

[R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Maas James Dr (MED)
I'm attempting to sort a 3 dimensional array that looks like this x , , 1 [,1] [,2] [1,]99 [2,]79 , , 2 [,1] [,2] [1,]65 [2,]46 , , 3 [,1] [,2] [1,]21 [2,]32 Such that it ends up like this y , , 1 [,1] [,2] [1,]21

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Maas James Dr (MED)
Hi Rex, Thanks, this is exactly what I want but have to do it with many big arrays ... thus if there were a way to do it with a vectorized function would it not be a lot more efficient? Much appreciated! J Subject: RE: sort a 3 dimensional array across third dimension ? Although I suggested

[R] removing lower and upper quantiles from an arry

2011-02-17 Thread Maas James Dr (MED)
I'm trying to work out the simplest way to remove the upper and lower quantiles, in this case upper and lower 25% from an array. I can do it in two steps but when I try it in one, it fails. Is there something simple missing from my syntax or are there other simple elegant way to accomplish

[R] does range of values in array include a third value?

2011-02-17 Thread Maas James Dr (MED)
I'm using the range command to get the minimum and maximum values of an array as in x - range(array_y) which gives me two values such as [1] -2 9 I need to be able to test if this range of values includes a third value. For example I'd like to query 1) does the range of -2 to 9 include

[R] does range of values in array include a third value?

2011-02-17 Thread Maas James Dr (MED)
I'm using the range command to get the minimum and maximum values of an array as in x - range(array_y) which gives me two values such as [1] -2 9 I need to be able to test if this range of values includes a third value. For example I'd like to query 1) does the range of -2 to 9 include 3,

[R] Error in { : task 3 failed - NA/NaN argument

2011-01-30 Thread Maas James Dr (MED)
I'm attempting to run a rather complex routine that involves a few loops, and even some use of foreach and doMPI. I just added another external loop and now get this error message. Error in { : task 3 failed - NA/NaN argument Is there a way to debug what is causing this error or where? I

[R] syntax for a list of components from a list

2011-01-20 Thread Maas James Dr (MED)
I'm attempting to generalise a function that reads individual list components, in this case they are matrices, and converts them into 3 dimensional array. I can input each matrix individually, but want to do it for about 1,000 of them ... This works array2 -

[R] combining matrices from a list into a multidimensional array

2011-01-19 Thread Maas James Dr (MED)
I get some results back from running an iterative analysis in the form of a list of matrices. What I would like to do with this list is combine it such that all the similar components get combined into a multidimensional array. If possible I'd like to put results[[1]]$resultmean and

[R] external R scripts

2010-11-10 Thread Maas James Dr (MED)
Is it possible to send data from an executing R script, to external R script files, on linux in this case, get that external R script to execute, and pass results back to the central script? If so what commands should I be looking at? I've googled for R and external, stuff like that but no

[R] jags error message

2010-11-09 Thread Maas James Dr (MED)
Could anyone give me some clues as to the best way to debug this error message? I think it is from the passing of variables back to R from the jags function which does Bayesian fitting. The curious part for me is that the error messages seem random, yet the input data are always the same.

[R] getting all contrasts from glm

2010-10-22 Thread Maas James Dr (MED)
I'm using the following model to do an analysis faicout - glm(cbind(events,patnums-events) ~ as.factor(treat) + as.factor(numtrial), family = binomial ) Is this example there are 4 treatments . In the glm object I can find the contrasts of the main treats vs the first i.e. 2v1, 3v1 and 4v1

[R] create a list fails

2010-10-20 Thread Maas James Dr (MED)
I can not understand why this fails faicoutput2 - list(stuff21 = as.numeric(faicout$coefficients[2]), + stuff31=as.numeric(faicout$coefficients[3]), + stuff41=as.numeric(faicout$coefficients[4]), + stuff32=(stuff21-stuff31), +

[R] rbind ing matrices and resetting column numbers

2010-10-14 Thread Maas James Dr (MED)
Sorry for the verbose example. I want to row bind two matrices, and all works except I want the column labelled row to be sequential in the new matrix, shown as mat3 here, i.e. needs to be 1:6 and not 1:3 repeated twice. Any suggestions? Thanks J colnm1 - c(row,ti,counti) colnm2 -

[R] exponentiate elements of a whole matrix

2010-10-13 Thread Maas James Dr (MED)
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. Thanks J === Dr. Jim Maas University of

[R] debugging

2010-10-07 Thread Maas James Dr (MED)
I'm attempting to learn how to use the debug function to find the values of some variables. I've found a couple of documents describing the basics and they show examples that the debugger returns Browse[1] but for some reason when I follow the examples I get Browse[2] What is the 2

[R] Error: attempt to apply non-function

2010-09-23 Thread Maas James Dr (MED)
This code worked fine for me, then did some cleaning up of formatting using ESS (Emacs) and now I get this error, no idea what is causing it, all the brackets/parentheses seem to be balanced. What have I done wrong? Thanks Jim p0.trial01 - 0.25 TruOR01 - 0.80 num.patients.01 - 50

Re: [R] removing specific rows from array

2010-09-18 Thread Maas James Dr (MED)
...@gmail.com] Sent: 18 September 2010 04:14 To: Maas James Dr (MED) Cc: r-help@r-project.org Subject: Re: [R] removing specific rows from array Here's one way... treats - c(t0, t1, t2, t3) n - length(treats) n2 - choose(n-1, n-2) comb - matrix(, nrow=n*n2, ncol=n-1) k - 1 for (i in 1:n) { comb[k

[R] removing specific rows from array

2010-09-17 Thread Maas James Dr (MED)
I'm attempting to create an array of treatment comparisons for modelling data generation. This involves comparison of one treatment (c2) with another (c3), relative to a common comparator (c1). Attached code gives me the correct array but need to remove duplicates. Duplicates relate only to

[R] using variable from for loop in naming new variables

2010-09-16 Thread Maas James Dr (MED)
Simple one here ... but can't get it to work ... for (i in 1:4){ paste(stuff,[i]),sep=) - 3 + i } ls() rm(list=ls()) I just want it to create 4 new variables called stuff1, stuff2, stuff3, stuff4 with the corresponding assignments. I realise that there are more elegant functions but

[R] pasting together 2 character arrays

2010-08-31 Thread Maas James Dr (MED)
If possible I would like to combine two different character arrays in combinations Array1 - c(height,weight,age,sex) Array2 - c(trt0,trt1,trt2) I would like to combine these two character vectors to end up with such ... Array3 height.trt0.trt1 height.trt0.trt2 weight.trt0.trt1

[R] multiple assignments ?

2010-08-24 Thread Maas James Dr (MED)
Simple one, have read and googled, still no luck! I want to create several empty vectors all of the same length. I would like multiple empty vectors (vec1, vec2, vec3) and want to create them all in one line. I've tried vec1,vec2,vec3 - vector(length=5) and c(vec1,vec2,vec3) -

[R] output values from within a function

2010-08-20 Thread Maas James Dr (MED)
Is it possible to get R to output the value of an expression, that is being calculated within a function? I've attached a very simple example but for more complicated ones would like to be able to debug by seeing what the value of specific expressions are each time it cycles through a loop

[R] combinations

2010-08-18 Thread Maas James Dr (MED)
I would appreciate any suggestions on which function to use to write subsequent functions analysing combinations of treatments. This refers to experimental trials of medical treatments. I want to write routines to analyse various comparisons (combinations) So if 5 treatments are

[R] adding a row of names to data.frame

2010-07-05 Thread Maas James Dr (MED)
Relative noob here, I have a data.frame and simply want to add an explicit column of names in column 1 of the form trial_number01 for row 1, trial_number02 for row 2 etc. It is simply for visual purposes and to explain data to others. I've tried Using row.names and other but still no