[R] Creating Vectors

jim holtman
Fri, 30 Jun 2006 23:01:04 -0000

Does this do what you want?  It creates a 'list' with the vectors:


> x <- 'type count
+   0     20
+   1     15
+    0     10
+   1     35
+   0     28
+ '
> x <- read.table(textConnection(x), header=TRUE)
> x
  type count
1    0    20
2    1    15
3    0    10
4    1    35
5    0    28
> type <- split(x$count, x$type)
> type
$`0`
[1] 20 10 28

$`1`
[1] 15 35

> type[['0']]
[1] 20 10 28
> type[['1']]
[1] 15 35
>



On 6/30/06, Raphael Fraser <raphael.fraser@gmail.com>
wrote:
>
> type count
>   0     20
>   1     15
>    0     10
>   1     35
>   0     28
>
> I would like to create two vectors from the data above. For example,
> type1=c(15, 35) and type0 = c(20, 10, 28). Can any one help
>
> Raphael
>
> ______________________________________________
> R-help@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
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]