[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:

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

2012-04-20 Thread StellathePug
+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 the documentation and help lists and I have been unable to find

[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

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 variable (g

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)

[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, 5, 4, 1, 3),

[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

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 immensely for

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

[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 have

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