Re: [R] data manipulation question

2021-08-23 Thread Jim Lemon
Hi Kai, How about setting: germlinepatients$DisclosureStatus <- NA then having your three conditional statements as indices: germlinepatients$DisclosureStatus[germlinepatients$gl_resultsdisclosed == 1] <-"DISCLOSED" germlinepatients$DisclosureStatus[germlinepatients$ gl_resultsdisclosed == 0] <-

[R] data manipulation question

2021-08-23 Thread Kai Yang via R-help
Hello List, I wrote the script below to assign value to a new field DisclosureStatus. my goal is if gl_resultsdisclosed=1 then DisclosureStatus=DISCLOSED else if gl_resultsdisclosed=0 then DisclosureStatus= ATTEMPTED else if gl_resultsdisclosed is missing and gl_discloseattempt1 is not missing the

Re: [R] data manipulation

2016-12-19 Thread Duncan Mackay
"data.frame", row.names = c(NA, -396L )) Regards Duncan -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Monday, 19 December 2016 13:47 To: Duncan Mackay Cc: R Subject: Re: [R] data manipulation > On Dec 18, 2016, at 5:39 PM, Duncan Mackay wrote

Re: [R] data manipulation

2016-12-18 Thread David Winsemius
Cowpertwait. -- David. > >> >> -- >> David. >>> >>> If it does not get through will do a dput as the file is only 7K >>> >>> Regards >>> >>> Duncan >>> Duncan Mackay >>> Department of Agronomy and

Re: [R] data manipulation

2016-12-18 Thread David Winsemius
> From: David Winsemius [mailto:dwinsem...@comcast.net] > Sent: Monday, 19 December 2016 05:36 > To: Duncan Mackay > Cc: R > Subject: Re: [R] data manipulation > > >> On Dec 17, 2016, at 7:57 PM, Duncan Mackay wrote: >> >> Hi >> >> Coming late t

Re: [R] data manipulation

2016-12-18 Thread Duncan Mackay
Hi David Thanks for the info. As a test I am attaching it anyway Regards Duncan -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Monday, 19 December 2016 05:36 To: Duncan Mackay Cc: R Subject: Re: [R] data manipulation > On Dec 17, 2016, at 7:57

Re: [R] data manipulation

2016-12-18 Thread peter dalgaard
gt; Email: home: mac...@northnet.com.au >> >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas >> Sent: Thursday, 15 December 2016 01:19 >> To: Farshad Fathian; r-help >> Subject: Re: [R] data manipulatio

Re: [R] data manipulation

2016-12-18 Thread David Winsemius
- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas > Sent: Thursday, 15 December 2016 01:19 > To: Farshad Fathian; r-help > Subject: Re: [R] data manipulation > > Hello, > > Please cc your mails to the list. > As for your data, your u

Re: [R] data manipulation

2016-12-18 Thread David Winsemius
ui Barradas > Sent: Thursday, 15 December 2016 01:19 > To: Farshad Fathian; r-help > Subject: Re: [R] data manipulation > > Hello, > > Please cc your mails to the list. > As for your data, your url is wrong, you need to contact Massey or maybe > the source of your info

Re: [R] data manipulation

2016-12-17 Thread Duncan Mackay
nt of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Thursday, 15 December 2016 01:19 To: Farshad Fathian; r-help Subject: Re: [R]

Re: [R] data manipulation

2016-12-15 Thread John Kane via R-help
That should read "now" instead of "not" On Thursday, December 15, 2016 6:49 PM, John Kane wrote: It downloaded a file for me earlier but I am not getting the 404 error and I did not bother to save the download.  Shrug. On Wednesday, December 14, 2016 6:57 AM, John Kane via R-he

Re: [R] data manipulation

2016-12-15 Thread John Kane via R-help
It downloaded a file for me earlier but I am not getting the 404 error and I did not bother to save the download.  Shrug. On Wednesday, December 14, 2016 6:57 AM, John Kane via R-help wrote: xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat";) gives me something. Since we ha

Re: [R] data manipulation

2016-12-14 Thread Rui Barradas
half Of Rui Barradas Sent: Wednesday, December 14, 2016 6:12 AM To: John Kane; Farshad Fathian; r-h...@stat.math.ethz.ch Subject: Re: [R] data manipulation Hello, What do you mean by "gives me something"? xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat";) Error in

Re: [R] data manipulation

2016-12-14 Thread David Winsemius
352 > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas > Sent: Wednesday, December 14, 2016 6:12 AM > To: John Kane; Farshad Fathian; r-h...@stat.math.ethz.ch > Subject: Re: [R] data manipulation > > Hell

Re: [R] data manipulation

2016-12-14 Thread David L Carlson
r-h...@stat.math.ethz.ch Subject: Re: [R] data manipulation Hello, What do you mean by "gives me something"? xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat";) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(f

Re: [R] data manipulation

2016-12-14 Thread Rui Barradas
Hello, Please cc your mails to the list. As for your data, your url is wrong, you need to contact Massey or maybe the source of your information and get a valid internet address. Without one there's not much we can do. Rui Barradas Em 14-12-2016 12:16, Farshad Fathian escreveu: Hello, Thank

Re: [R] data manipulation

2016-12-14 Thread Rui Barradas
Hello, What do you mean by "gives me something"? xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat";) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open URL 'http://massey.ac.nz/~pscoperwait/ts/cbe.dat': HTTP status

Re: [R] data manipulation

2016-12-14 Thread John Kane via R-help
xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat";) gives me something. Since we have no idea of what you are doing I don't know if the data has downloaded correctly On Tuesday, December 13, 2016 1:38 PM, Farshad Fathian wrote: Hi, I couldn't access to data file about PS

Re: [R] data manipulation

2016-12-13 Thread John McKown
On Tue, Dec 13, 2016 at 3:23 AM, Farshad Fathian wrote: > Hi, > > I couldn't access to data file about PSCoperwait by > http://massey.ac.nz/~pscoperwait/ts/cbe.dat. > ​First off, this post is nearly useless. You don't tell us what you tried to do. And you didn't tell us what error message you go

Re: [R] data manipulation

2016-12-13 Thread Rui Barradas
Hello, And what has your question to do with R? Please read the posting guide before posting and when you do, post a question where at least the link is correct. Rui Barradas Em 13-12-2016 09:23, Farshad Fathian escreveu: Hi, I couldn't access to data file about PSCoperwait by http://mas

[R] data manipulation

2016-12-13 Thread Farshad Fathian
Hi, I couldn't access to data file about PSCoperwait by http://massey.ac.nz/~pscoperwait/ts/cbe.dat. Looking forward to hearing from you, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and mo

Re: [R] Data manipulation in a data.frame

2014-02-21 Thread arun
Hi Ioanna, If you need to paste the colnames if there are multiple 1's per row: You could try: A<-data.frame(A=c(10,100,1000,30,50,60,300,3,4,2,20,35,45),B=c(0,1,1,1,0,0,0,0,0,1,0,0,1),C=c(0,0,0,0,1,1,0,0,0,0,1,1,1),D=c(1,0,0,0,0,0,1,0,0,1,NA,1,1)) apply(A[,-1],1,function(x) {x1 <-paste(colnames(A[

Re: [R] Data manipulation in a data.frame

2014-02-21 Thread Bert Gunter
,1,0,0,0,0), > > C=c(0,0,0,0,1,1,0,0), > > D=c(1,0,0,0,0,0,1,0), > >Variable=c(D,B,B,B,C,C,D,none)) > > Thanks in advance, > IOanna > > > -Original Message- > From: arun [mailto:smartpink...@yahoo.com] > Sent

Re: [R] Data manipulation in a data.frame

2014-02-21 Thread arun
mailto:smartpink...@yahoo.com] Sent: 21 February 2014 00:19 To: r-help@r-project.org Cc: ioanna ioannou Subject: Re: [R] Data manipulation in a data.frame Also, rownames(which(t(!!A[,-1]),arr.ind=TRUE)) A.K. On Thursday, February 20, 2014 6:48 PM, arun wrote: Hi, May be this helps: A$V

Re: [R] Data manipulation in a data.frame

2014-02-21 Thread Bert Gunter
t; D=c(1,0,0,0,0,0,1,0), > >Variable=c(D,B,B,B,C,C,D,none)) > > Thanks in advance, > IOanna > > -Original Message- > From: arun [mailto:smartpink...@yahoo.com] > Sent: 21 February 2014 00:19 > To: r-help@r-project.org > Cc: ioanna ioannou &

Re: [R] Data manipulation in a data.frame

2014-02-21 Thread ioanna ioannou
D,none)) Thanks in advance, IOanna -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: 21 February 2014 00:19 To: r-help@r-project.org Cc: ioanna ioannou Subject: Re: [R] Data manipulation in a data.frame Also, rownames(which(t(!!A[,-1]),arr.ind=TRUE)) A.K. On Thursday, Fe

Re: [R] Data manipulation in a data.frame

2014-02-20 Thread Bert Gunter
... and yet another approach (written for generalization) > names(A)[-1][as.matrix(A[,-1])%*%(seq_len(ncol(A)-1))] [1] "D" "B" "B" "B" "C" "C" "D" Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge

Re: [R] Data manipulation in a data.frame

2014-02-20 Thread arun
Also, rownames(which(t(!!A[,-1]),arr.ind=TRUE)) A.K. On Thursday, February 20, 2014 6:48 PM, arun wrote: Hi, May be this helps: A$Variable <- rep(colnames(A[,-1]),nrow(A))[t(!!A[,-1])] A.K. On Thursday, February 20, 2014 5:55 PM, ioanna ioannou wrote: Hello, Assuming that I have a da

Re: [R] Data manipulation in a data.frame

2014-02-20 Thread arun
Hi, May be this helps: A$Variable <- rep(colnames(A[,-1]),nrow(A))[t(!!A[,-1])] A.K. On Thursday, February 20, 2014 5:55 PM, ioanna ioannou wrote: Hello, Assuming that I have a data frame A<-data.frame(A=c(10,100,1000,30,50,60,300),               B=c(0,1,1,1,0,0,0),                     

[R] Data manipulation in a data.frame

2014-02-20 Thread ioanna ioannou
Hello, Assuming that I have a data frame A<-data.frame(A=c(10,100,1000,30,50,60,300), B=c(0,1,1,1,0,0,0), C=c(0,0,0,0,1,1,0), D=c(1,0,0,0,0,0,1)) What I would like is to introduce a new column Variable such that:

Re: [R] data manipulation

2013-11-22 Thread David Carlson
age- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of philippe massicotte Sent: Friday, November 22, 2013 12:27 PM To: r-help@r-project.org Subject: Re: [R] data manipulation Hi again. I realized that the example I give is not valid, because the number I&#

Re: [R] data manipulation

2013-11-22 Thread philippe massicotte
s,Phil > From: pmassico...@hotmail.com > To: r-help@r-project.org > Date: Fri, 22 Nov 2013 18:17:03 +0000 > Subject: Re: [R] data manipulation > > Thank you everyone for your suggestions. > > > Date: Fri, 22 Nov 2013 18:04:16 + > > From: pbu...@pburns.seanet.com > &g

Re: [R] data manipulation

2013-11-22 Thread philippe massicotte
Thank you everyone for your suggestions. > Date: Fri, 22 Nov 2013 18:04:16 + > From: pbu...@pburns.seanet.com > To: pmassico...@hotmail.com; r-help@r-project.org > Subject: Re: [R] data manipulation > > The final ")" went missing in the command > starting 

Re: [R] data manipulation

2013-11-22 Thread Patrick Burns
The final ")" went missing in the command starting 'names(neutralVec) <- '. On 22/11/2013 17:51, Patrick Burns wrote: I think a list is the wrong structure, a vector would be better since you can use 'match': # transform data structure: neutralVec <- unlist(neutral_classes) names(neutralVec) <

Re: [R] data manipulation

2013-11-22 Thread arun
Hi, You could use either: names(which(sapply(lapply(neutral_classes,`%in%`,50),any))) #[1] "B" #or vec1 <-unlist(neutral_classes)  names(vec1) <- gsub("\\d+","",names(vec1))  names(vec1)[vec1==50] #[1] "B" A.K. Hi everyone. I have a list like this: neutral_classes = list(A = 71:100, B = 46

Re: [R] data manipulation

2013-11-22 Thread Patrick Burns
I think a list is the wrong structure, a vector would be better since you can use 'match': # transform data structure: neutralVec <- unlist(neutral_classes) names(neutralVec) <- names(neutral_classes[rep(1:length(neutral_classes), sapply(neutral_classes, length))] # get one or more results w

[R] data manipulation

2013-11-22 Thread philippe massicotte
Hi everyone. I have a list like this: neutral_classes = list(A = 71:100, B = 46:70, C = 21:45, D = 0:20) and I'm trying to return the letter of the named vector for with an integer belong. For example, B if I use the value 50. Any help would be greatly appreciated. Regards,Phil

Re: [R] Data Manipulation in R

2013-10-21 Thread arun
Hi, I am getting this.  res <- lapply(seq_len(nrow(Y1)),function(i) {dat <- data.frame(X=i,Y1=unlist(Y1[i,]),Y2=unlist(Y2[i,])); row.names(dat) <- 1:nrow(dat); write.csv(dat,paste0("Anam",i,".csv"),row.names=FALSE,quote=FALSE)}) dat1 <- read.csv("Anam1.csv",header=TRUE)  dat1   X Y1 Y2 1 1

Re: [R] Data Manipulation in R

2013-10-21 Thread Anamika Chaudhuri
Hi Arun: Thanks for your help. Seperate files are being created by concatenating the rows from the two files but I was looking to have them as columns rather than text. This is the way it appears in Excel with row # at the beginning. X Y1 Y2 1 1 4 0 20 17 1 20 52 15 18 Ideally I would like it to

Re: [R] Data Manipulation in R

2013-10-20 Thread arun
Hi, May be this helps: Y1 <- read.table(text="V1 V2 V3 V4 1 4 0 20 17 2 4 0 15 17 3 2 0 13 21",sep="",header=TRUE) Y2 <- read.table(text="V1 V2 V3 V4 1 20 52 15 18 2 18 54 14 21 3 18 51 13 21",sep="",header=TRUE)  res <- lapply(seq_len(nrow(Y1)),function(i) {dat <- data.frame(X=i,Y1=unlist(Y1[i,]

[R] Data Manipulation in R

2013-10-20 Thread Anamika Chaudhuri
Hi: I am looking for some help to manipulate data in R. I have two csv files. datasetY1 V1 "V2" "V3" "V4" 1 4 0 20 17 2 4 0 15 17 3 2 0 13 21 datasetY2 V1 "V2" "V3" "V4" 1 20 52 15 18 2 18 54 14 21 3 18 51 13 21 I want to be able to create separate csv files by taking the corresponding

Re: [R] data manipulation

2013-05-15 Thread Jim Lemon
On 05/15/2013 04:15 PM, catalin roibu wrote: Hello all! I have a problem with my data. My initial data is a list years and months (see below). I want to transpose my data (12 rows (months) and year values as column). I try t(spi3), but the year values do not appear as column names, but as values.

Re: [R] data manipulation

2013-05-14 Thread Berend Hasselman
On 15-05-2013, at 08:15, catalin roibu wrote: > Hello all! > I have a problem with my data. > My initial data is a list years and months (see below). I want to transpose > my data (12 rows (months) and year values as column). I try t(spi3), but > the year values do not appear as column names, bu

[R] data manipulation

2013-05-14 Thread catalin roibu
Hello all! I have a problem with my data. My initial data is a list years and months (see below). I want to transpose my data (12 rows (months) and year values as column). I try t(spi3), but the year values do not appear as column names, but as values. Please help me to solve this problem! Thank yo

Re: [R] Data manipulation

2013-03-15 Thread David L Carlson
vid L Carlson > Sent: Friday, March 15, 2013 9:23 AM > To: 'IOANNA'; 'John Kane'; 'Blaser Nello'; r-help@r-project.org > Subject: Re: [R] Data manipulation > > Wouldn't this do the same thing? > > xtabs(Count~Class+X, D) > > ---

Re: [R] Data manipulation

2013-03-15 Thread David L Carlson
[mailto:r-help-bounces@r- > project.org] On Behalf Of IOANNA > Sent: Friday, March 15, 2013 8:51 AM > To: 'John Kane'; 'Blaser Nello'; r-help@r-project.org > Subject: Re: [R] Data manipulation > > Thanks a lot! > > -Original Message- > From: John

Re: [R] Data manipulation

2013-03-15 Thread IOANNA
Thanks again. I hope its clearer now. Ioanna -Original Message- From: John Kane [mailto:jrkrid...@inbox.com] Sent: 15 March 2013 12:51 To: IOANNA; r-help@r-project.org Subject: RE: [R] Data manipulation What zero values? And are they acutall zeros or are the NA's, that is, m

Re: [R] Data manipulation

2013-03-15 Thread IOANNA
Thanks a lot! -Original Message- From: John Kane [mailto:jrkrid...@inbox.com] Sent: 15 March 2013 13:41 To: Blaser Nello; IOANNA; r-help@r-project.org Subject: Re: [R] Data manipulation Nice. That does look like it. IOANNA? John Kane Kingston ON Canada > -Original Mess

Re: [R] Data manipulation

2013-03-15 Thread John Kane
Nice. That does look like it. IOANNA? John Kane Kingston ON Canada > -Original Message- > From: nbla...@ispm.unibe.ch > Sent: Fri, 15 Mar 2013 14:27:03 +0100 > To: ii54...@msn.com, r-help@r-project.org > Subject: Re: [R] Data manipulation > > Is this what yo

Re: [R] Data manipulation

2013-03-15 Thread John Kane
i, 15 Mar 2013 13:11:48 + > To: jrkrid...@inbox.com, r-help@r-project.org > Subject: RE: [R] Data manipulation > > > Hello John, > > > I thought I attached the file. So here we go: > Class=c(1,1,1,1, 1,1,1,2,2,2,2,2,2,2,3,3, > 3,3,3,3,

Re: [R] Data manipulation

2013-03-15 Thread Blaser Nello
ect.org [mailto:r-help-boun...@r-project.org] On Behalf Of IOANNA Sent: Freitag, 15. März 2013 13:41 To: r-help@r-project.org Subject: [R] Data manipulation Hello all, I would appreciate your thoughts on a seemingly simple problem. I have a database, where each row represent a single record. I

Re: [R] Data manipulation

2013-03-15 Thread John Kane
Please supply some sample data. John Kane Kingston ON Canada > -Original Message- > From: ii54...@msn.com > Sent: Fri, 15 Mar 2013 12:40:54 + > To: r-help@r-project.org > Subject: [R] Data manipulation > > Hello all, > > > > I would appreciat

[R] Data manipulation

2013-03-15 Thread IOANNA
Hello all, I would appreciate your thoughts on a seemingly simple problem. I have a database, where each row represent a single record. I want to aggregate this database so I use the aggregate command : D<-read.csv("C:\\Users\\test.csv") attach(D) by1<-factor(Class) by2<-factor(X)

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread arun
HI, The option z5 takes care of it. z5<-t(x-t(mat)) #still faster than ?sweep()  dim(z5) [1] 20  2  identical(sweep(-mat,2,x,"+"),z5) #[1] TRUE A.K. From: C W To: arun Sent: Wednesday, December 5, 2012 5:09 PM Subject: Re: [R] data manipul

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread arun
ystem elapsed #  0.008   0.000   0.009 A.K. From: C W To: arun Cc: R help ; Sarah Goslee Sent: Wednesday, December 5, 2012 4:11 PM Subject: Re: [R] data manipulation between vector and matrix thanks, I knew about apply, but did not you you can put plu

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread C W
0.008 0.000 0.009 > > > A.K. > > > > > > ________ > From: C W > To: arun > Cc: R help ; Sarah Goslee > Sent: Wednesday, December 5, 2012 4:11 PM > Subject: Re: [R] data manipulation between vector and matrix > > >

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread arun
HI, In addition to ?sweep(), you can use apply(-mat,1,`+`,x) #or library(plyr) aaply(-mat,1,"+",x) A.K. - Original Message - From: C W To: Sarah Goslee Cc: r-help Sent: Wednesday, December 5, 2012 1:51 PM Subject: Re: [R] data manipulation between vector and matr

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread C W
aaply(-mat,1,"+",x) > > > A.K. > > > > > > > - Original Message - > From: C W > To: Sarah Goslee > Cc: r-help > Sent: Wednesday, December 5, 2012 1:51 PM > Subject: Re: [R] data manipulation between vector and matrix > > Thanks, Sarah. First time

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread C W
Thanks, Sarah. First time heard about sweep(), it worked just the way I wanted. Mike On Wed, Dec 5, 2012 at 1:42 PM, Sarah Goslee wrote: > Hi, > > On Wed, Dec 5, 2012 at 1:30 PM, C W wrote: > > Dear list, > > I was curious how to subtract a vector from matrix? > > > > Say, I have > > > > mat <

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread Sarah Goslee
Hi, On Wed, Dec 5, 2012 at 1:30 PM, C W wrote: > Dear list, > I was curious how to subtract a vector from matrix? > > Say, I have > > mat <- matrix(1:40, nrow=20, ncol=2) > > x <-c(1,2) Thanks for the actual reproducible example. > I want, > > x-mat[1,] and x-mat[2,], and so on... Basically, su

Re: [R] data manipulation between vector and matrix

2012-12-05 Thread C W
The only solution I found was x-t(mu) Is there a better way? Mike On Wed, Dec 5, 2012 at 1:30 PM, C W wrote: > Dear list, > I was curious how to subtract a vector from matrix? > > Say, I have > > mat <- matrix(1:40, nrow=20, ncol=2) > > x <-c(1,2) > > I want, > > x-mat[1,] and x-mat[2,], and so

[R] data manipulation between vector and matrix

2012-12-05 Thread C W
Dear list, I was curious how to subtract a vector from matrix? Say, I have mat <- matrix(1:40, nrow=20, ncol=2) x <-c(1,2) I want, x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements of x against column elements in mat. But x-mat won't do it. Thanks, Mike [[al

Re: [R] Data manipulation with aggregate

2012-07-03 Thread arun
ll=TRUE)   Name length type 1    a    1.5    x 2    b    3.5 A.K. - Original Message - From: Filoche To: r-help@r-project.org Cc: Sent: Tuesday, July 3, 2012 12:04 PM Subject: [R] Data manipulation with aggregate Hi everyone. I have these data : myData = data.frame(Name =

Re: [R] Data manipulation with aggregate

2012-07-03 Thread jim holtman
try this: > myData = data.frame(Name = c('a', 'a', 'b', 'b'), length = c(1,2,3,4), type + = c('x','x','y','z')) > > result <- do.call(rbind, lapply(split(myData, myData$Name), function(.name){ + data.frame(Name = .name$Name[1L] + , length = mean(.name$length) + , type = if (all(.name$type[1L] == .

[R] Data manipulation with aggregate

2012-07-03 Thread Filoche
Hi everyone. I have these data : myData = data.frame(Name = c('a', 'a', 'b', 'b'), length = c(1,2,3,4), type = c('x','x','y','z')) which gives me: Name length type 1a 1x 2a 2x 3b 3y 4b 4 z I would group (mean) this DF using 'Name' as grouping

[R] data manipulation

2012-01-12 Thread Rinde
Hi all, I'm trying to do some data manipulation using R, but I'm a bit stuck. I have to warn you, I'm a real R noob. I have for example this file: V1 V2 V3 V4 V5V6 1:156706559

Re: [R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-16 Thread Clemontina Alexander
Thank you, that is much simpler! On Thu, Dec 15, 2011 at 2:04 PM, Rui Barradas wrote: > Hello, > > I believe I can help, or at least, my code is simpler. > First, look at your first line: > > idd <- length(diag(1,tt))   # length of intercept matrix > # > not needed: diag(tt) would do the job bu

Re: [R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-15 Thread Rui Barradas
Hello, I believe I can help, or at least, my code is simpler. First, look at your first line: idd <- length(diag(1,tt)) # length of intercept matrix # not needed: diag(tt) would do the job but it's not needed, why call 2 functions, and one of them, 'diag', uses memory(*), if the result

Re: [R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-15 Thread Clemontina Alexander
I'm sorry, the indices of my X matrix are wrong. It should be: X = x11 0 0 x12 0 0 0 x11 00 x12 0 0 0 x110 0 x12 x21 0 0 x22 0 0 0 x21 0

[R] Data Manipulation - make diagonal matrix of each element of a matrix

2011-12-15 Thread Clemontina Alexander
Dear R list, I have the following data: set.seed(1) n <- 5 # number of subjects tt <- 3 # number of repeated observation per subject numco <- 2 # number of covariates x <- matrix(round(rnorm(n*numco),2), ncol=numco) # the actual covariates x > x [,1] [,2] [1,] -0.63 -0.82 [2,]

Re: [R] data manipulation and summaries with few million rows

2011-08-27 Thread jim holtman
Factors are you friend here: > myData mydate gender mygroup id mygrp.f 1 2012-03-25 F A 1 1 2 2005-05-23 F B 2 2 3 2005-09-08 F B 2 2 4 2005-12-07 F B 2 2 5 2006-02-26 F C 2 3 6 2006-05-13 F

Re: [R] data manipulation and summaries with few million rows

2011-08-24 Thread Juliet Hannah
Thanks Dennis! I'll check this out. Just to clarify, I need the total number of switches/changes regardless of if that state had occurred in the past. So A-A-B-A, would have 2 changes: A to B and B to A. Thanks again. On Wed, Aug 24, 2011 at 1:28 PM, Dennis Murphy wrote: > Hi Juliet: > > Here'

Re: [R] data manipulation and summaries with few million rows

2011-08-24 Thread Dennis Murphy
Hi Juliet: Here's a Q & D solution: # (1) plyr > f <- function(d) length(unique(d$mygroup)) - 1 > ddply(myData, .(id), f) id V1 1 1 0 2 2 2 3 3 1 4 4 0 # (2) data.table myDT <- data.table(myData, key = 'id') myDT[, list(nswitch = length(unique(mygroup)) - 1), by = 'id'] If one can sw

[R] data manipulation and summaries with few million rows

2011-08-24 Thread Juliet Hannah
I have a data set with about 6 million rows and 50 columns. It is a mixture of dates, factors, and numerics. What I am trying to accomplish can be seen with the following simplified data, which is given as dput output below. > head(myData) mydate gender mygroup id 1 2012-03-25 F

Re: [R] Data manipulation

2011-02-12 Thread mathijsdevaan
That worked great! Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Data-manipulation-tp3302717p3303001.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

Re: [R] Data manipulation

2011-02-12 Thread jim holtman
Will this do it for you: > x <- read.table(textConnection(" A B C + 1 1 a 1999 + 2 1 b 1999 + 3 1 c 1999 + 4 2 c 2001 + 5 2 d 2001 + 6 3 a 2004 + 7 3 b 2004"), header = TRUE) > closeAllConnections() > # add a tenure column > x$tenure <- ave(x$C, x$B, FUN = function(yr) yr - min(yr)

Re: [R] Data manipulation

2011-02-12 Thread Johannes Huesing
mathijsdevaan [Sat, Feb 12, 2011 at 03:00:18PM CET]: > > Hi, > > I have a dataset with info on individuals (B) that have been involved in > projects (A) during multiple years (C). The dataset contains three columns: > A, B, C. Example: >A B C > 1 1 a 1999 > 2 1 b 1999 > 3 1 c 1999 >

[R] Data manipulation

2011-02-12 Thread mathijsdevaan
Hi, I have a dataset with info on individuals (B) that have been involved in projects (A) during multiple years (C). The dataset contains three columns: A, B, C. Example: A B C 1 1 a 1999 2 1 b 1999 3 1 c 1999 4 2 c 2001 5 2 d 2001 6 3 a 2004 7 3 b 2004 I am interested in the

Re: [R] R Data Manipulation - Transposing Data by a Given Column, Like User_ID

2011-02-03 Thread Gabor Grothendieck
On Thu, Feb 3, 2011 at 10:05 PM, Peter Ehlers wrote: > On 2011-02-03 14:09, Dennis Murphy wrote: >> >> Hi: >> >> This also works, except that the result is of class 'table': >> >> xtabs(COUNTS ~ USER_ID + SITE, data = RAW) >>        SITE >> USER_ID SITE1 SITE2 SITE3 >>       1    10    13    22 >>

Re: [R] R Data Manipulation - Transposing Data by a Given Column, Like User_ID

2011-02-03 Thread Peter Ehlers
On 2011-02-03 14:09, Dennis Murphy wrote: Hi: This also works, except that the result is of class 'table': xtabs(COUNTS ~ USER_ID + SITE, data = RAW) SITE USER_ID SITE1 SITE2 SITE3 1101322 2101212 31344 0 4 0 09

Re: [R] R Data Manipulation - Transposing Data by a Given Column, Like User_ID

2011-02-03 Thread Dennis Murphy
Hi: This also works, except that the result is of class 'table': xtabs(COUNTS ~ USER_ID + SITE, data = RAW) SITE USER_ID SITE1 SITE2 SITE3 1101322 2101212 31344 0 4 0 099 If you need a data frame, then the earlier res

Re: [R] R Data Manipulation - Transposing Data by a Given Column, Like User_ID

2011-02-03 Thread Steve Lianoglou
Hi, On Thu, Feb 3, 2011 at 2:41 PM, Mike Schumacher wrote: > Hello, > > I'd like to transpose data to create an analysis-friendly dataframe.  See > below for an example, I was unable to use t(x) and I couldn't find a > function with options like PROC TRANSPOSE in SAS. > > The ideal solution handl

Re: [R] R Data Manipulation - Transposing Data by a Given Column, Like User_ID

2011-02-03 Thread Eik Vettorazzi
Hi Mike reshape will be your friend. reshape(RAW,direction="wide",timevar="SITE",idvar="USER_ID") there is also the 'reshape'-package, which can do some more sophisticated transformations. hth. Am 03.02.2011 20:41, schrieb Mike Schumacher: > Hello, > > I'd like to transpose data to create an

[R] R Data Manipulation - Transposing Data by a Given Column, Like User_ID

2011-02-03 Thread Mike Schumacher
Hello, I'd like to transpose data to create an analysis-friendly dataframe. See below for an example, I was unable to use t(x) and I couldn't find a function with options like PROC TRANSPOSE in SAS. The ideal solution handles variable quantities of SITE - but beggars can't be choosers. :-) Tha

Re: [R] Data manipulation in R

2010-09-24 Thread Dennis Murphy
Hi: Please provide a minimal reproducible example that resembles your real data so that people can try it out and provide potential solutions for you. Show what you tried that failed, and what you expect. A number of people on this list are very adept in data summarization, but most of them are lo

[R] Data manipulation in R

2010-09-24 Thread Thomas Parr
If this has already been answered, my apologies in advance I am relatively new to this aspect of [R]. it is a bit of a basic question. I have 4 columns of data (site, Date, measurement type, value) in a tab delimited text file. Site is a site where measurements were collected, Date is a date i

Re: [R] Data Manipulation

2010-09-10 Thread Erik Iverson
Hello, This is definitely possible with R, there a lots of package to make good graphics. However, the easiest way for us to help you is if you give us a small reproducible example, as you started to with your initial post. If you have an object in your R session that you'd like help with you c

Re: [R] Data Manipulation

2010-09-10 Thread Joshua Wiley
Hi, Yes, the table() function is not to read the data, but to do the frequency counts of each level. I just included the read.table() part so that you could copy and paste my code, but I did not include the R output from table(dat). > table(dat) dat A B C D 3 3 2 1 It nicely tallies for you. A

Re: [R] Data Manipulation

2010-09-10 Thread dfong
I'm actually importing it from a CSV, so I already have that in a table. But i Can't make a graph with text. I assume I need to do some counting in order to draw the graph? Any example of this? thanks -- View this message in context: http://r.789695.n4.nabble.com/Data-Manipulation-tp2534662p253

Re: [R] Data Manipulation

2010-09-10 Thread Joshua Wiley
Hi, Look at the table() function. Here is an example with your data: dat <- read.table(textConnection(" Study A A B B B A C C D"), header = TRUE) closeAllConnections() table(dat) Hope that helps, Josh On Fri, Sep 10, 2010 at 8:53 AM, dfong wrote: > > Hi, > > I just started using R and nee

[R] Data Manipulation

2010-09-10 Thread dfong
Hi, I just started using R and need some guidance. I need to create a time series chart in R, but the problem is the data is not numeric. The data is in the following format Study A A B B B A C C D Then there is also another column with dates. How can I manipulate this in order to have so

Re: [R] Data manipulation search

2010-08-11 Thread Erik Iverson
?match, look at the %in% operator. Mestat wrote: Hi listers, I made some search, but i didn`t find in the forum. I have a data set. I would like to make a search (conditon) on my data set. x<-c(1,2,3,4,5,6,7,8,9,10) count<-0 if (CONDITON){count<-1}else{count<-0} My CONDITION would be: is there

[R] Data manipulation search

2010-08-11 Thread Mestat
Hi listers, I made some search, but i didn`t find in the forum. I have a data set. I would like to make a search (conditon) on my data set. x<-c(1,2,3,4,5,6,7,8,9,10) count<-0 if (CONDITON){count<-1}else{count<-0} My CONDITION would be: is there number 5 in my data set? Thanks in advance, Marci

Re: [R] Data manipulation problem

2010-04-09 Thread Dieter Menne
Bert Gunter wrote: > > Yes. Don't do this. > > (what you probably really want to do is fit a model with age as a factor, > which can be done statistically e.g. by logistic regression; or > graphically > using conditioning plots, e.g. via trellis graphics (the lattice package). > This avoids the

Re: [R] Data manipulation problem

2010-04-09 Thread moleps
1002 866 >>>>>> 547 247 82 18 >>>>>>> table (yr5) >>>>>> yr5 >>>>>> (1950,1955] (1955,1960] (1960,1965] (1965,1970] (1970,1975] (1975,1980] >>>>>> (1980,1985] (1985,1990] (1990,1

Re: [R] Data manipulation problem

2010-04-07 Thread David Winsemius
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of moleps Sent: Monday, April 05, 2010 11:46 AM To: r-help@r-project.org Subject: [R] Data manipulation problem Dear R´ers. I´ve got a dataset with age and year of diagnosis. In order to age-standardize the incid

Re: [R] Data manipulation problem

2010-04-07 Thread moleps islon
45] (45,50] (50,55] (55,60] (60,65] (65,70] (70,75] (75,80] >>>>>> (80,85] (85,100] 35 34 33 47 51 109 >>>>>> 157 231 362 511745 926 1002 866 >>>>>>

Re: [R] Data manipulation problem

2010-04-06 Thread David Winsemius
llis graphics (the lattice package). This avoids the arbitrariness and discontinuities of binning by age range.) Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of moleps Sent: Monda

Re: [R] Data manipulation problem

2010-04-06 Thread David Winsemius
istics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of moleps Sent: Monday, April 05, 2010 11:46 AM To: r-help@r-project.org Subject: [R] Data manipulation problem Dear R´ers. I´ve got a dataset with age and year of diagnosis.

Re: [R] Data manipulation problem

2010-04-06 Thread moleps islon
> >>>> Yes. Don't do this. >>>> >>>> (what you probably really want to do is fit a model with age as a factor, >>>> which can be done statistically e.g. by logistic regression; or graphically >>>> using conditioning plots, e.g. via

  1   2   >