Re: [R] pasting a formula string with double quotes in it

2012-04-20 Thread StellathePug
15:06 -0700 > From: ml-node+s789695n457488...@n4.nabble.com > To: ritacarre...@hotmail.com > Subject: Re: pasting a formula string with double quotes in it > > Hello, > > StellathePug wrote > Hello everyone, > I have tried several ways of doing this and searched th

[R] pasting a formula string with double quotes in it

2012-04-20 Thread StellathePug
Hello everyone, I have tried several ways of doing this and searched the documentation and help lists and I have been unable to find an answer or even whether it is possible to do it. I am pasting together a formula and I need to insert double quotes around the strings. Here's an example: locati

Re: [R] Weighted Average on More than One Variable in Data Frame

2011-09-21 Thread StellathePug
Thanks Jean, that worked perfectly! Try this sapply(split(df, df$g), function(x) apply(x[, 1:2], 2, weighted.mean, x$w)) Jean StellathePug wrote on 09/21/2011 01:15:33 PM: > > I have a data frame, say df, which has 4 variables, one of which I would > like to use as a grouping va

[R] Weighted Average on More than One Variable in Data Frame

2011-09-21 Thread StellathePug
Dear R Users, I have looked for a solution to the following problem and I have not been able to find it on the archive, through Google or in the R documentation. I have a data frame, say df, which has 4 variables, one of which I would like to use as a grouping variable (g), another one that I woul

Re: [R] Replacing NAs in one variable with values of another variable

2011-08-24 Thread StellathePug
Thank you Dan and Ista! Both of you are correct, I should have used NA rather than "NA" in my example. So the correct code should be: X <-as.data.frame(matrix(c(9, 6, 1, 3, 9, NA, NA,NA,NA,NA, 6, 4, 3,NA, NA, NA, 5, 4, 1, 3), ncol=2)) names(X)<-c("X1","X2") X$X1[

[R] Replacing NAs in one variable with values of another variable

2011-08-23 Thread StellathePug
Hello everyone, I am trying to figure out a way of replacing missing observations in one of the variables of a data frame by values of another variable. For example, assume my data is X X <-as.data.frame(matrix(c(9, 6, 1, 3, 9, "NA", "NA","NA","NA","NA", 6, 4, 3,"NA", "NA", "NA

Re: [R] Loop through each subject

2011-06-28 Thread StellathePug
> for (i in 1:(dat[(unique(dat$Subject)),)] I don't think the order of the parentheses when you open the loop is correct. You have four (s and only three )s. Plus the brackets (square parentheses) seem so be out of order too. If you use RStudio to write your code, when you highlight a parenthe

Re: [R] How do I output all the R-squares of an SUR? summary(fitSUR$eq[[1:4]])$r.squared does not work

2011-06-28 Thread StellathePug
> sapply(fitSUR$eq, function(x) summary(x)$r.squared) > You can abbreviate that to: > sapply(summary(fitSUR)$eq, "[[", "r.squared") This is fantastic! Thanks so much. I had a hunch that it would be something related to the apply family but I am still not very good at using it. Thank you immensel

[R] How do I output all the R-squares of an SUR? summary(fitSUR$eq[[1:4]])$r.squared does not work

2011-06-28 Thread StellathePug
Greetings R Users, I have a system of equations for which I would like to output all the R-squares. Assume there are four equations in my system, the only way I found to output all the R-squares is by calling them out one by one as this: summary(fitSUR$eq[[1]])$r.squared summary(fitSUR$eq[[2]])$r.

[R] What does class "call" mean? How do I make class "formula" into a "call"?

2011-06-25 Thread StellathePug
Hello R Users! I have a list called "tabs" that I would like to have the same structure as my list "eqSystem." The two look like they have the same structure but they are different because when I look at their attributes, class(eqSystem[[1]]) is "call" but class(tabs[[1]]) is "formula". I want to

Re: [R] new to R need urgent help!

2011-06-24 Thread StellathePug
I have taught myself R over the last few months and I learned quite a bit from reading the PDFs that accompany each package, articles on the R Journal (http://journal.r-project.org/) that cover similar problems to mine, and by asking specific questions about code to this list. I also search online