[R] Difficulty with UNIQUE

Blaser Nello nblaser at ispm.unibe.ch
Fri Mar 15 10:19:31 CET 2013


with(price.lookup, list(Price_Line)) is a list! Use

unique(unlist(with(price.lookup, list(Price_Line))))

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Barry King
Sent: Freitag, 15. März 2013 09:34
To: r-help at r-project.org
Subject: [R] Difficulty with UNIQUE

I need to extract labels from Excel input data to use as dimnames later on.
I can successfully read the Excel data into three matrices:

capacity <- read.csv("c:\\R\\data\\capacity.csv")
price.lookup <- read.csv("c:\\R\\data\\price lookup.csv") sales <- read.csv("c:\\R\\data\\sales.csv")

The values to be used as dimnames are duplicated in the matrices.

For example, I would like to create

dimnames(out.table) [[3]] <- c("a", "b", "c")

by not explicitly entering the first three letters of the alphabet but by something like

dimnames(out.table) [[3]] <- pl.names

but I cannot generate unique values with

> pl.names <- unique(with(price.lookup, list(Price_Line))) pl.names
[[1]]
  [1] a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a c c c c c c c  [44] c c c c c c c c c c c c c c c c c c c c c c c c c c c c c b b b b b b b b b b b b b b  [87] b b b b b b b b b b b b b b b b b b b b b b
Levels: a b c

Can someone please suggest how I can grab "a", "b", "c" from

(with(price.lookup, list(Price_Line))

?

Thank you,


--
__________________________
*Barry E. King, Ph.D.*
Director of Retail Operations
Qualex Consulting Services, Inc.
Barry.King at qlx.com
O: (317)940-5464
M: (317)507-0661
__________________________

	[[alternative HTML version deleted]]

______________________________________________
R-help at 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.



More information about the R-help mailing list