[R] data frame row manipulation

2007-08-31 Thread Calle
Hello, struggling with the very basic needs... :( any help appreciated. #using the package doBY #who drinks how much beer per day and therefor cannot calculate rowise maxvals evaluation=data.frame(date=c(1,2,3,4,5,6,7,8,9), name=c(Michael,Steve,Bob, Michael,Steve,Bob,Michael,Steve,Bob),

Re: [R] data frame row manipulation

2007-08-31 Thread Gabor Grothendieck
Try this: evaluation$maxVol - ave(evaluation$vol, evaluation$name, FUN = max) or using SQL via sqldf like this: library(sqldf) sqldf(select * from evaluation join (select name, max(vol) from evaluation group by name) using (name)) On 8/31/07, Calle [EMAIL PROTECTED] wrote: Hello,

[R] data frame

2007-04-23 Thread elyakhlifi mustapha
hello, I wanna print something like this Class Levels Values Id_TrT1 1 2 Id_Geno764208 64209 64210 64211 64212 64213 64214 Id_Rep 2 12 Is it possible? I have some problem I think taht

Re: [R] data frame

2007-04-23 Thread Stefan Grosse
how about: ?str ever considered reading an introductory text? find some here: http://cran.r-project.org/other-docs.html Stefan elyakhlifi mustapha wrote: hello, I wanna print something like this Class Levels Values Id_TrT1 1 2 Id_Geno

Re: [R] data frame

2007-04-23 Thread Schmitt, Corinna
, new.info) dat It works. The R console result can be seen in the attachment. CU, Corinna -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von elyakhlifi mustapha Gesendet: Montag, 23. April 2007 16:02 An: R-help@stat.math.ethz.ch Betreff: [R] data

[R] data frame

2007-04-23 Thread Schmitt, Corinna
] data frame hello, I wanna print something like this Class Levels Values Id_TrT1 1 2 Id_Geno764208 64209 64210 64211 64212 64213 64214 Id_Rep 2 12 Is it possible? I have some problem I

Re: [R] data frame

2007-04-23 Thread Gabor Grothendieck
Its not usual to represent structures in this form in R but you can do it if you really want: data.frame(A = letters[1:3], B = 1:3, C = I(list(2, 1:6, 9))) Note the I (capital i) to make sure the list gets passed in asis. On 4/23/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote: hello, I

Re: [R] data-frame adding/deleting column

2007-03-26 Thread Kyle.
This is a slightly different formulation of your problem, but you might find it easier to work with: Start by making a data frame): df=data.frame(Father=c (Fred,Fred,Fred,Barney,Barney),Mother=c (Mary,Mary,Mary,Liz,Liz),Child.Age=c(4,7,9,3,5)) If you want to add a wedding date column

[R] Data frame operations getting slower when accessed by index

2007-02-21 Thread Alp ATICI
I have a data frame called df which has about 100 columns but thousands of rows. I set D the index of df$D and M to be the index of df$M. When I run the following loop as it is vs. df[,D] and df[,M] replaced with df$D and df$M there is a real big time difference in completion (with the latter

Re: [R] Data frame operations getting slower when accessed by index

2007-02-21 Thread Prof Brian Ripley
What are D and M? 'Index' here could be a number or a name. In either case, df[[D]] would be the equivalent of df$D. However, your computation does not need a loop at all, let alone two. Try something like tmp - with(df, paste(D, m)) dates - unique(tmp) On Wed, 21 Feb 2007, Alp ATICI wrote:

[R] Data frame: how to create list of row max?

2007-02-19 Thread Johannes Graumann
Dear all, Can anyone please shed some light onto how to do this? This will give me all intensity columsn in my data frame: intensityindeces - grep(^Intensity,names(dataframe),value=TRUE) This will give me the maximum intensity for the first row: intensityone - max(dataframe[1,intensityindeces])

Re: [R] Data frame: how to create list of row max?

2007-02-19 Thread Chuck Cleland
Johannes Graumann wrote: Dear all, Can anyone please shed some light onto how to do this? This will give me all intensity columsn in my data frame: intensityindeces - grep(^Intensity,names(dataframe),value=TRUE) This will give me the maximum intensity for the first row: intensityone -

Re: [R] Data frame: how to create list of row max?

2007-02-19 Thread Prof Brian Ripley
do.call(pmax, dataframe[,intensityindeces]) if I understand you aright. On Mon, 19 Feb 2007, Johannes Graumann wrote: Dear all, Can anyone please shed some light onto how to do this? This will give me all intensity columsn in my data frame: intensityindeces -

Re: [R] Data frame: how to create list of row max?

2007-02-19 Thread Johannes Graumann
On Monday 19 February 2007 11:53, Prof Brian Ripley wrote: do.call(pmax, dataframe[,intensityindeces]) Thank you very much for your help! Any idea why do.call(pmax,list(na.rm=TRUE),dataframe[,intensityindeces]) would give me Error in if (quote) { : argument is not interpretable as logical In

Re: [R] Data frame: how to create list of row max?

2007-02-19 Thread Prof Brian Ripley
On Mon, 19 Feb 2007, Johannes Graumann wrote: On Monday 19 February 2007 11:53, Prof Brian Ripley wrote: do.call(pmax, dataframe[,intensityindeces]) Thank you very much for your help! Any idea why do.call(pmax,list(na.rm=TRUE),dataframe[,intensityindeces]) You want something like

Re: [R] Data frame: how to create list of row max?

2007-02-19 Thread David Barron
Try do.call(pmax,c(dataframe[,intensityindices],na.rm=TRUE)) This is like the second example in the help page for do.call On 19/02/07, Johannes Graumann [EMAIL PROTECTED] wrote: On Monday 19 February 2007 11:53, Prof Brian Ripley wrote: do.call(pmax, dataframe[,intensityindeces]) Thank you

Re: [R] Data frame: how to create list of row max?

2007-02-19 Thread Johannes Graumann
Thanks to you and Brian Ripley. Quite confusing all this ... Thanks again. Joh On Monday 19 February 2007 13:42, David Barron wrote: Try do.call(pmax,c(dataframe[,intensityindices],na.rm=TRUE)) This is like the second example in the help page for do.call On 19/02/07, Johannes Graumann

[R] Data frame referencing?

2006-08-04 Thread Sander Oom
Dear R users, When you do: x - rnorm(10) y - rnorm(10) z - rnorm(10) a - data.frame(x,y,z) a$x [1] 1.37821893 0.21152756 -0.55453182 -2.10426048 -0.08967880 0.03712110 [7] -0.80592149 0.07413450 0.15557671 1.22165341 Why does this not work: a[a$y0.5,y] -1 Error in

Re: [R] Data frame referencing?

2006-08-04 Thread Gabor Grothendieck
When specifying a column name with [ the name must be quoted (unlike when using it with $): a[a$y 0.5, y] - 1 On 8/4/06, Sander Oom [EMAIL PROTECTED] wrote: Dear R users, When you do: x - rnorm(10) y - rnorm(10) z - rnorm(10) a - data.frame(x,y,z) a$x [1] 1.37821893

Re: [R] Data frame referencing?

2006-08-04 Thread Dimitris Rizopoulos
/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Sander Oom [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, August 04, 2006 1:48 PM Subject: [R] Data frame referencing

Re: [R] Data frame referencing?

2006-08-04 Thread Sander Oom
://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Sander Oom [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, August 04, 2006 1:48 PM Subject: [R] Data frame referencing? Dear R users, When you do: x - rnorm(10) y - rnorm(10) z - rnorm(10

[R] data frame search

2006-06-24 Thread Bart Joosen
Hi, I want to make a data frame which contains the positions of some searched values in another data frame. Like: Dataframe 1: 1 2 3 4 1 2 3 4 2 3 4 1 2 3 4 2 4 1 2 3 2 3 4 1 Let's say I searched on 4, then Dataframe 2 should contain: x y 1 4 1 8 2 3 2 7 3 1 3 7 I

Re: [R] data frame search

2006-06-24 Thread Gabor Grothendieck
Try this: which(DF1 == 4, arr.ind = TRUE) On 6/24/06, Bart Joosen [EMAIL PROTECTED] wrote: Hi, I want to make a data frame which contains the positions of some searched values in another data frame. Like: Dataframe 1: 1 2 3 4 1 2 3 4 2 3 4 1 2 3 4 2 4 1 2 3 2 3 4

Re: [R] data frame search

2006-06-24 Thread Jay Emerson
I'll suggest an algorithm with a little code but haven't actually tried it. R loves vector/matrix operations (and, incidentally, you probably ought to be using matrices here and not data frames, particularly if the images are large). Here is your matrix from your example (I'll call this x) 1 2

Re: [R] data frame search

2006-06-24 Thread Bart Joosen
Thanks, couldn't find this function, Best regards Bart - Original Message - From: Gabor Grothendieck [EMAIL PROTECTED] To: Bart Joosen [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Saturday, June 24, 2006 1:15 PM Subject: Re: [R] data frame search Try this: which(DF1 == 4

Re: [R] data frame search

2006-06-24 Thread Gabor Grothendieck
: Saturday, June 24, 2006 1:15 PM Subject: Re: [R] data frame search Try this: which(DF1 == 4, arr.ind = TRUE) On 6/24/06, Bart Joosen [EMAIL PROTECTED] wrote: Hi, I want to make a data frame which contains the positions of some searched values in another data frame. Like

Re: [R] data frame as X in linear model lm() ?

2006-03-26 Thread Prof Brian Ripley
I guess you are looking for print(summary(lm(y ~ ., data=x.d))) since '.' refers to all the columns of 'data' except perhaps the response. On Sat, 25 Mar 2006, ivo welch wrote: Dear R wizards: This must have an obvious solution, but I am stumped. I can run a linear regression giving

[R] data frame as X in linear model lm() ?

2006-03-25 Thread ivo welch
Dear R wizards: This must have an obvious solution, but I am stumped. I can run a linear regression giving a matrix as the independent set of variables, but if I give a data frame (which I would like to give, because it should tell the linear model the names of the variables), R does not like

Re: [R] data frame as X in linear model lm() ?

2006-03-25 Thread Gabor Grothendieck
Try using dot notation: lm(y ~., x.d) On 3/25/06, ivo welch [EMAIL PROTECTED] wrote: Dear R wizards: This must have an obvious solution, but I am stumped. I can run a linear regression giving a matrix as the independent set of variables, but if I give a data frame (which I would like to

Re: [R] Data frame index?

2006-01-18 Thread Jacques VESLOT
try: DF2 - as.data.frame(matrix(vec, nr=nrow(DF),nc=ncol(DF))== matrix(1:ncol(DF),nr=nrow(DF),nc=ncol(DF),byrow=T)) DF3 - data.frame(mapply(function(z,x,y) { x[y] - 0 ; x }, names(DF), DF, DF2, SIMPLIFY=F)) but there must be an easier way... Kenneth Cabrera a écrit : Hi, R

Re: [R] Data frame index?

2006-01-18 Thread Petr Pikal
wrote: Date sent: Wed, 18 Jan 2006 02:35:35 -0500 From: Kenneth Cabrera [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Data frame index? Hi, R users: I have a data.frame (not a matrix), I got a vector with the same

Re: [R] Data frame index?

2006-01-18 Thread Dimitris Rizopoulos
/dimitris.htm - Original Message - From: Kenneth Cabrera [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, January 18, 2006 8:35 AM Subject: [R] Data frame index? Hi, R users: I have a data.frame (not a matrix), I got a vector with the same length as the number of records (rows

Re: [R] Data frame index?

2006-01-18 Thread Duncan Murdoch
On 1/18/2006 2:35 AM, Kenneth Cabrera wrote: Hi, R users: I have a data.frame (not a matrix), I got a vector with the same length as the number of records (rows) of the data frame, and each element of that vector is the column number (in a specific range of columns) of the corresponding

Re: [R] Data frame index?

2006-01-18 Thread Prof Brian Ripley
It's worth noting that there are quite a few for loops inside the code used by matrix indexing of data frames. I think a single for-loop over the columns is as good as any, something like DF - data.frame(x=1, y=rep(a, 4), z = 3) ind - c(1,3,3,1) # only numeric cols for(i in unique(ind))

[R] Data frame index?

2006-01-17 Thread Kenneth Cabrera
Hi, R users: I have a data.frame (not a matrix), I got a vector with the same length as the number of records (rows) of the data frame, and each element of that vector is the column number (in a specific range of columns) of the corresponding record that I must set to zero. How can I do

Re: [R] data frame

2005-12-25 Thread justin bem
R-help@stat.math.ethz.ch Rhett Eckstein [EMAIL PROTECTED] a écrit : Dear R users: s4 - seq(length=10, from=1, by=5) s-data.frame(s4,s4,s4) I would like to do some modification to s. And I want the form like the following,if it is possible, how should I do? The last column is the sum of

[R] data frame

2005-12-22 Thread Rhett Eckstein
Dear R users: s4 - seq(length=10, from=1, by=5) s-data.frame(s4,s4,s4) I would like to do some modification to s. And I want the form like the following,if it is possible, how should I do? The last column is the sum of previous three column. s4 s4.1 s4.2sum 1 11 2

Re: [R] data frame

2005-12-22 Thread jim holtman
Here is one way. You can change depending on what you want the offsets to be: s4 - seq(length=10, from=1, by=5) s4 [1] 1 6 11 16 21 26 31 36 41 46 f.x - function(vec, n) c(rep(0,n), vec)[1:length(vec)] f.x(s4,2) [1] 0 0 1 6 11 16 21 26 31 36 df - data.frame(s4=s4, s4.1=f.x(s4,2),

Re: [R] data frame

2005-12-22 Thread Sean Davis
On 12/22/05 9:11 AM, Rhett Eckstein [EMAIL PROTECTED] wrote: Dear R users: s4 - seq(length=10, from=1, by=5) s-data.frame(s4,s4,s4) I would like to do some modification to s. And I want the form like the following,if it is possible, how should I do? The last column is the sum of

[R] data frame output in loops

2005-05-06 Thread Apoian, Zack
I know this is very basic--I'm wondering if there is a way to write data frames as outputs from a loop. In other words, take this simple example: a - data.frame(x = c(1,2,3,4), y = c(1,2,1,2)) Given a, how would you write a loop that creates two data frames, x and y, where the first column

RE: [R] data frame output in loops

2005-05-06 Thread Francisco J. Zagmutt
No need for computer-intensive loops. Try the following: a - data.frame(x = c(1,2,3,4), y = c(1,2,1,2)) xx=data.frame(x.1=a[,1],x.2=2*a[,1]) yy=data.frame(y.1=a[,2],y.2=2*a[,2]) Cheers Francisco From: Apoian, Zack [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] data frame output

[R] data frame excerption

2005-03-12 Thread Oleg Bartunov
Hello, is't possible to get excerptions of data frame using some contstraints, something like q1 = q[q$V31] ? Regards, Oleg _ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute,

Re: [R] data frame excerption

2005-03-12 Thread Ales Ziberna
PM Subject: [R] data frame excerption Hello, is't possible to get excerptions of data frame using some contstraints, something like q1 = q[q$V31] ? Regards, Oleg _ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg

Re: [R] data frame excerption

2005-03-12 Thread Uwe Ligges
Oleg Bartunov wrote: Hello, is't possible to get excerptions of data frame using some contstraints, something like q1 = q[q$V31] ? Yes, but you have to use the indexing matrix-like (see the manuals): q1 - q[q$V3 1, ] Uwe Ligges Regards, Oleg

[R] Data Frame Manipulations

2004-12-01 Thread michael watson \(IAH-C\)
Hi I have used merge() to merge two data frames, very much like performing a SQL join. Now I want to do a few different SQL-style things and I wondered if there were functions to do it... Is there a group by style function? For example if I merge() two data frames and end up with multiple

Re: [R] Data Frame Manipulations

2004-12-01 Thread Petr Pikal
Hi Michael On 1 Dec 2004 at 11:50, michael watson (IAH-C) wrote: Hi I have used merge() to merge two data frames, very much like performing a SQL join. Now I want to do a few different SQL-style things and I wondered if there were functions to do it... Is there a group by style

Re: [R] Data Frame Manipulations

2004-12-01 Thread Dimitris Rizopoulos
://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: michael watson (IAH-C) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 12:50 PM Subject: [R] Data Frame Manipulations Hi I have used merge() to merge two data frames, very much like performing a SQL

Re: [R] data frame output

2004-03-19 Thread Prof Brian Ripley
On Thu, 18 Mar 2004, Randy Zelick wrote: Is there a way to *not* supress leading zeros when printing (to the console window or to a file) a dataframe? If you mean via print() or autoprinting, no. I am not sure why you would want to do this, but it seems that using format() and then gsub should

Re: [R] data frame output

2004-03-19 Thread Martin Maechler
Randy == Randy Zelick [EMAIL PROTECTED] on Thu, 18 Mar 2004 21:00:08 -0800 (PST) writes: Randy Hello list, Randy Is there a way to *not* supress leading zeros when printing (to the Randy console window or to a file) a dataframe? Yes, e.g. use formatC(..., format = f) to

[R] data frame output almost

2004-03-19 Thread Randy Zelick
Hello again, I got three responses for help on the leading zero problem. Thank you. Alas I still don't have it working. Here are more specifics: I read in a data file like this: participants-read.table(C:/Work/blah-blah) The data file consists of the fields last name, first name, social

Re: [R] data frame output almost

2004-03-19 Thread Prof Brian Ripley
On Fri, 19 Mar 2004, Randy Zelick wrote: I got three responses for help on the leading zero problem. Thank you. Well, it seems that you didn't tell us what the actual problem was: please consult the posting guide and its references and learn to ask the right question. Alas I still don't have

[R] data frame output

2004-03-18 Thread Randy Zelick
Hello list, Is there a way to *not* supress leading zeros when printing (to the console window or to a file) a dataframe? Thanks, =Randy= R. Zelick email: [EMAIL PROTECTED] Department of Biology voice: 503-725-3086 Portland State University

[R] data frame filtration

2004-03-10 Thread Sean Liang
Hi, R-help: I am a new user of R and am very pleased with R's features. Here I have one question regarding data frame manipulation. I have a data frame look like this: Fruit Condition 1 Orange Good 2 OrangeBad 3 Orange Good 4 Orange Good 5 OrangeBad 6 Apple Good 7

RE: [R] data frame filtration

2004-03-10 Thread Gabor Grothendieck
is returned since there is no else leg to the if. rbind then binds the groups back into a data frame. --- Date: Wed, 10 Mar 2004 17:09:23 -0500 From: Sean Liang [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [R] data frame filtration Hi, R-help: I am a new user of R and am very pleased

[R] Data frame transpose

2003-09-29 Thread Kang . Daiwen
Hi All, I want to ask if there is a transpose function for data frame like the procedure of transpose in SAS? Because I want to partially transpose a data frame which contains 5 columns (siteid, date, time, obs, mod), what I want to do is to put time as the column variables along with siteid,

Re: [R] Data frame transpose

2003-09-29 Thread Thomas Lumley
On Mon, 29 Sep 2003 [EMAIL PROTECTED] wrote: Hi All, I want to ask if there is a transpose function for data frame like the procedure of transpose in SAS? Because I want to partially transpose a data frame which contains 5 columns (siteid, date, time, obs, mod), what I want to do is to put

Re: [R] Data frame transpose

2003-09-29 Thread Thomas W Blackwell
Dave - I'm not sure whether there is already a function which does exactly what you want, because this is kind of a special case. The functions I wold look at are: by, aggregate, tapply, mapply, and, in the package nlme one I didn't know about before called gapply. But, in your case, the part

RE: [R] Data frame transpose

2003-09-29 Thread Gabor Grothendieck
]: [EMAIL PROTECTED]: Mon, 29 Sep 2003 13:15:36 -0400Subject: [R] Data frame transposeHi All,I want to ask if there is a transpose function for data frame like theprocedure of transpose in SAS? Because I want to partially transpose adata frame which contains 5 columns (siteid, date, time, obs, mod

RE: [R] Data frame transpose

2003-09-29 Thread Gabor Grothendieck
$siteid,m$date),] --- On Mon 09/29, [EMAIL PROTECTED] wrote: From: [mailto: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Mon, 29 Sep 2003 13:15:36 -0400 Subject: [R] Data frame transpose brbrbrbrHi All,brbrI want to ask if there is a transpose function for data frame like thebrprocedure

[R] Data frame from list of lists

2003-09-22 Thread Gregory Jefferis
This seems to be a simple problem, and I feel that there ought to be a simple answer, but I can't seem to find it. I have a function that returns a number of values as a heterogeneous list - always the same length and same names(), but a number of different data types, including character. I

RE: [R] Data frame from list of lists

2003-09-22 Thread Liaw, Andy
22, 2003 5:15 AM To: [EMAIL PROTECTED] Subject: [R] Data frame from list of lists This seems to be a simple problem, and I feel that there ought to be a simple answer, but I can't seem to find it. I have a function that returns a number of values as a heterogeneous list - always

Re: [R] Data frame from list of lists (Quick Summary)

2003-09-22 Thread Gregory Jefferis
part (for me) is how to get that last column back to POSIXct. I have not dealt with date/time in R before. HTH, Andy -Original Message- From: Gregory Jefferis [mailto:[EMAIL PROTECTED] Sent: Monday, September 22, 2003 5:15 AM To: [EMAIL PROTECTED] Subject: [R] Data frame from

Re: Part II Re: [R] read.ssd {foreign} (Reading a permanent SAS d ataset into an R data frame)

2002-12-25 Thread Stephen Arthur
Scot, Thanks for the additional information. On further reflection... whether one uses SAS PROC EXPORT or uses a SAS LIBNAME yourfile XPORT 'yourpathname'; statement, an intermediate file is created in either case. As far as experience tells me now, PROC EXPORT is a far superior choice, because