[R] problems trying to reproduce structural equation model using the sem package

2010-09-16 Thread Gustavo Carvalho
Hello, I've been unsuccessfully trying to reproduce a sem from Grace et al. (2010) published in Ecological Monographs: http://www.esajournals.org/doi/pdf/10.1890/09-0464.1 The model in question is presented in Figure 8, page 81. The errors that I've been getting are: 1. Using a correlation matr

Re: [R] Finding (Ordered Subvectors)

2010-09-21 Thread Gustavo Carvalho
This function might be helpful: bleh <- function(a, b) { where <- list() matches <- 0 first <- which(a == b[1]) for (i in first) { seq.to.match <- seq(i, length = length(b)) if (identical(a[seq.to.match], b)) { matches <- matches + 1 where[[matches]] <- seq.to.match

[R] looking for a faster way to compare two columns of a matrix

2010-09-23 Thread Gustavo Carvalho
Please consider this matrix: x <- structure(c(5, 4, 3, 2, 1, 6, 3, 2, 1, 0, 3, 2, 1, 0, 0, 2, 1, 1, 0, 0, 2, 0, 0, 0, 0), .Dim = c(5L, 5L)) For each pair of columns, I want to calculate the proportion of entries different than 0 in column j (i > j) that have lower values than the entries in the s

Re: [R] the first. from SAS in R

2010-11-23 Thread Gustavo Carvalho
Perhaps something like this: a$d <- ifelse(duplicated(a$a), 0, 1) On Tue, Nov 23, 2010 at 1:33 PM, Joel wrote: > > Is there any similar function in R to the first. in SAS? > > What it dose is: > > Lets say we have this table: > >  a b  c >  1 1  5 >  1 0  2 >  2 0  2 >  2 0 NA >  2 9  2 >  3 1  

Re: [R] Is there an implementation for "URL Encoding" (/format) in R?

2010-11-25 Thread Gustavo Carvalho
?URLencode On Thu, Nov 25, 2010 at 3:53 PM, Tal Galili wrote: > Hello all, > > I would like some R function that can translate a string to a "URL encoding" > (see here: http://www.w3schools.com/tags/ref_urlencode.asp) > > Is it implemented? (I wasn't able to find any reference to it) > > Thanks,

Re: [R] How to call an external program/web page under R for Mac OS?

2011-05-24 Thread Gustavo Carvalho
To open a website on the default browser: system("open http://www.google.com";) Gustavo. On Tue, May 24, 2011 at 7:56 PM, jbrezmes wrote: > I would like to be able to call external programs such as Java scripts (*.jar > files) or bring up the browser to a given direction. Can that be done from

Re: [R] Incorrect degrees of freedom in SEM model using lavaan

2011-03-17 Thread Gustavo Carvalho
Your model is saturated. I think lavaan calculates the number of degrees of freedom this way: DF = n*(n + 1)/2 - t - n.fix*(n.fix + 1)/2 n = number of variables t = number of free parameters n.fix = number of fixed exogenous variables So, if you fix the exogenous variables, as in mimic = "Mplus

Re: [R] confirmatory factor analysis program in R

2011-03-20 Thread Gustavo Carvalho
Search for lavaan, sem, and OpenMx. On Mon, Mar 21, 2011 at 12:34 AM, rvohen wrote: > thank you !  I will try it ! > > -- > View this message in context: > http://r.789695.n4.nabble.com/confirmatory-factor-analysis-program-in-R-tp3386133p3392279.html > Sent from the R help mailing list archive a

Re: [R] Find number of elements less than some number: Elegant/fast solution needed

2011-04-14 Thread Gustavo Carvalho
This might be a bit quicker with larger vectors: f <- function(x, y) sum(x > y) vf <- Vectorize(f, "x") vf(x, y) On Thu, Apr 14, 2011 at 5:37 PM, Marc Schwartz wrote: > On Apr 14, 2011, at 2:34 PM, Kevin Ummel wrote: > >> Take vector x and a subset y: >> >> x=1:10 >> >> y=c(4,5,7,9) >> >> For ea

Re: [R] Help: extrac the first entry for each component of a list

2011-08-23 Thread Gustavo Carvalho
sapply(a, `[`, 1) On Wed, Aug 24, 2011 at 12:18 AM, Chee Chen wrote: > Dear All, > I would like to know, beside writing a function and then apply it to a list, > or using a for loop, whether there is a one-line command to do the following. > Suppose we have a list, each of whose components are n

Re: [R] Chemical Names in Data Frames

2011-09-02 Thread Gustavo Carvalho
?make.names perhaps. On Fri, Sep 2, 2011 at 4:13 PM, Durant, James T. (ATSDR/DTEM/PRMSB) wrote: > Greetings - > > I am working on some data that contain chemical names with air > concentrations, and I am creating a data frame with date/time and each > chemical having its own column. However, th

Re: [R] Conditional Counting with Table

2008-12-23 Thread Gustavo Carvalho
Hello, Something like this should work: table(test$V1[!test$V2 %in% c("NM","QC")]) Cheers, Gustavo. On Wed, Dec 24, 2008 at 3:06 AM, Gundala Viswanath wrote: > Dear all, > > I have the following data frame: > > V1 V2 > aaachr1 > aaachr2 > aaaNM > aaaQC > aaachr10 > att

Re: [R] remove columns containing all zeros (or other value)

2009-01-14 Thread Gustavo Carvalho
You can also try this: x[,-(which(colSums(x) == 0))] Cheers, Gustavo. On Wed, Jan 14, 2009 at 8:01 PM, Anthony Dick wrote: > Hello- > > I would like to remove the columns of a matrix that contain all zeros. For > example, from > x<-matrix(c(1,5,3,2,1,4,0,0,0), ncol=3,nrow=3) > > I would like t

Re: [R] remove columns containing all zeros (or other value)

2009-01-14 Thread Gustavo Carvalho
Sorry for the double post, but this is probably faster: x[, colSums(x) != 0] On Wed, Jan 14, 2009 at 8:22 PM, Gustavo Carvalho wrote: > You can also try this: > > x[,-(which(colSums(x) == 0))] > > Cheers, > > Gustavo. > > On Wed, Jan 14, 2009 at 8:01 PM, Anthony Dic

Re: [R] Logical function to turn missing values to 0's

2009-01-14 Thread Gustavo Carvalho
Hello rafamoral, Try this: ifelse(is.na(x),0,x) On Wed, Jan 14, 2009 at 8:32 PM, rafamoral wrote: > > I have a dataset which contains some missing values, and I need to replace > them with zeros. I tried using the following: > > x <- matrix(data=rep(c(1,2,3,NA),6), ncol=6, nrow=6) > > y <- matr

Re: [R] Problem with the Linux R 2.8.0 rpm for 64 bit REL 4

2008-11-18 Thread Gustavo Carvalho
xdg utils is probably not being recognized because you compiled it from source. The R rpm is looking for the xdg utils package. I'm not familiar with yum, but I think you can try to force the installation: rpm -ivh --force (or something like that) /data/R-2.8.0-1.rh4.x86_64.rpm On Tue, Nov 18, 20

Re: [R] Checking collinearity using lmer

2008-11-19 Thread Gustavo Carvalho
Take a look at vif in the package car. On Wed, Nov 19, 2008 at 10:00 PM, Crystal McRae <[EMAIL PROTECTED]> wrote: > > > I am running a logistic regression model with a random effect using lmer. I > am uncertain how to check for collinearity between my parameters. I have > already run cor() an

Re: [R] R course in Scotland

2008-11-20 Thread Gustavo Carvalho
Hello, Take a look at this course: http://www.r4all.group.shef.ac.uk/index.html I don't think they teach tools for working with the genome, but it might be helpful anyway. On Thu, Nov 20, 2008 at 11:16 AM, Peter Saffrey <[EMAIL PROTECTED]> wrote: > (apologies if this is the wrong list) > > I'm

Re: [R] if then statement problem

2008-11-27 Thread Gustavo Carvalho
If I understood your problem correctly, you are just missing a couple of things: q = which(apply(p.unique,2,function(x)all(x==r)) == TRUE) Also, you should probably change this line: if(q>0){c=p.unique[,q]};{c=c(0,0,0)} To something like this: if(length(q)>0){c=p.unique[,q]};{c=c(0,0,0)} Rega

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Gustavo Carvalho
Is there a way to list only the files in a given directory without passing pattern="..." to list.files()? On Fri, Dec 5, 2008 at 5:10 PM, Kyle. <[EMAIL PROTECTED]> wrote: > Thanks, Barry. I'll use that in the future. > > > ---Kyle. > > On Fri, Dec 5, 2008 at 11:01 AM, Barry Rowlingson < > [EMAIL P

Re: [R] Running R Script on a Sequence of Files

2008-12-06 Thread Gustavo Carvalho
Thanks a lot! On Fri, Dec 5, 2008 at 5:54 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this: > > dir()[!file.info(dir())$isdir] > > > On Fri, Dec 5, 2008 at 2:30 PM, Gustavo Carvalho > <[EMAIL PROTECTED]> wrote: >> Is there a way to list only

[R] extract the digits of a number

2008-12-09 Thread Gustavo Carvalho
Hello, Anyone knows how can I do this in a cleaner way? mynumber = 1001 as.numeric(unlist(strsplit(as.character(mynumber),""))) [1] 1 0 0 1 Thanks in advance, Gustavo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P

Re: [R] == operand

2008-12-09 Thread Gustavo Carvalho
Hello, You assigned 53 to c, not cc. Also, take a look at this: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f On Tue, Dec 9, 2008 at 9:36 PM, Renny Li <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to compare two values using "==" operand, p

Re: [R] Logical inconsistency

2008-12-10 Thread Gustavo Carvalho
Hello, An alternative to round(): isTRUE(all.equal((2.3-1.3),1)) Regards, Gustavo. On Wed, Dec 10, 2008 at 3:12 PM, Stephan Kolassa <[EMAIL PROTECTED]> wrote: > Hi Emma, > > unfortunately, rounding variables before taking the difference will not > solve your problem, because the *rounded* vari

Re: [R] Logical "in" test

2008-12-11 Thread Gustavo Carvalho
Take a look at ?any. On Thu, Dec 11, 2008 at 3:11 PM, David B. Thompson, Ph.D., P.E., D.WRE, CFM <[EMAIL PROTECTED]> wrote: > OK, this should be trivial but I'm not finding it. I want to compress the > test, > > if (i==7 | i==10 | i==30 | i==50) {} > > into something like > > if (i in c(7,10,30,50

Re: [R] Reading from Google Docs

2008-12-15 Thread Gustavo Carvalho
Hello, You can probably extract a .tar.gz using 7zip on Windows. Regards, Gustavo. On Mon, Dec 15, 2008 at 8:07 PM, Farrel Buchinsky wrote: > I saw a thread from September 24 in which Duncan Temple Lang told us: > - The package currently has no Rd files, but there is a brief "user's > guide".

Re: [R] Editor for R under Fedora 7

2007-09-11 Thread Gustavo Carvalho
Fedora 7 is a linux distribution On 9/11/07, Paul Smith <[EMAIL PROTECTED]> wrote: > On 9/11/07, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > I wanted to ask what will be a good editor to write R scripts in Fedora 7. > > Tell us first what is your operating system. > > Paul > > _