Re: [R] spatstat regression troubles

2011-04-16 Thread Gregory Ryslik
ite sure what the correct way 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

[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. Aft

[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 this

Re: [R] Non-conformable arrays

2011-03-02 Thread Gregory Ryslik
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

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

[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 t

Re: [R] vertical list sum

2010-10-29 Thread Gregory Ryslik
, mylist), na.rm = TRUE) > [1] 7.33 11.67 15.00 11.33 12.67 10.67 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 >

[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 ver

[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 https://stat.ethz.c

Re: [R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
;))) On Oct 18, 2010, at 4:09 PM, jim holtman wrote: > files did not make it through the mailer. How did you attach them? > try outputting the data using 'dput' and then attaching a '.txt' file, > or just pasting them in the email. > > On Mon, Oct 18,

Re: [R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
> > mapply(function(x1,x2)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.pre

Re: [R] Extracting elements from a nested list

2010-10-18 Thread Gregory Ryslik
[3]] [1] 0 [[4]] [1] 0 [[5]] NULL [[6]] [1] 0 [[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,

[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 wa

[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

Re: [R] misclassification matrix

2010-10-06 Thread Gregory Ryslik
8182 0.0909091 0.7272727 > > In the above, the diagonal is the % correctly classified. > >> diag(1-prop.table(mat, 1)) > [1] 0.750 0.333 0.2727273 > > > TF > > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-h

[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] second element of a list

2010-09-30 Thread Gregory Ryslik
UC Berkeley > spec...@stat.berkeley.edu > > > 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.

[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 si

[R] Fwd: mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
n you can take 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 > Date: September 21, 2010 4:08:33 PM EDT > To: Henrique Dallazuanna > Cc: r-h...@stat

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
} answer <- apply(array(unlist(mymats), dim = c(dim(mymats[[1]]), length(mymats))), 1:2, mode) 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'

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 wrote: > Hi, &g

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
(unlist(mymats), 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 wrote: > Ack, apologies for the previous email. What I meant to say is that the first > ele

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
mode <- function(x, ...) > as.numeric(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 wrote: > Hi Everyone, > > I am interested in takin

Re: [R] mode across lists of matrices

2010-09-21 Thread Gregory Ryslik
m = c(length(mymats), dim(mymats[[1]]))), 1:2, mode) On Sep 21, 2010, at 10:08 AM, Henrique Dallazuanna wrote: > Try this: > > mode <- function(x, ...) > as.numeric(names(which.max(table(x)))) > apply(array(unlist(mymats), dim = c(length(mymats), dim(mymats[[1]]))), 1:2, > mo

[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 wa

Re: [R] creating matrices from lists

2010-09-20 Thread Gregory Ryslik
> On Sep 20, 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

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 s

[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] multiple cores/building fails

2010-09-15 Thread Gregory Ryslik
nd regards, Greg Sent via BlackBerry by AT&T -Original Message- From: Uwe Ligges Date: Wed, 15 Sep 2010 10:56:54 To: Gregory Ryslik Cc: Subject: Re: [R] multiple cores/building fails On 14.09.2010 21:50, Gregory Ryslik wrote: > Hi Everyone, > > I have written debugged an

[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] average matrices across a list

2010-09-14 Thread Gregory Ryslik
te: > You can try this also: > > Reduce('+', lapply(mymats, function(x)replace(x, is.na(x), 0))) > > > On Sun, Sep 12, 2010 at 10:36 PM, Gregory Ryslik wrote: > > > Hi Everyone, > > > > Thanks to everyone for their help. With your suggestions a

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 <- vector('l

Re: [R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
m elementwise > Reduce('+', mymats) > [,1] [,2] [,3] > [1,] 23 33 15 > [2,] 25 36 26 > [3,] 20 24 23 > > HTH, > Dennis > > On Sun, Sep 12, 2010 at 12:52 PM, Gregory Ryslik wrote: > Hi, > > Doing that I get the following: >

Re: [R] average matrices across a list

2010-09-12 Thread Gregory Ryslik
ose your list is called "mymats". Then > > Reduce("+",mymats) > > does what you want. > - Phil > > > On Sun, 12 Sep 2010, Gregory Ryslik wrote: > >> Hi, >> >> I have a list of several hundred 2 dimensi

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 nee

[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 co

Re: [R] mapping array

2010-09-12 Thread Gregory Ryslik
gt; ### 8< cut here 8< ### > > > (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 Grego

[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

[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