Re: [R] add zero in front of numbers

2011-04-04 Thread Luis Ridao
Have a look at ?formatC On Mon, Apr 4, 2011 at 11:35 AM, Yan Jiao wrote: > Dear R users, > > I need to add 0 in front of a series of numbers, e.g. 1->001, 19->019, > Is there a fast way of doing that? > > Many thanks > > yan > >[[alternative HTML version deleted]] > > __

Re: [R] How to read only specified columns from a data file

2011-03-16 Thread Luis Ridao
Thanks Sarah. Best, Luis On Wed, Mar 16, 2011 at 1:19 PM, Sarah Goslee wrote: > On Wed, Mar 16, 2011 at 9:07 AM, Luis Ridao wrote: >> This is my code: >> >> mycols <- rep(NULL, 430) ; mycols[c(1,3:5)] <- rep("numeric", 4) ; >> mycols[c(2)] <- rep(&

Re: [R] How to read only specified columns from a data file

2011-03-16 Thread Luis Ridao
in turn based on the code you had proposed. So ... what did you do > to get that result? > > > -- > David. > >> >> Sarah >> >> On Wed, Mar 16, 2011 at 7:54 AM, Luis Ridao wrote: >>> >>> David, >>> >>> Thanks for your ti

Re: [R] How to read only specified columns from a data file

2011-03-16 Thread Luis Ridao
read.table(myfile, skip=2)[,1:5] >> >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> On Behalf Of Luis Ridao >> Sent: Tuesday, March 15, 2011 11:53 AM >> To: r-help@r-project.org >> Subject: [R] How to read

[R] How to read only specified columns from a data file

2011-03-15 Thread Luis Ridao
R-help, I'm trying to read a data file with plenty of columns. I just need the first 5 but it doe not work by doing something like: > mycols <- rep(NULL, 430) ; mycols[c(1:4)] <- NA > read.table(myfile, skip=2, colClasses=mycols) Any suggestions? Thanks in advance _

[R] update not working

2011-02-02 Thread Luis Ridao
R-help, I'm using the "update" command for a multiple regression model and it is just not working: > update(model1, . ~ . – temp:wind:rad,data=ozone.pollution) Error: unexpected input in "model2<-update(model1, . ~ . –" > summary(model1) Call: lm(formula = ozone ~ temp * wind * rad + I(rad^2) +

[R] removing indexing

2010-11-04 Thread Luis Ridao
R-help, I was wondering how to remove indexing from an output, e.g., > aVector<-1:10 > aVector [1] 1 2 3 4 5 6 7 8 9 10 > someFunction(aVector) 1 2 3 4 5 6 7 8 9 10 Thanks in advance [[alternative HTML version deleted]] __

[R] Unable to load an object

2010-06-11 Thread Luis Ridao Cruz
R-help, I seem not to get an object saved neither with ".RData" extension nor output via dput. Whenever I try to import the above object in another worspace I just get nothing. > geoFeatures <- load("geoFeatures.RData") > geoFeatures [1] "geoFeatures" The "geoFeatures.RData" workspace contain

[R] Sort a data frame according to romans

2009-12-08 Thread Luis Ridao Cruz
R-help, I have a data frame: > mydata strata nh NhWhfh 1 I 10 26 0.048 0.385 2 II 32 84 0.154 0.381 3 III 16 42 0.077 0.381 4 IV 4 11 0.020 0.364 5 V 10 26 0.048 0.385 7 VII 64 168 0.309 0.381 8VIII 49 129 0.237 0.380 9 IX 22 58 0.107 0.37

[R] could not find function lapply<-

2009-12-08 Thread Luis Ridao Cruz
R-help, I have a list whose elements are data frames. I want to change the colnames attribute in each element of this list but an error message comes up: > lapply(LD_strataNew,function(x) dimnames(x)[[2]][-1]) <- as.roman(1:9)[-6] Error in lapply(LD_strataNew, function(x) dimnames(x)[[2]][-1]) <

[R] Optim(...) estimate of stDev far too low

2009-09-30 Thread Luis Ridao Cruz
R-help, I'm just trying to find the ML (maximum likelihood) estimates of the mean and standard deviation of a set of observations: >xx=c(2.5,3.5,4,6,6.5,7.5) fn<-function(params,x=xx) { media<-params[1] st <-params[2] pdf=-sum(dnorm(log(xx),log(media),st,TRUE)) return(pdf) } optim(c(mu,stdev

[R] Maximum likelihood estimation of parameters make no biological sense

2009-09-24 Thread Luis Ridao Cruz
R-help, I'm trying to estimate some parameters using the Maximum Likehood method. The model describes fish growth using a sigmoidal-type of curve: fn_w <- function(params) { Winf <- params[1] k <- params[2] t0 <- params[3] b <- params[4]

[R] Error: C stack usage is too close to the limit

2009-09-14 Thread Luis Ridao Cruz
R-help, I 'm trying to optimize a model to data using log-likelihoods but I encounter the following error message: > l= c(49.4, 57.7,64.8,70.9,78.7,86.6,88.3,91.6,99,115) > t=3:12 > fn <- function(params, l=l, t=t) { Linf <- params[1] k <- params[2]

[R] cannot upgrade to R 2.9.1 in Ubuntu

2009-08-07 Thread Luis Ridao Cruz
R-help, At the moment the R version installed on my machine is 2.8.1. (Ubuntu 9.04) I wish to upgrade to R 2.9.1. I did: $ sudo apt-get upgrade ..but R is not upgraded although the "sources.list" file is updated with: deb http://cran.ii.uib.no/bin/linux/ubuntu jaunty/ When I run from the term

[R] RODBC package to connect to Oracle database Linux

2009-08-04 Thread Luis Ridao Cruz
t on this I would need also help as there is no example on Oracle drivers (just MySql, PostgreSQLt) Thanks in advance Luis Ridao Cruz Faroe Marine Research Institute Nóatún 1, P.O. Box 3051 FO-110 Tórshavn Faroe Islands Tel : (+298

[R] Oracle ODBC driver for Linux

2009-08-04 Thread Luis Ridao Cruz
R-help, I get the following error message when trying to connect to an Oracle database through R (2.8.1) under Linux (Ubuntu 9.04). > channel<-odbcConnect("magnus",uid="luisr",pwd="juanayzakarias") Warning messages: 1: In odbcDriverConnect(st, ...) : [RODBC] ERROR: state IM002, code 0, message

[R] Problem installing RODBC package under UBUNTU

2009-06-24 Thread Luis Ridao Cruz
R-help, I'm now on the process of installing RODBC on UBUNTU but an error occured. I copy-paste the output: > install.packages("RODBC") Warning in install.packages("RODBC") : argument 'lib' is missing: using '/home/luisridaocruz/R/x86_64-pc-linux-gnu-library/2.8' trying URL 'http://cran.ii.uib

[R] rgdal package -- Error in installing package

2009-06-24 Thread Luis Ridao Cruz
R-help, I'm trying to install the rgdal package under Ubuntu but I get the following warning: > install.packages("rgdal") Warning in install.packages("rgdal", configure.args = "--with-gdal-modules=/usr/local/lib") : argument 'lib' is missing: using '/home/luisridaocruz/R/x86_64-pc-linux-gnu-

[R] R under Ubuntu

2009-05-26 Thread Luis Ridao Cruz
R-help, I have installed R under Ubuntu and I'm very new to a Linux distribution. To open an empty R session I just type R on the Terminal aplication. But how can I open a saved workspace? At present I just start R and then load ("my_workspace") but it must be possible to do it all at oncer

Re: [R] RES: set a legend with an "image" graph

2009-03-17 Thread Luis Ridao Cruz
R-help, I'm sorry that I said " I don't have idea ". What I mean t is that I just don't know how to set a legend when "image" is called. Thanks in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] set a legend with an "image" graph

2009-03-17 Thread Luis Ridao Cruz
R-help, I have an image plot and I wish to set a legend to it but I don't have an idea how to do it. Below it's the code line. image(yyy, col = rev(heat.colors(10)), axes = T) Thanks in advance. __ R-help@r-project.org mailing list https://stat.ethz.c

[R] distance betwenn axis and axis annotation

2009-02-18 Thread Luis Ridao Cruz
R-help, How can I specify the distance between the axis and axis annotation? Thanks in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htm

[R] Alternate looping

2009-01-06 Thread Luis Ridao Cruz
R-help, I'm using the "for" control flow to graph plots continuously: par(mfrow=c(3,5), mar=c(0.6,.2,1.2,.2),yaxt="n",xaxt="n") for(j in 1:11) { for(i in 1:15) { species <- spAldur[spAldur$ar == 1993+i & spAldur$aldur == j,] plot(spec...@coords[,1], spec...@coords[,2], xlim=c(-10,-3.5),

[R] savePlot() does not save plot with format set

2008-08-26 Thread Luis Ridao Cruz
R-help, Whenever I try to save a plot with "savePlot" the file is not stored in my hard disk with the selected format. Several formats are set and none of them works. I just get the file name with missing extension and it can't be open with programs like Paint and Microsoft Photo Editor Th only on

[R] "remove.packages" gives error message

2008-04-02 Thread Luis Ridao Cruz
R-help, I'm trying to remove some packages with the command "remove.packages" but R 2.4.1 will come out with this: > remove.packages(pkgs="FLAssess", lib = "C:\\Program Files\\R\\R-2.4.1\\library\\FLAssess") Error in .find.package(pkgs, lib) : there is no package called 'FLAssess' Thanks in adv

[R] equivalent of excel "sumif"

2008-03-04 Thread Luis Ridao Cruz
R-help, I have two data frames df1 and df2: >head(df1) lgdcm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0

[R] data manipulation

2008-02-29 Thread Luis Ridao Cruz
R-help, I have a data frame in which I compute maximum by rows and I wish to find out the column name at which this maximun occurs. Does anyone know how to do it? Thanks in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/list

[R] shaded area graph and extra plot

2008-02-14 Thread Luis Ridao Cruz
R-help, I'm using the code below to plot a shaded area graph. At the same time I want to plot a second series on the y-axis (from par(new=T) on) but as the two series have different x-axis range (first 1994:2007 and second 1996:2007) the corresponding x's do not match. How can this be sorted ou

[R] shaded area graph and extra plot

2008-02-12 Thread Luis Ridao Cruz
R-help, I'm using the code below to plot a shaded area graph. At the same time I want to plot a second series on the y-axis (from par(new=T) on) but as the two series have different x-axis range (first 1994:2007 and second 1996:2007) the corresponding x's do not match. How can this be sorted ou

[R] sort a data frame according to roman characters

2008-02-12 Thread Luis Ridao Cruz
R-help, I have a data frame with one column containing roman numbers The data are not sorted as : III III IV VVI VII VIII IX XXI XII XIII XIV XV Using data[order(data$Roman),] does not do the job. How can this be done? Thanks in advance. __

[R] function code

2008-01-25 Thread Luis Ridao Cruz
R-help, Sorry for this question (I guess it has been addressed before but I could not find it in the archives) but how can I see a function code when the following comes up: > svymean function (x, design, na.rm = FALSE, ...) { .svycheck(design) UseMethod("svymean", design) } Thanks i

[R] reduce the code used by "for"

2007-12-04 Thread Luis Ridao Cruz
R-help, I have a 3-way array: > dim(bugvinP) [1] 13 14 3 The array looks something like this (object trimmed for readability) , , slag = 1 ar 1994 1995 1996 1997 1998 1 NA 0.000 0.000 0.000 0.000 2 0.036 0.059 0.027 0.000 0.000 3 0.276 0.475 0.491 0.510 0.559 10 1.0

[R] Fail to open R 2.6.1 - additional information

2007-11-28 Thread Luis Ridao Cruz
This is additional information to my previous email (pasted below) ## I opened an R session ( R 2.6.0 on Windows) and got the following pop-up window: ## "This application has failed to start because tk84.dll was not found. Re-installing the application may fix the problem" ## I have now upgr

[R] Fail to open R 2.6.1

2007-11-28 Thread Luis Ridao Cruz
R-help, I opened an R session ( R 2.6.0 on Windows) and got the following pop-up window: "This application has failed to start because tk84.dll was not found. Re-installing the application may fix the problem" I have now upgraded to R 2.6.1 but the same fatal error comes up. Can someone let me

[R] print " character

2007-11-20 Thread Luis Ridao Cruz
R-help, Sorry if this question has been discussed/posted before but I can't just find it myself. How can I print the comment character (") ? Thanks in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] Unable to save plot as ".pdf" , "ps" , "eps"

2007-11-15 Thread Luis Ridao Cruz
R-help, Whenever I try to save a plot with extension ".pdf" , "ps" or "eps" I get the following error/warning message: plot(rnorm(10)) savePlot("test",type="pdf") Error in savePlot("test", type = "pdf") : Invalid font type In addition: Warning messages: 1: In savePlot("test", type = "pdf") : f

[R] manipulating 3-way array

2007-10-18 Thread Luis Ridao Cruz
R-Help, I have a 3 dimensional array with dimensions: > dim(test) [1] 241 104 12 I copy-paste an example of the object > test[1:5,1:5,1:2] , , ar = 1996 slagnr puntar12 34 5 I1 60.30303 36.50610 0 0.0 0 I10 58.19512 35.48209 0 75.0 0 I11 0.