[R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
Hi, I have a list of n items and the ith element has m_i elements within it. I want to do something like: predicted.values- lapply(all.predicted.values,'[[',max.growth[[i]]) Where max.growth[[i]] is the element I want to extract from each of the ith predicted elements. Thus, for example, I

Re: [R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
[[7]] [1] 0 [[8]] [1] 0 [[9]] NULL On Oct 18, 2010, at 11:08 AM, Henrique Dallazuanna wrote: Try this: diag(sapply(all.predicted.values, '[[', 'max.growth')) On Mon, Oct 18, 2010 at 12:59 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi, I have a list of n items and the ith element

Re: [R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
)x1[[x2]],all.predicted.values,max.growth) might be what you want. On Oct 18, 2010, at 5:17 PM, Gregory Ryslik wrote: Unfortunately, that gives me null everywhere. Here's the data I have for all.predicted.values and max.growth. Perhaps this will help. Thus I want

Re: [R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
' and then attaching a '.txt' file, or just pasting them in the email. On Mon, Oct 18, 2010 at 2:40 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi Everyone, This is closer to what I need but this returns me a matrix where each element is a factor. Instead I would want a list of lists

[R] cube root of a negative number

2010-10-26 Thread Gregory Ryslik
Hi, This might be me missing something painfully obvious but why does the cube root of the following produce an NaN? (-4)^(1/3) [1] NaN As we can see: (-1.587401)^3 [1] -4 Thanks! Greg __ R-help@r-project.org mailing list

[R] vertical list sum

2010-10-29 Thread Gregory Ryslik
Hi Everyone, I have a list of vectors like this (in this case it's 3 vectors but assume the vector count and the length of each vector is not known): [[1]] [1] 9 5 7 2 14 4 4 3 [[2]] [1] 3 6 25 2 14 3 3 4 [[3]] [1] 28 4 14 3 14 2 4 5 What I want to do is take the average

Re: [R] vertical list sum

2010-10-29 Thread Gregory Ryslik
9.33 14.67 13.67 [10] 10.00 Reduce(+, mylist)/length(mylist) [1] 7.33 11.67 15.00 11.33 12.67 10.67 9.33 14.67 13.67 [10] 10.00 HTH, Jorge On Fri, Oct 29, 2010 at 6:46 PM, Gregory Ryslik wrote: Hi Everyone, I have

[R] writing to a file

2010-11-13 Thread Gregory Ryslik
Hi, I have a fairly complex object that I have written a print function for. Thus when I do print(results), the R console shows me a whole bunch of stuff already formatted. What I want to do is to take whatever print(results) shows to console and then put that in a file. I am doing this using

[R] bootstrapping

2010-09-11 Thread Gregory Ryslik
Hi Everyone, I am implementing a special case of Random forests. At one point, I have a list of which I then sample for replacement. So if the list is 100 elements, I get 100 elements some of them duplicates. How can I easily get the elements that were not included in the list? I realize i can

[R] mapping array

2010-09-11 Thread Gregory Ryslik
Hi, Suppose I have array A with 100 elements all filled in with N/A. Array B has 25 elements with actual values. Lastly, I have array C that provides a map of where to put the elements from array A into array B. Thus C would say put element 1 from B into element 3 from array A. I realize I

Re: [R] mapping array

2010-09-12 Thread Gregory Ryslik
### (The sorting is not necessary. It's only there to make checking what happened easier.) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gregory Ryslik Sent: Sunday, 12 September 2010 8:54 AM To: r-help@r-project.org Subject

[R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
Hi, I have a list of several hundred 2 dimensional matrices, where each matrix is n x m. What I need to do is that for each n,m I need an average over all the lists. This would collapse it down to just one nxm matrix. Any easy ways to do that? As always, I'd like to avoid a for loop to keep

Re: [R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
Sorry, I forgot to add that some of the entries in various matrices have NA in them. On Sep 12, 2010, at 3:40 PM, Gregory Ryslik wrote: Hi, I have a list of several hundred 2 dimensional matrices, where each matrix is n x m. What I need to do is that for each n,m I need an average over

Re: [R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
(+,mymats) does what you want. - Phil On Sun, 12 Sep 2010, Gregory Ryslik wrote: Hi, I have a list of several hundred 2 dimensional matrices, where each matrix is n x m. What I need to do is that for each n,m I need an average over all the lists

Re: [R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
23 HTH, Dennis On Sun, Sep 12, 2010 at 12:52 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi, Doing that I get the following: Browse[2] Reduce[+,results] Error in Reduce[+, results] : object of type 'closure' is not subsettable You want parentheses there, not brackets; you're

Re: [R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
Hi Everyone, Thanks to everyone for their help. With your suggestions and some poking around, the following works for what I need. It basically adds all the matrices elementwise, and adds nothing if the element is NA. Thanks again! Code below: ** mymats -

Re: [R] average matrices across a list

2010-09-14 Thread Gregory Ryslik
('+', lapply(mymats, function(x)replace(x, is.na(x), 0))) On Sun, Sep 12, 2010 at 10:36 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi Everyone, Thanks to everyone for their help. With your suggestions and some poking around, the following works for what I need. It basically adds all

[R] multiple cores/building fails

2010-09-14 Thread Gregory Ryslik
Hi Everyone, I have written debugged and tested my code and it works (yay!). I recently tried to parallelize it (1 core/per tree) and when I run the code I get an error saying the object control was not found. I do have an object control in my code but it always works fine as long as I am not

Re: [R] multiple cores/building fails

2010-09-15 Thread Gregory Ryslik
, Greg Sent via BlackBerry by ATT -Original Message- From: Uwe Ligges lig...@statistik.tu-dortmund.de Date: Wed, 15 Sep 2010 10:56:54 To: Gregory Ryslikrsa...@comcast.net Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] multiple cores/building fails On 14.09.2010 21:50, Gregory Ryslik wrote

[R] creating matrices from lists

2010-09-20 Thread Gregory Ryslik
Hi, I have a list of 5 main elements where each main element has 247 atomic entries either 0 or 1. I need to get this into a 247x5 matrix so I do do.call(cbind, mylist). However, it renumbers 0 to a 1 and the 1 to a 2 so that my matrix is filled with 1's and 2's. I understand I can fix it

Re: [R] creating matrices from lists

2010-09-20 Thread Gregory Ryslik
, 2010, at 10:28 PM, David Winsemius wrote: On Sep 20, 2010, at 10:12 PM, Gregory Ryslik wrote: Hi, I have a list of 5 main elements where each main element has 247 atomic entries either 0 or 1. I need to get this into a 247x5 matrix so I do do.call(cbind, mylist). However, it renumbers

Re: [R] creating matrices from lists

2010-09-20 Thread Gregory Ryslik
, 2010, at 10:28 PM, David Winsemius wrote: On Sep 20, 2010, at 10:12 PM, Gregory Ryslik wrote: Hi, I have a list of 5 main elements where each main element has 247 atomic entries either 0 or 1. I need to get this into a 247x5 matrix so I do do.call(cbind, mylist). However

[R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
Hi Everyone, I am interested in taking the mode over several thousand matrices. I show an example below. For the [1,1] entry of my mode matrix that I want to create I would like to have a 2. For the [1,2] entry I would want a 2. For the [2,2] entry it would be 4 and so forth. Earlier, I was

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
(names(which.max(table(x apply(array(unlist(mymats), dim = c(length(mymats), dim(mymats[[1]]))), 1:2, mode) On Tue, Sep 21, 2010 at 10:47 AM, Gregory Ryslik rsa...@comcast.net wrote: Hi Everyone, I am interested in taking the mode over several thousand matrices. I show an example below

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
AM, Gregory Ryslik rsa...@comcast.net wrote: Hi Everyone, I am interested in taking the mode over several thousand matrices. I show an example below. For the [1,1] entry of my mode matrix that I want to create I would like to have a 2. For the [1,2] entry I would want a 2. For the [2,2

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
), dim = c(dim(mymats[[1]]), length(mymats))), 1:2, mode) The error was in c(length(mymats), dim(mymats[[1]])) On Tue, Sep 21, 2010 at 3:19 PM, Gregory Ryslik rsa...@comcast.net wrote: Ack, apologies for the previous email. What I meant to say is that the first element is calculated

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
Perfect! Thank you! On Sep 21, 2010, at 3:27 PM, Henrique Dallazuanna wrote: Use this function: mode - function(x, ...) as.numeric(names(which.max(table(x, useNA = 'ifany' On Tue, Sep 21, 2010 at 4:18 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi, Much better! That seems

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
(which.max(table(x, useNA = 'ifany' On Tue, Sep 21, 2010 at 4:18 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi, Much better! That seems to work great. The only time it doesn't work is that if all the elements are NA for a specific element. Then it gives me a numeric(0) for that cell

[R] Fwd: mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
out the useNA = 'ifAny' in the apply line. Thanks everyone and especially Henrique for all your help! Kind regards, Greg Begin forwarded message: From: Gregory Ryslik rsa...@comcast.net Date: September 21, 2010 4:08:33 PM EDT To: Henrique Dallazuanna www...@gmail.com Cc: r-h

[R] second element of a list

2010-09-30 Thread Gregory Ryslik
Hi, I have a list of of n elements (where n is unknown beforehand). Each element of the list has two subelements. The first is a matrix, the second is a number. I want to make a list of just the matrices. I want to do something like mylists[[ ,2]] but that obviously doesn't work. Is there a

Re: [R] second element of a list

2010-09-30 Thread Gregory Ryslik
On Thu, 30 Sep 2010, Gregory Ryslik wrote: Hi, I have a list of of n elements (where n is unknown beforehand). Each element of the list has two subelements. The first is a matrix, the second is a number. I want to make a list of just the matrices. I want to do something like mylists[[ ,2

[R] misclassification matrix

2010-10-06 Thread Gregory Ryslik
HI Everyone, I am working with the following situation. I have n observations and j possible outcomes and each one of the n observations is assigned a class from 1 to j. Furthermore, this process is done m times (for some large m 1000). What I want to do is create a misclassification matrix

Re: [R] misclassification matrix

2010-10-06 Thread Gregory Ryslik
0.2727273 TF -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gregory Ryslik Sent: Wednesday, October 06, 2010 10:19 AM To: R Help Subject: [R] misclassification matrix HI Everyone, I am working with the following

[R] confusion matrix

2010-10-07 Thread Gregory Ryslik
Hi Everyone, In follow up to my previous question, I wrote some code that correctly makes a confusion matrix as I need it. However, it only works when the numbers are between 1 and n. If the possible outcomes are between 0 and n, then I can't reference row 0 of the matrix and the code breaks.

[R] spatstat regression troubles

2011-04-15 Thread Gregory Ryslik
Hi Everyone, I am trying to figure out the spatstat package for the first time and am having some trouble. Unfortunately, I can't post my data set but I'll hopefully post enough details for some help. I want to model the intensity of a spatial point process using 2 covariates from my data.

Re: [R] spatstat regression troubles

2011-04-16 Thread Gregory Ryslik
to do it would be? Hopefully, I would get the fit using the image way and see that the fits are consistent. Thank you again for your help! Kind regards, Greg On Apr 16, 2011, at 4:46 AM, Rolf Turner wrote: On 16/04/11 15:50, Gregory Ryslik wrote: Hi Everyone, I am trying to figure out

[R] Non-conformable arrays

2011-03-02 Thread Gregory Ryslik
Hi Everyone, I'm running some simulations where eventually I need to table the results. The problem is, that while most simulations I have at least one predicted outcome for each of the six possible categories, sometimes the algorithm assigns all the outcomes and one category is left out. Thus

Re: [R] Non-conformable arrays

2011-03-02 Thread Gregory Ryslik
with the wrong levels, turn it back into a character string vector first. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gregory Ryslik Sent: Thursday, 3 March 2011 1:46 PM To: r-help Help Subject: [R] Non-conformable arrays

[R] read a text file with variable number of spaces

2011-03-02 Thread Gregory Ryslik
Hi, I seem to be having somewhat of an unusual data input problem with some of the data sets I'm working with and want to run a simulation on. in the first data set I'm looking at, I have a text file where the spacing between columns varies. I've attached a snippet. Is there a way to read