| To: | s-news@lists.biostat.wustl.edu |
|---|---|
| Subject: | Function with dataframe argument variables.? |
| From: | Mandans <mandans_p@yahoo.com> |
| Date: | Mon, 15 Dec 2008 15:39:47 -0800 (PST) |
| Domainkey-signature: | a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Message-ID; b=xV8MBiYu1cx8COYAC6VqXaZ8dNR0v6L1T0ECFK+4pX5XVNxwtfDF59YHb5JUiN7MuM+wDRvZWTQrYLBmCS6GnUCZC25Ferwfd2IAz0W2nG8u+xDSgSuIRefqjVmW6Gz9lPQ0rJKqpQpTrSJaBo6PBCtdx9zhCFNSPcjwu0hS9lo=; |
| Reply-to: | mandans_p@yahoo.com |
Hi Everyone,
I have quick question regarding writing a function for a dataframe with
arguments called from the dataframe name.
Here is what I am trying to get a simple mean. my question how do address the
Data$Variable1 with an argument Variable passed into the function.?
-------------------------------
VarianceT1 <- function(Data, Variable1) {
if(!is.data.frame(Data))
stop("Data should be a dataframe")
if(dim(Data)[1] != length(Data$Variable1))
stop("Data and Variable1 should be of the same length")
a1 <- mean(Data$Variable1)
return(a1)
}
--------------------------------
Appreciate all your help and thanks for all shared ideas out there on s-news
archive.
Thanks a bunch.
Thanks
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | ANNOUNCE: 2009 John M. Chambers Statistical Software Award, J.R. Lockwood |
|---|---|
| Next by Date: | Re: Function with dataframe argument variables.?, David L Lorenz |
| Previous by Thread: | ANNOUNCE: 2009 John M. Chambers Statistical Software Award, J.R. Lockwood |
| Next by Thread: | Re: Function with dataframe argument variables.?, David L Lorenz |
| Indexes: | [Date] [Thread] [Top] [All Lists] |