由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - How to do 'look up' in R?
相关主题
求问 sas _c_ 什么意思how to get variable names and # of variable names in sas dataset
[合集] 求助,怎样在SAS里读数据的column name?求高人指点一个SAS数据的转换问题
请教一个关于R的问题one quick question about concatenating data in SAS
如何比较两个proc contents的结果?base 123题第109题新的疑惑
请问如何改变 data set's column 位置. 比如name, id 换成id, name.R问题求助。
what is the fastest way of look-up in SAS?求教一个R 的简单问题!
这个DATA如何做TRNASPOSE?R求教
问个SAS 数据处理问题sas programming question
相关话题的讨论汇总
话题: prod话题: 678978话题: 11111话题: 2011话题: 12
进入Statistics版参与讨论
1 (共1页)
n*********e
发帖数: 318
1
I am trying to translate prod id into prod name
Here is data -
#----------------------
customer_id, product_id, date
11111,634578,11/12/2011
11111,987654,11/12/2011
11111,678978,11/12/2011
11111,678978,12/22/2011
22222,456789,12/24/2011
33333,678978,01/10/2012
33333,678978,01/15/2012
44444,987365,03/30/2012
I also has a reference file -
prod_id, prod_name
634578, 'ice-cream'
987654, 'green beans'
678978, 'beef'
...
------------------------------------------------------------
How can I do it in R so that my data will have an additional column 'prod_
name'?
Thanks.
t*****i
发帖数: 426
2
data.frame
n*********e
发帖数: 318
3
what is the thing in R which would be equivalent to -
'map' in Java
'dictionary' in Python
'PROC FORMAT' in SAS
?
t******g
发帖数: 372
4
datanew<-cbind(data, as.character(ref[match(data[, 'prod_id'], ref[,'prod_id
']),'prod_name']))

【在 n*********e 的大作中提到】
: I am trying to translate prod id into prod name
: Here is data -
: #----------------------
: customer_id, product_id, date
: 11111,634578,11/12/2011
: 11111,987654,11/12/2011
: 11111,678978,11/12/2011
: 11111,678978,12/22/2011
: 22222,456789,12/24/2011
: 33333,678978,01/10/2012

s*r
发帖数: 2757
5
R vector can have names
w <- 1:3
names(w) <- c('s','i','r')
w['i']

【在 n*********e 的大作中提到】
: what is the thing in R which would be equivalent to -
: 'map' in Java
: 'dictionary' in Python
: 'PROC FORMAT' in SAS
: ?

1 (共1页)
进入Statistics版参与讨论
相关主题
sas programming question请问如何改变 data set's column 位置. 比如name, id 换成id, name.
在 R 里面如何循环调用变量名what is the fastest way of look-up in SAS?
[R问题]how to make matrix from list (or the other way around)这个DATA如何做TRNASPOSE?
SAS format 的问题问个SAS 数据处理问题
求问 sas _c_ 什么意思how to get variable names and # of variable names in sas dataset
[合集] 求助,怎样在SAS里读数据的column name?求高人指点一个SAS数据的转换问题
请教一个关于R的问题one quick question about concatenating data in SAS
如何比较两个proc contents的结果?base 123题第109题新的疑惑
相关话题的讨论汇总
话题: prod话题: 678978话题: 11111话题: 2011话题: 12