[R] OBS in Column 1
Chuck Cleland
ccleland at optonline.net
Tue Nov 7 17:12:16 CET 2006
Thorsten Muehge wrote:
> Hello R Freaks,
I think it's been a few years since we were last referred to as freaks
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/4433.html).
> is there a way to omit the counts in the first column of a data.frame.
I'm not sure what you mean, but does this help?
> df <- as.data.frame(matrix(rpois(110, 5), ncol=10))
> df
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1 5 3 6 3 4 6 6 5 5 8
2 3 7 7 2 5 2 4 8 2 4
3 4 5 3 10 5 9 4 7 8 3
4 7 5 4 4 3 1 1 3 3 6
5 5 4 4 5 5 4 4 6 6 7
6 2 8 5 6 7 3 6 4 3 4
7 2 6 3 4 6 6 4 7 1 3
8 7 1 5 2 5 4 6 5 3 9
9 4 6 4 5 4 7 5 6 6 5
10 6 2 5 3 2 4 5 5 4 6
11 2 1 8 3 5 4 2 4 4 9
> df[,-1]
V2 V3 V4 V5 V6 V7 V8 V9 V10
1 3 6 3 4 6 6 5 5 8
2 7 7 2 5 2 4 8 2 4
3 5 3 10 5 9 4 7 8 3
4 5 4 4 3 1 1 3 3 6
5 4 4 5 5 4 4 6 6 7
6 8 5 6 7 3 6 4 3 4
7 6 3 4 6 6 4 7 1 3
8 1 5 2 5 4 6 5 3 9
9 6 4 5 4 7 5 6 6 5
10 2 5 3 2 4 5 5 4 6
11 1 8 3 5 4 2 4 4 9
> rowSums(df[,-1])
1 2 3 4 5 6 7 8 9 10 11
46 41 54 30 45 46 40 40 48 36 40
> Thanks a lot for your help
> Thorsten
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list