Skip to content
Prev 359015 / 398502 Next

Extract row form a dataframe by row names in another vector and factor . Need explanation

Hi,Here i have written an example to explain my problem
## Data Generationdat<-data.frame(matrix(1:50,ncol=5))
rownames(dat)<-letters[1:10]
colnames(dat)<- c("SA1","SA2","SA3","SA4","SA5")

dat1<-data.frame(matrix(letters[1:20],ncol=4))
colnames(dat1)<-c("AA","BB","CC","DD")

## Row names
v1<-dat1[,"BB"] ? ? ? ? ? ? ? ? ? # Factor
v2<-as.vector(dat1[,"BB"]) ?# Vector

is(v1) # Factor
is(v2) # Vector

# Result
res1<-dat[v1,]
res2<-dat[v2,]
##########################################################i assumed res1 and res2 are same .?but it is not .?Can any body please explain why ??
?
?
Tanvir Ahamed 
G?teborg, Sweden??| mashranga at yahoo.com