Re: [R] Data Manipulation Question

2009-12-03 Thread hadley wickham
On Thu, Dec 3, 2009 at 3:52 PM, John Filben johnfil...@yahoo.com wrote: Can R support data manipulation programming that is available in the SAS datastep?  Specifically, can R support the following: -  Read multiple dataset one record at a time and compare values from each; then base

Re: [R] Data Manipulation Question

2009-12-03 Thread Jason Morgan
Please refrain from posting HTML. The results can be incomprehensible: On 2009.12.03 13:52:09, John Filben wrote: Can R support data manipulation programming that is available in the SAS datastep??? Specifically, can R support the following: -?? Read multiple dataset one

Re: [R] Data Manipulation Question

2009-12-03 Thread Gray Calhoun
The data import/export manual can elaborate on a lot of these; this is all straightforward, although many people would prefer to use a relational database for some of the things you mentioned. I'm not aware of a goto command in R, though (although I could be wrong). --Gray On Thu, Dec 3, 2009 at

Re: [R] Data Manipulation Question

2009-12-03 Thread David Winsemius
On Dec 3, 2009, at 10:52 PM, Gray Calhoun wrote: The data import/export manual can elaborate on a lot of these; this is all straightforward, although many people would prefer to use a relational database for some of the things you mentioned. See Wickham's pithy response to this. I'm not

Re: [R] data manipulation involving aggregate

2009-05-29 Thread Gabor Grothendieck
Try this: as.data.frame.table(xtabs(area ~ habitat + sq, DF), responseName = area.sum)[c(2:3, 1)] sq area.sum habitat 1 10 field 2 13 garden 3 13pond 4 10 river 5 21 field 6 22 garden 7 20pond 8 2

Re: [R] Data manipulation - multiplicate cases

2009-03-27 Thread jim holtman
Is this what you are looking for: x X Y Z 1 123 3 1 2 234 3 1 3 345 4 2 4 456 3 2 new.x - x[rep(seq(nrow(x)), times=x$Y),] new.x X Y Z 1 123 3 1 1.1 123 3 1 1.2 123 3 1 2 234 3 1 2.1 234 3 1 2.2 234 3 1 3 345 4 2 3.1 345 4 2 3.2 345 4 2 3.3 345 4 2 4 456 3 2 4.1 456 3 2 4.2

Re: [R] Data manipulation - multiplicate cases

2009-03-27 Thread Bill.Venables
Here is a suggestion. Let your data frame be 'dat': dat X YZ 123 31 234 31 345 42 456 32 Try this: bigData - data.frame(with(dat, rbind(cbind(X = rep(X, Z), Y = rep(Y,Y), Z = 1), cbind(X = rep(X, Y-Z), Y = rep(Y,

Re: [R] Data Manipulation, add frequency index

2008-11-08 Thread Gabor Grothendieck
See ?ave and ?seq_along DF - data.frame(Name = c(Mary, Mary, Mary, Sam, Sam, John, John, John, John), stringsAsFactors = FALSE) DF$index - ave(1:nrow(DF), DF$Name, FUN = seq_along) On Sat, Nov 8, 2008 at 5:43 AM, jie feng [EMAIL PROTECTED] wrote: Hi, there, I have a simple data

Re: [R] Data Manipulation, add frequency index

2008-11-08 Thread Dimitris Rizopoulos
one way is with ave(), e.g., dat - data.frame(name = rep(c(Mary, Sam, John), c(3,2,4))) dat$freq - ave(seq_along(dat$name), dat$name, FUN = seq_along) dat I hope it helps. Best, Dimitris jie feng wrote: Hi, there, I have a simple data manipulation question for you. Thank you for your

Re: [R] Data manipulation question

2008-11-06 Thread bartjoosen
How about: id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1)) start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) data - data.frame(id,start,stop) f - function(data){ m - match(data$start,data$stop) + 1 if (length(m)==1

Re: [R] Data manipulation question

2008-11-06 Thread cruz
On Thu, Nov 6, 2008 at 4:23 PM, Peter Jepsen [EMAIL PROTECTED] wrote: Here is an example: id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1)) start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) data - as.data.frame(cbind(id,start,stop)) data

Re: [R] Data manipulation question

2008-11-06 Thread Peter Jepsen
special cases outside my small example dataset. Thank you again! Peter. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bartjoosen Sent: 6. november 2008 11:31 To: r-help@r-project.org Subject: Re: [R] Data manipulation question How about: id - c(rep(a,4

Re: [R] Data manipulation for random intercept GLMM

2008-05-02 Thread Ben Bolker
Giovanni Petris GPetris at uark.edu writes: ## Example: Ratings of prime minister (Agresti, Table 12.1, p.494) rating - matrix(c(794, 86, 150, 570), 2, 2) dimnames(rating) - list(First = c(approve, disapprove), + Second = c(approve, disapprove)) rating

Re: [R] Data manipulation for random intercept GLMM

2008-05-02 Thread Greg Snow
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ben Bolker Sent: Friday, May 02, 2008 7:36 AM To: [EMAIL PROTECTED] Subject: Re: [R] Data manipulation for random intercept GLMM Giovanni Petris GPetris at uark.edu writes: ## Example: Ratings of prime

Re: [R] data manipulation

2008-02-29 Thread Gavin Simpson
On Fri, 2008-02-29 at 15:01 +, Luis Ridao Cruz wrote: R-help, I have a data frame in which I compute maximum by rows and I wish to find out the column name at which this maximun occurs. Does anyone know how to do it? Thanks in advance Do you mean compute the maximum value in a row

Re: [R] data manipulation for plotting

2008-02-15 Thread Jim Lemon
[EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data data=c(1,1,1,4,5,5,6) I

Re: [R] data manipulation for plotting

2008-02-14 Thread Gavin Simpson
On Thu, 2008-02-14 at 14:35 +, [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data vector for example, say i have a vector of data

Re: [R] data manipulation for plotting

2008-02-14 Thread Abi Ghanem josephine
Hi rich, data - c(1,1,1,4,5,5,6) table(data) data 1 4 5 6 3 1 2 1 hope it helps josephine [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq on the y axis. So, I need to calculate the freq a value is seen within my data

Re: [R] data manipulation for plotting

2008-02-14 Thread John Kane
Here are a couple of ways depending on what you want. data1=c(1,1,1,4,5,5,6) plot(table(data1)) --- plotvec - as.vector(aa) nns - names(aa) plot(plotvec, xaxt=n) mtext(nns, at=1:4, side=1) --- --- [EMAIL PROTECTED] [EMAIL

Re: [R] data manipulation for plotting

2008-02-14 Thread Henrique Dallazuanna
Try this: values - c(1,1,1,4,5,5,6) with(rle(values), plot(values, lengths)) But I think that you can use barplot: barplot(table(values)) On 14/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, i'd like to plot some data that I have with the value on the x axis and freq

Re: [R] Data manipulation question (opposite of table?)

2008-01-27 Thread David Winsemius
Michael Denslow [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Dear R users, I am a new user (probably obvious by my question) and have really learned a lot from reading this list. Thank you all very much. My main struggles with R are with data manipulation. So here is my

Re: [R] Data manipulation

2007-10-16 Thread Klaus Friis Østergaard
2007/10/15, Petr PIKAL [EMAIL PROTECTED]: Hi Well, let us put it another way. Do you want for each unique combination of Hole and Feature to subtract a value from one data frame, let us call it nom from another data frame, let us call it raw? If yes I assume you have exactly same number of

Re: [R] Data manipulation

2007-10-16 Thread Petr PIKAL
Hi Klaus Friis Østergaard [EMAIL PROTECTED] napsal dne 16.10.2007 10:34:15: 2007/10/15, Petr PIKAL [EMAIL PROTECTED]: Hi Well, let us put it another way. Do you want for each unique combination of Hole and Feature to subtract a value from one data frame, let us call it nom from

Re: [R] Data manipulation

2007-10-15 Thread Stephen Tucker
Hi Klaus, I am not exactly sure what you are asking for, but something like this? This would be option (2) from your list - I don't know that it would be too difficult in R that you would want to use another tool. filt - function(x) with(x,which(Hole 1)) normalize - function(x,y) {

Re: [R] Data manipulation

2007-10-15 Thread Klaus Friis Østergaard
2007/10/15, Stephen Tucker [EMAIL PROTECTED]: Hi Klaus, I am not exactly sure what you are asking for, but something like this? This would be option (2) from your list - I don't know that it would be too difficult in R that you would want to use another tool. filt - function(x)

Re: [R] Data manipulation

2007-10-15 Thread Petr PIKAL
Hi [EMAIL PROTECTED] napsal dne 15.10.2007 14:36:59: 2007/10/15, Stephen Tucker [EMAIL PROTECTED]: Hi Klaus, I am not exactly sure what you are asking for, but something like this? This would be option (2) from your list - I don't know that it would be too difficult in R that you

Re: [R] Data manipulation question

2007-10-10 Thread Gabor Grothendieck
Try this: transform(d, z = y[match(x, id)]) On 10/10/07, Julien Barnier [EMAIL PROTECTED] wrote: Hi all, Suppose I have the following data.frame, with an id column and two variables columns : idX Y 0001 NA 21 0002 NA 13 0003 000145 0004

Re: [R] Data manipulation

2007-09-29 Thread Dimitris Rizopoulos
use something like the following (untested) files - paste(C:/d, 1:3, .txt, sep = ) dats - vector(list, 3) for (i in 1:3) { dats[[i]] - read.table(files[i], header = TRUE) } dats do.call(rbind, dat) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre

Re: [R] Data manipulation

2007-09-29 Thread Peter Dalgaard
Dimitris Rizopoulos wrote: use something like the following (untested) files - paste(C:/d, 1:3, .txt, sep = ) dats - vector(list, 3) for (i in 1:3) { dats[[i]] - read.table(files[i], header = TRUE) } dats do.call(rbind, dat) ..or even files - paste(C:/d, 1:3, .txt, sep = )

<    1   2