[R] install R package on Unix cluster

2012-03-18 Thread Lorenzo Cattarino
Hi R users, Working from a PC, I am trying to install the spatstat package on a Unix cluster. I created the following PBS file to send a job array: #!/bin/bash -ue #PBS -m ae #PBS -M my email #PBS -J 1-45 #PBS -A my username #PBS -N job name #PBS -l resources #PBS -l walltime cd

[R] string manipulation

2011-08-25 Thread Lorenzo Cattarino
I R-users, I am trying to find the way to manipulate a character string to select a 4 digit number after some specific word/s. Example: mytext - I do not want the first number 1234, but the second number 5678 Is there any function that allows you to select a certain number of digits (in this

Re: [R] string manipulation

2011-08-25 Thread Lorenzo Cattarino
- From: Steven Kennedy [mailto:stevenkennedy2...@gmail.com] Sent: Friday, 26 August 2011 11:31 AM To: Henrique Dallazuanna Cc: Lorenzo Cattarino; r-help@r-project.org Subject: Re: [R] string manipulation You can split your string, and then only take the first 4 digits after that (this is only

[R] lapply, if statement and concatenating to a list

2011-05-05 Thread Lorenzo Cattarino
Hi R users I was wondering on how to use lapply co when the applied function has a conditional statement and the output is a 'growing' object. See example below: list1 - list('A','B','C') list2 - c() myfun - function(x,list2) { one_elem - x cat('one_elem= ', one_elem, '\n') random -

[R] do not execute newline command

2011-04-05 Thread Lorenzo Cattarino
Hi R-users, To automate the creation of scripts, I converted the code (example below) into a character string and wrote the object to a file: Repeat - myvec - c(1:12) cat('vector= ', myvec, '\n') write (Repeat, 'yourpath/test.R') the problem is that one line of the code is a cat command. In

[R] combining vectors into list

2011-02-02 Thread Lorenzo Cattarino
Hi R users I have these two vectors: Row - sample(1:25, 10) Col - sample(1:25, 10) Is there a way to combine them into a list, whose first component is a vector containing the first element of Row and the first element of Col, the second component is a vector containing the second

[R] automatic coercion to character

2011-02-01 Thread Lorenzo Cattarino
Hi R users I am wondering how I can avoid automatic coercion of my numeric vector elements to character init - c(age='N', R=as.numeric(0.5), S=as.numeric(0.8)) I have used as.numeric() but it does not seem to work Thank you Lorenzo [[alternative HTML version deleted]]

[R] get list index

2010-11-25 Thread Lorenzo Cattarino
): [[2]] [1] 0.28 0.45 0.59 0.69 0.80 0.87 0.95 0.94 0.98 and the position of course 2. I am looking for the index because I would like to subset the list afterwards (e.g. mylist[[2]]) and extract that element (i.e. the whole vector). Thanks for your help Lorenzo Lorenzo Cattarino PhD

[R] convergence message SE calculation when using optim( )

2010-11-09 Thread Lorenzo Cattarino
Hi R-users, I am trying to estimate function parameters using optim(). My count observations follows a Poisson like distribution. The problem is that I wanna express the lambda coefficient, in the passion likelihood function, as a linear function of other covariates (and thus of other

Re: [R] memory allocation problem

2010-11-03 Thread Lorenzo Cattarino
: Lorenzo Cattarino Sent: Wednesday, 3 November 2010 2:22 PM To: 'David Winsemius'; 'Peter Langfelder' Cc: r-help@r-project.org Subject: RE: [R] memory allocation problem Thanks for all your suggestions, This is what I get after removing all the other (not useful) objects and run my code: getsizes

Re: [R] memory allocation problem

2010-11-03 Thread Lorenzo Cattarino
-Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Wednesday, 3 November 2010 12:48 PM To: Lorenzo Cattarino Cc: r-help@r-project.org Subject: Re: [R] memory allocation problem Restart your computer. (Yeah, I know that what the help-desk always says.) Start R before

[R] memory allocation problem

2010-11-02 Thread Lorenzo Cattarino
I forgot to mention that I am using windows 7 (64-bit) and the R version 2.11.1 (64-bit) Thank you Lorenzo From: Lorenzo Cattarino Sent: Wednesday, 3 November 2010 10:52 AM To: r-help@r-project.org Subject: memory allocation problem Hi R users I am trying to run a non linear

[R] memory allocation problem

2010-11-02 Thread Lorenzo Cattarino
Hi R users I am trying to run a non linear parameter optimization using the function optim() and I have problems regarding memory allocation. My data are in a dataframe with 9 columns. There are 656100 rows. head(org_results) comb.id p H1 H2 Range Rep no.steps dist

[R] memory allocation problem

2010-11-02 Thread Lorenzo Cattarino
in the target path), is that right? Thank you a lot Lorenzo From: Lorenzo Cattarino Sent: Wednesday, 3 November 2010 10:55 AM To: 'r-help@r-project.org' Subject: memory allocation problem I forgot to mention that I am using windows 7 (64-bit) and the R version 2.11.1 (64-bit

[R] GAM function in mgcv package

2010-10-26 Thread Lorenzo Cattarino
Hi R-users I am trying to use the GAM function of the mgcv package. But I am having problem trying to specify the k parameter. Although I managed to run some models by giving to the parameter some (random) value, and it is explained by Wood (2006) that it does not seem to really affect the

[R] bind matrices by row

2010-10-22 Thread Lorenzo Cattarino
Hi R-users I have a series of matrices and I would like to bind them together by column using a loop (i.e. not writing cbind(matrix1, matrix2,matrix3)). The reason is because in my real data set I have a very large number of matrices. Example: matrix1 - matrix (1:12,4,3) matrix2 -

Re: [R] paste an unevaluated expression

2010-10-18 Thread Lorenzo Cattarino
/uqlcatta/pbs/result1.RData'))) path - '//atlas2/Research/Lorenzo Cattarino/PhD/myR/R_laboratory/' output - paste(path, object.result, sep = ) write(paste(Apply,Save), paste(output, 'R', sep = .)) Start - Start + 120 End - End + 120 } As you can see, apart from an extremely repetitive

[R] paste an unevaluated expression

2010-10-17 Thread Lorenzo Cattarino
Hi R-users, I would like to create an expression without evaluating it. Then paste that expression to an object. Example: Result - paste('Result', 1, sep=) paste(Result, substitute(apply(exp.des[1:10,], 1, one.row, parms=parameters)), sep=-) However this pastes EACH element of the

[R] running R script on linux server

2010-10-11 Thread Lorenzo Cattarino
Hi R-users, I have a problem running my R code on a Linux cluster. What I did was write a .pbs file to instruct the cluster on what to do and how: #!/bin/sh #PBS -m ae #PBS -M uqlca...@uq.edu.au #PBS -A uq-CSER #PBS -N job1_lollo #PBS -l select=1:ncpus=1:NodeType=fast:mem=8GB

[R] accessing elements located after $ symbol

2010-10-05 Thread Lorenzo Cattarino
Hi R-users I am having troubles accessing elements after the $ symbol. Reproducible example: test - data.frame (first=1:10, second=11:20, third=21:30) test$first #this works fine but when I try interest - first test$interest # does not seem to work Could you tell me why that

[R] name ONLY one column

2010-09-27 Thread Lorenzo Cattarino
Hi R-users I can not change the name of one column only of my matrix. my_matrix - matrix (1:12,ncol=3) colnames(my_matrix)[1] - 'myname' Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent thank you for your help Lorenzo

[R] extracting random effects from model formula

2010-09-22 Thread Lorenzo Cattarino
Hi R-users I would like to extract the random effects (1|SITE, 1+SPECIES|SITE and BA|SITE) from this model formula: Full_model - formula (VAR ~ (1|SITE) + (1+SPECIES|SITE) + (BA|SITE) + HEIGHT + COND + NN_DIST) I tried: terms(Full_model) labels(terms(Full_model)) but I could

[R] extracting random effects from model formula

2010-09-22 Thread Lorenzo Cattarino
). Thanks Lorenzo From: Lorenzo Cattarino Sent: Wednesday, 22 September 2010 5:23 PM To: r-help@r-project.org Subject: extracting random effects from model formula Hi R-users I would like to extract the random effects (1|SITE, 1+SPECIES|SITE and BA|SITE) from this model formula

Re: [R] extracting random effects from model formula

2010-09-22 Thread Lorenzo Cattarino
actually I need to extract the random effect from the formula, not the model any idea? From: Sacha Viquerat [mailto:sacha.v...@googlemail.com] Sent: Wed 22/09/2010 5:55 PM To: Lorenzo Cattarino Subject: Re: [R] extracting random effects from model formula Am

[R] sum of some matrix columns

2010-08-29 Thread Lorenzo Cattarino
Hi, I have the following matrix cc - matrix (1:21, 3) cc[,3:4]- 0 cc [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,]1400 13 16 19 [2,]2500 14 17 20 [3,]3600 15 18 21 and I would like to sum just the values in columns

[R] storing the results of an apply call

2010-08-11 Thread Lorenzo Cattarino
with the three groups of five values. Many thanks Lorenzo Lorenzo Cattarino PhD Candidate (Confirmed) Landscape Ecology and Conservation Group Centre for Spatial Environmental Research School of Geography, Planning and Environmental Management The University of Queensland Brisbane

[R] modifying vector elements

2010-07-13 Thread Lorenzo Cattarino
forth. Thanks Lorenzo Lorenzo Cattarino PhD Candidate (Confirmed) Landscape Ecology and Conservation Group Centre for Spatial Environmental Research School of Geography, Planning and Environmental Management The University of Queensland Brisbane, Queensland, 4072, Australia

[R] applying quantile to a list using values of another object as probs

2010-05-17 Thread Lorenzo Cattarino
Hi r-users, I have a matrix B and a list of 3x3 matrices (mylist). I want to calculate the quantiles in the list using each of the value of B as probabilities. The codes I wrote are: B - matrix (runif(12, 0, 1), 3, 4) mylist - lapply(mylist, function(x) {matrix (rnorm(9), 3, 3)}) for

Re: [R] applying quantile to a list using values of another object as probs

2010-05-17 Thread Lorenzo Cattarino
Hi Jim, Thanks for your reply. Your codes does work but I was hoping to find a way to use lapply and avoid the for loop. Lorenzo -Original Message- From: Jim Lemon [mailto:j...@bitwrit.com.au] Sent: Monday, 17 May 2010 8:27 PM To: Lorenzo Cattarino Cc: r-help@r-project.org Subject: Re

Re: [R] applying quantile to a list using values of another object as probs

2010-05-17 Thread Lorenzo Cattarino
[mailto:jorgeivanve...@gmail.com] Sent: Tuesday, 18 May 2010 12:37 PM To: Lorenzo Cattarino Subject: Re: [R] applying quantile to a list using values of another object as probs Hi Lorenzo, How about this? lapply(1:length(mylist), function(i) quantile(mylist[[i]], probs = B[i,])) HTH, Jorge