Displaying 3 results from an estimated 3 matches for "moutier".
Did you mean:
mortier
2007 Jul 12
1
[[.data frame and row names
Hi,
I'm wondering why indexing a data frame by row name doesn't work
with [[. It works with [:
> sw <- swiss[1:5,1:2]
> sw["Moutier", "Agriculture"]
[1] 36.5
but not with [[:
> sw[["Moutier", "Agriculture"]]
Error in .subset2(.subset2(x, ..2), ..1) : subscript out of bounds
The problem is really with the row name (and not the col name) since
this works:
> sw[[4, "Agricul...
2007 Apr 20
2
sorting data in R
...re Examination Education Catholic Infant.Mortality
Courtelary 80.2 17.0 15 12 9.96 22.2
Delemont 83.1 45.1 6 9 84.84 22.2
Franches-Mnt 92.5 39.7 5 5 93.40 20.2
Moutier 85.8 36.5 12 7 33.77 20.3
Neuveville 76.9 43.5 17 15 5.16 20.6
Porrentruy 76.1 35.3 9 7 90.57 26.6
Broye 83.8 70.2 16 7...
2007 Mar 14
0
cannot delete the last column of a dataframe using "[<-" (PR#9565)
...0 <- sw)
Fertility Agriculture Examination Education new1 new2 new3
Courtelary 80.2 17.0 15 12 A a A
Delemont 83.1 45.1 6 9 B b B
Franches-Mnt 92.5 39.7 5 5 C c C
Moutier 85.8 36.5 12 7 D d D
Neuveville 76.9 43.5 17 15 E e E
> # This works:
> sw[6:8] <- list(letters[10:14], NULL, aa=1:5) # delete col7, update 6, append
> # But this doesn't:
> sw <- sw0
> sw[6...