[R] Creating Vectors

2006-06-30 Thread Raphael Fraser
 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


Re: [R] Creating Vectors

2006-06-30 Thread Alexander Nervedi
Hi all.

I have a factor variable distributed over time. I am looking for an elegant 
way to code duration of a state. Suppose,

rainfall.shocks - factor(sample(c(1,2,3), size = 15, replace = TRUE, prob 
= unit.p),
+  label = c(Drought, Normal, High))

rainfall.shocks
[1] Normal  HighHighDrought Normal  Normal  HighNormal  Drought
[10] Normal  Drought Normal  Normal  Normal  Normal


So capture the duration of say drought, I'd need a variable that is able to 
keep track of rainfall.shocks as well as its past values. I was wondering if 
there is any obvious way to do this. the Drought variable in this case would 
have values

0 0 0 1 0 0 0 0 1 0 1 0 0 0 0

many thanks for the suggestions you are likely to make.

Alexander Nervedi

__
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


Re: [R] Creating Vectors

2006-06-30 Thread jim holtman
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
1020
2115
3010
4135
5028
 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 [EMAIL PROTECTED] 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]]

__
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