[R] reading data rows
p.pagel at gsf.de
Thu Nov 20 20:47:31 CET 2003
On Thu, Nov 20, 2003 at 10:21:49AM -0800, forkusam wrote:
> I have problems reading a file with more than one row
> to carry out mathematical calculations
> I have a a file of the form
> mu1 mu2 alpha beta Wsigma sigmaA b r
> 25 15 .05 .05 22 3 .3 .5
> 30 20 .1 .2 22 .3 .3 .5
> I intend to read one row , carry out the calculations
> and then the next row with which I intend to do the
> same calculations.
Although you can read the file line by line I guess you actually want to
read the whole table and then perform your calculations on the resulting
> I do the following.
> p<-read.table(file="eingabe.csv", header=TRUE,sep=";")
Your file is not separated by ';'! From what you show above I guess it's
tab-separated - or maybe by variying numbers of spaces. Assuming tabs
this will read the entire file:
p <- read.table('eingabe.csv', header=T, sep='\t')
I'm totally confused about this. First, p is already a data frame.
Second, the columns are already of type numeric or int after correctly
reading the file - so as.numeric is not needed here. You should
probably read 'An Introduction to R', especially the section on lists
and data frames and the one about reading data from files.
> I intend to use the variables stored in the the data
> frame for my caculations. but each time I try I get
> the followingerror message.
> Error in uniroot(function(n) eval(p.body) - power,
> c(2, 1e+07)) :
> invalid function value in 'zeroin'
> In addition: Warning message:
> the condition has length > 1 and only the first
> element will be used in: if (f(lower, ...) * f(upper,
> ...) >= 0) stop("f() values at end points not of
> opposite sign")
> ...which I do not get when I use just one row.
Since you didn't say what calculation you were attempting I can't even
guess, what is going on. Maybe you can tell us what the goal of all this
is and what commands you were using ...
Dr. Philipp Pagel Tel. +49-89-3187-3675
Institute for Bioinformatics / MIPS Fax. +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
More information about the R-help