I'm taking a random sample from dataframe (a) I've got. The qualifier a[,1] is to be exported into excel. However I'm in trouble.
str(a)
'data.frame': 2299 obs. of 5 variables:
$ A : Factor w/ 2284 levels "01012223427",..: 1339 78 779 1590 1687 64 1034 633 1321 109
a[sample(a[,1],300),]->q
This results in 300 random samples, but several of them are NA. Any ideas?
q[,1]->r
str(r)
Factor w/ 2284 levels "01012223427",..: 85 1162 1886 549 1996 789 185 321 632 2273
I need to get the r vector in the 01012223427 format into excel, but doing write.csv(r,"r.csv")
results in a file with concactenated 1,"01012223427" etc in every cell for the column. I tried write.csv(as.numeric(r),"r.csv")
to no help with the factors themselves being output. How can I do this?
--edit
write.csv2(r,"300.csv",row.names=F) solved my problems, but I'm still uncertain with regards to why the NA's are introduced...
//M