[R] remove component from list or data frame
Sarah Goslee
sarah.goslee at gmail.com
Thu Feb 8 19:03:18 CET 2007
Hi Jason,
On 2/8/07, Jason Horn <jhorn at bu.edu> wrote:
> Sorry to ask such a simple question, but I can't find the answer after
> extensive searching the docs and the web.
>
> How do you remove a component from a list? For example say you have:
You use the - operator for both your vector and data frame
examples.
> lst <- c(5,6,7,8,9)
# which by the way isn't a list
> is.list(lst)
[1] FALSE
> lst
[1] 5 6 7 8 9
> lst <- lst[-3]
> lst
[1] 5 6 8 9
> lst1<-c(1,2,3,4,5)
> lst2<-c(6,7,8,9,10)
> frame<-data.frame(lst1,lst2)
> frame
lst1 lst2
1 1 6
2 2 7
3 3 8
4 4 9
5 5 10
> frame[-2,]
lst1 lst2
1 1 6
3 3 8
4 4 9
5 5 10
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list