[R] alternative for shell() in Mac

2013-11-04 Thread Nicolas Gutierrez
Hi All, I'm trying to run an ADMB function on R for Mac and need to find a substitute for the Windows command shell(). I tried system() but I get the following message: > system(ADMBFile) /bin/sh: /Users/nicolas/Desktop/SPE/LBSPR_ADMB/L_AFun.exe: cannot execute binary file Any hints please?

[R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Nicolas Gutierrez
Hi All, I’m trying to superimpose (or "add") two matrices: 1. resulting from a table function with frequencies: > U=table(pop$xloc, pop$yloc)) 14 15 16 17 18 19 20 21 22 5 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0

[R] list inside a for loop

2011-01-22 Thread Nicolas Gutierrez
Hi All, Trying to figure out the way to create a vector of values inside a loop I have a matrix pop: Id yloc xloc weight 1 2 . and spatial grid grid.dens with "coordinates" (x=xloc,y=yloc) I want to create two more vectors: Food and Consumed inside the loop and add those to pop so: Id

[R] return object from loop inside a function

2011-01-25 Thread Nicolas Gutierrez
Hi All, I have a for loop inside the function and I cannot get UUU to give me an updated grid.dens object when I run the function (it does update when I run just the for loop). Here's a simplified version of my function: UUU=function(pop, grid.dens) { for (i in 1:10){ Food=grid.dens[pop$yloc

[R] delete a row in dataframe w/o changing indexing

2011-02-08 Thread Nicolas Gutierrez
Hi All, I'm trying to delete a row from my dataframe "pop" without changing the indexing (column 0) as follows: >pop id birth size xloc yloc weight energy gonad consumed 1 136 13 34 43 0 18 00 2 236 10 39 38 0 18 00 3 3

[R] add repeated rows in data frame (without a loop)

2011-02-22 Thread Nicolas Gutierrez
Hi All, I have a data frame "pop": >id xloc yloc size > 1 1 101295 > 2 211 1081 And I want to add the vector "rec" to the data frame "n" times (without using a loop): > rec=c(3, 5, 5, 10) > n=2 The result I want: >id xloc yloc size > 1 1 10

Re: [R] add repeated rows in data frame (without a loop)

2011-02-22 Thread Nicolas Gutierrez
That worked.. thanks Peter On 2/22/2011 5:40 PM, Peter Ehlers wrote: popm <- as.matrix(pop) recm <- matrix(rep(rec, n), nr=n, byrow=TRUE) newpop <- data.frame(rbind(popm, recm)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

[R] sum data from data.frame in a matrix

2011-02-22 Thread Nicolas Gutierrez
Hi all (again), I have a data frame "pop": xloc yloc yield 1 101295 2 111081 3 121120 4 121110 And I want to get the sum of yield for the cell (pop$xloc, pop$yloc) in a matrix as follows: xloc 10 11 12 10 0 81 0 yloc

[R] Fwd: Re: sum data from data.frame in a matrix

2011-02-23 Thread Nicolas Gutierrez
data.frame in a matrix Date: Wed, 23 Feb 2011 00:10:52 -0800 From: Dennis Murphy To: Nicolas Gutierrez Hi: ...and a second way, using the reshape2 package: library(reshape2) dcast(df, yloc ~ xloc, value_var = 'yield', fun = sum) yloc 10 11 12 1 10 0 81 0 2 11

[R] data.frame operations

2011-02-25 Thread Nicolas Gutierrez
Hi All, I've been doing circles with this all morning, although I'm sure there's a simple solution. I have a data.frame "pop" as follows: > pop ind xloc yloc gonad 1 15 2 12 2 15 4 25 3 13 3 30 4 15 4 10 5 11 4 08 .

[R] substract 2 data.frames

2011-02-27 Thread Nicolas Gutierrez
Hi! I have 2 data.frames: "fish" and "popn": >fish xloc yloc id birth size weight energy gonad 20 15 15 54 -60 107.9 63.0 15952.9 8.0 21 15 15 32 -60 105.1 61.4 15538.8 7.8 914 43 96 -60 118.9 69.4 17573.2 8.8 71 324 64 -60 121.6 71.0 17976.0 9.0

Re: [R] substract 2 data.frames

2011-02-27 Thread Nicolas Gutierrez
That worked! Gracias Jorge Nico On 2/27/2011 12:58 PM, Jorge Ivan Velez wrote: Hi Nicolas, Try popn[!rownames(popn) %in% rownames(fish), ] HTH, Jorge On Sun, Feb 27, 2011 at 3:29 PM, Nicolas Gutierrez <> wrote: Hi! I have 2 data.frames: "fish" and &qu

[R] sub setting data.frame

2011-02-28 Thread Nicolas Gutierrez
Hi All, I have a data.frame: >pop consumed ind recruits gonad cell 1516.74 1 0.0220.21 0.25 2 1143.20 1 0.0220.21 0.50 3250.00 1 0.0220.21 0.25 4251.98 1 0.0218.69 0.25 5598.08 1 0.0218.69 0.25 6437.38 1 0.02

Re: [R] sub setting data.frame

2011-02-28 Thread Nicolas Gutierrez
Got it.. thanks to Jorge! pop[1:which(with(pop, cumsum(cell) == 2)),] Nico 2/28/2011 12:08 PM, Ista Zahn wrote: I don't understand the question... On Mon, Feb 28, 2011 at 2:46 PM, Nicolas Gutierrez wrote: Hi All, I have a data.frame: pop consumed ind recruits gonad c

[R] extract rows with unique values from data.frame

2011-03-07 Thread Nicolas Gutierrez
Hello! I have the data frame "pop": xloc yloc gonad indEneW Agent 123 20 516.74 1 0.02 20.21 0.25 223 20 1143.20 1 0.02 20.21 0.50 321 19 250.00 1 0.02 20.21 0.25 422 15 251.98 1 0.02 18.69 0.25 524 18 598.08 1 0.02

Re: [R] extract rows with unique values from data.frame

2011-03-07 Thread Nicolas Gutierrez
Dear Bill.. .great, thanks for your quick response. Cheers Nico On 3/7/2011 8:16 PM, bill.venab...@csiro.au wrote: i<- with(pop, cumsum(!duplicated(cbind(xloc, yloc k<- 2 ## how many do you want? no<- min(which(i == k)) pop[1:no, ] __ R

[R] extracting half the rows with unique values from data.frame

2011-03-09 Thread Nicolas Gutierrez
hey!! Another data.frame question: I have the following data.frame (pop) pp=textConnection(" + xloc yloc gonad indEneW Agent + 123 20 516.74 1 0.02 20.21 0.25 + 223 20 1143.20 1 0.02 20.21 0.50 + 323 20 250.00 1 0.02 20.21 0.25 + 422 15

[R] subset data frame with condition

2011-03-18 Thread Nicolas Gutierrez
Hello, One more question.. I have the data.frame "pop": xloc yloc gonad indEneW Area 123 20 516.74 1 0.02 20.21 1 223 20 1143.20 1 0.02 20.21 1 323 20 250.00 1 0.02 20.21 1 422 15 251.98 1 0.02 18.69 2 522 15 598.08

Re: [R] subset data frame with condition

2011-03-18 Thread Nicolas Gutierrez
perfect, thanks Henrique! Nico On 3/18/2011 11:17 AM, Henrique Dallazuanna wrote: Try this: subset(pop, (ave(Area, Area, FUN = length) == 1 | ave(Area, Area, FUN = function(x)cumsum(prop.table(x)))< 0.7& Area %in% 1:3)) On Fri, Mar 18, 2011 at 2:48 PM, Nicolas Gutierrez wrote:

[R] create a matrix with values from data.frame

2011-03-19 Thread Nicolas Gutierrez
Hello, I'm trying to create a matrix (95x55) with data from a data.frame pop: xloc yloc go indEne totW 123 20 516 1 0.02 20.21 223 20 1143 1 0.02 20.21 323 20 250 1 0.02 20.21 422 15 251 1 0.02 18.69 522 15 598

Re: [R] create a matrix with values from data.frame

2011-03-19 Thread Nicolas Gutierrez
Thanks Jim and David.. that was easy! Nic On 3/19/2011 3:00 PM, jim holtman wrote: x.mat<- matrix(NA, 95, 55) # create matrix x.mat[cbind(x$xloc, x$yloc)]<- x$totW which(!is.na(x.mat), arr.ind =TRUE) __ R-help@r-project.org mailing list https://

[R] extract cells by columns/rows from matrix

2011-04-14 Thread Nicolas Gutierrez
Hi All, I have the following matrix Ufi (x by y): Ufin 1 2 3 4 5 6 7 8 9 10 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 4 0 0 0 6 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 9 0 0 0 7 0 2 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0

[R] extract cells by columns/rows from matrix

2011-04-14 Thread Nicolas Gutierrez
hi All, I have a matrix Ufi (x by y) 1 2 3 4 5 1 0 0 0 0 3 2 0 0 0 9 0 3 0 2 0 0 3 4 0 0 1 0 0 5 0 1 0 0 0 And I need the x and y "coordinates" of those cells with maximum values: First: x=4; y=2 (Value=9) Second: x=5; y=3 (value=3) Any help? THANKS! Nic _