[R] Problem with rbinom

Greg Snow Greg.Snow at intermountainmail.org
Tue Oct 3 00:11:32 CEST 2006


Using read.table creates a data frame that you store in dataen, rbinom wants a vector not a data frame, so try:

> rbinom(4857,1,dataen$pd) 

Or 

> rbinom(4857,1,dataen[[1]])

Hope this helps, 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Alexander Geisler
Sent: Monday, October 02, 2006 4:01 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Problem with rbinom

Hello!

I have the following problem: I calculate a variable called pd in Excel, save it as pd.txt, so that it looks like the following:

pd
0.070568471
0.011275136
0.006892258
0.028592432
0.028489582
0.01881913
0.035426606
0.011517305

There were 4857 cases in pd.txt.

After that I start R and load the data through the following command:
daten <- read.table("pd.txt", header=T)

Then I want to execute the function rbinom:

rbinom(4857,1,daten)

I get the following error message:
Fehler in rbinom(n, size, prob) : ungültige Argumente (error in rbinom(n, size, prob) : bad arguments

The problem is daten, because if I excecute rbinom(4857,1,0.5), then it works.

So, I have no idea, what the problem could be.

Alex

--
Alexander Geisler * Moserhofgasse 36/1 * A-8010 Graz StV Technische Mathematik | FakV TMTP
email: alexande at sbox.tugraz.at | ageisler at htu.tugraz.at
phone: +43 650 / 811 61 90

______________________________________________
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.



More information about the R-help mailing list