Hi, Please use ?dput() to show the data e.g. dput(head(data,20)) Also, your heading and description is a bit confusing. ##Assuming that this is how your data looks like dat <- read.table(text="1 0.1 2 0.5 3 0.7 8 0.01 3 0.2 4 0.5 6 0.3 8 0.1",sep="",header=FALSE) # dput(dat) vec1 <- c("1"=0.1, "2"=1.5,"3"=0.2,"4"=0.1,"6"=0.01,"7"=2,"8"=1) ?dat$V3 <- vec1[as.character(dat$V1)] A.K. Hi I have text file in this format: 1 0.1 ? 2 0.5 ? 3 0.7 ? 8 0.01 3 0.2 ? 4 0.5 6 0.3 ? 8 0.1 . . etc. I want to generate random weight to each individual item (1=0.1, ?2=1.5, ?3=0.2, ?4=0.1, ?6=0.01 ?,7=2 ?,8=1) so the new file will be: 1 0.1 0.1 ? 2 0.5 1.5 ? 3 0.7 0.2 ? 8 0.01 1 3 0.2 0.2 ? 4 0.5 0.1 6 0.3 0.01 ? 8 0.1 1 Thank you.