I am reading parameters from an Excel file but am having trouble using them
in tapply.  Here is a mini-version of my problem.
------------------------------------------------------------------------------------------------------------------------------------------------
sorted <- data.frame(c("Single","Single","Double","Double","Double",
"Triple"),
                     c(324.5, 435.3, 568.3, 345.4, 143.5, 563.5))
colnames(sorted) <- c("ITEM","PRICE")

attach(sorted)
sMean <- tapply(PRICE,ITEM,mean)  # works but cannot use column names
directly
                                  # since reading them from an Excel file
into
                                  # a parameter file

Pname <- c("PRICE")
Iname <- c("ITEM")
parameter <- data.frame(Pname,Iname)  # This mimics reading the specific
column names
                                      # from Excel
# Now I want to indirectly reference the PRICE and ITEM columns but this
does
# not work as expected
sMean2 <- tapply(parameter$Pname, parameter$Iname, mean)

-- 

Any  assistance would be greatly appreciated.
__________________________
*Barry E. King, Ph.D.*
Chief Modeler
Qualex Consulting Services, Inc.
barry.k...@qlx.com
O: (317)940-5464
M: (317)507-0661
__________________________

        [[alternative HTML version deleted]]

______________________________________________
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.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to