Re: [R] Data transformation problem

2020-11-12 Thread phil
Thank you so much for this elegant solution, Jeff. Philip On 2020-11-12 02:20, Jeff Newmiller wrote: I am not a data.table afficiando, but here is how I would do it with dplyr/tidyr: library(dplyr) library(tidyr) do_per_REL <- function( DF ) { rng <- range( DF$REF1 ) # watch out for

Re: [R] Data transformation problem

2020-11-11 Thread Jeff Newmiller
I am not a data.table afficiando, but here is how I would do it with dplyr/tidyr: library(dplyr) library(tidyr) do_per_REL <- function( DF ) { rng <- range( DF$REF1 ) # watch out for missing months? DF <- ( data.frame( REF1 = seq( rng[ 1 ], rng[ 2 ], by = "month" ) ) %>%

[R] Data transformation problem

2020-11-11 Thread phil
I am stuck on a data transformation problem. I have a data frame, df1 in my example, with some original "levels" data. The data pertain to some variable, such as GDP, in various reference periods, REF, as estimated and released in various release periods, REL. The release periods follow after

Re: [R] data transformation

2019-01-20 Thread Jeff Newmiller
There is no "perhaps" about it. Nonsense phrases like "similar to logit, where I dont [sic] lose normality of the data" that lead into off-topic discussions of why one introduces transformations in the first place are perfect examples of why questions like this belong on a statistical theory

Re: [R] data transformation

2019-01-20 Thread Richard M. Heiberger
this might work for you newy <- sign(oldy)*f(abs(oldy)) where f() is a monotonic transformation, perhaps a power function. On Sun, Jan 20, 2019 at 11:08 AM Adrian Johnson wrote: > > I apologize, I forgot to mention another key operation. > in my matrix -1 to <0 has a different meaning while

Re: [R] data transformation

2019-01-20 Thread David L Carlson
of Anthropology Texas A University -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adrian Johnson Sent: Sunday, January 20, 2019 8:02 AM To: r-help Subject: [R] data transformation Dear group, My question, perhaps is more of a statistical question using R I have

Re: [R] data transformation

2019-01-20 Thread Adrian Johnson
I apologize, I forgot to mention another key operation. in my matrix -1 to <0 has a different meaning while values between >0 to 1 has a different set of meaning. So If I do logit transformation some of the positives becomes negative (values < 0.5 etc.). In such case, the resulting transformed

[R] data transformation

2019-01-20 Thread Adrian Johnson
Dear group, My question, perhaps is more of a statistical question using R I have a data matrix ( 400 x 400 normally distributed) with data points ranging from -1 to +1.. For certain clustering algorithms, I suspect the tight data range is not helping resolving the clusters. Is there a way to

Re: [R] Data transformation to list for event occurence

2013-11-13 Thread William Dunlap
) which(!!x[,3])) } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Tuesday, November 12, 2013 2:13 PM To: R help Subject: Re: [R] Data transformation to list

[R] Data transformation to list for event occurence

2013-11-12 Thread Anindya Sankar Dey
Hi, Say I have a following data ID WeekEvent_Occurence A 1 0 A 2 0 A 3 1 A 4 0 B 1 1 B 2 0 B 3 0 B 4 1 that whether an individual experienced an event in a particular week. I wish to create list such as the first element of the list will be a vector listing the week number when the event

Re: [R] Data transformation to list for event occurence

2013-11-12 Thread arun
Hi Anindya, You may try: dat1 - read.table(text=ID   Week    Event_Occurence A 1 0 A 2 0 A 3 1 A 4 0 B 1 1 B 2 0 B 3 0 B 4 1,sep=,header=TRUE,stringsAsFactors=FALSE)  with(dat1,tapply(as.logical(Event_Occurence),ID,FUN=which )) #or lapply(split(dat1,dat1$ID),function(x) which(!!x[,3])) A.K.

Re: [R] Data transformation cleaning

2011-09-28 Thread Weidong Gu
Seems your questions belong to rule mining for frequent item sets. check arules package Weidong Gu On Tue, Sep 27, 2011 at 11:13 PM, pip56789 pd...@virginia.edu wrote: Hi, I have a few methodological and implementation questions for ya'll. Thank you in advance for your help. I have a dataset

Re: [R] Data transformation cleaning

2011-09-28 Thread Jim Lemon
On 09/28/2011 01:13 PM, pip56789 wrote: Hi, I have a few methodological and implementation questions for ya'll. Thank you in advance for your help. I have a dataset that reflects people's preference choices. I want to see if there's any kind of clustering effect among certain preference choices

[R] Data transformation cleaning

2011-09-27 Thread pip56789
Hi, I have a few methodological and implementation questions for ya'll. Thank you in advance for your help. I have a dataset that reflects people's preference choices. I want to see if there's any kind of clustering effect among certain preference choices (e.g. do people who pick choice A also

Re: [R] Data transformation cleaning

2011-09-27 Thread Daniel Malter
On a methodological level, if the choices do not correspond on a cardinal or at least ordinal scale, you don't want to use correlations. Instead you should probably use Cramer's V, in particular if the choices are multinomial. Whether the wide format is necessary will depend on the format the

[R] data transformation ----Box-Cox Transformations

2011-05-03 Thread Stuart
Hi Could any one please help how I can trnasform data based on Box-Cox Transformations. I have massive data set with many variables. If possible someone can write few lines so I can read in all data set once and transform it. g1 g2 g2 97.03703704 89.25925926 4.4

Re: [R] data transformation ----Box-Cox Transformations

2011-05-03 Thread Greg Snow
Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Stuart Sent: Tuesday, May 03, 2011 9:37 AM To: r-help@r-project.org Subject: [R] data transformation Box-Cox Transformations Hi

Re: [R] data transformation ----Box-Cox Transformations

2011-05-03 Thread John Fox
of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Stuart Sent: May-03-11 11:37 AM To: r-help@r-project.org Subject: [R] data transformation

[R] Data transformation

2010-11-03 Thread Santosh Srinivas
Dear Group, Need to do the following transformation: I have the dataset structure(list(Date = structure(1L, .Label = 2010-06-16, class = factor), ACC.returns1Day = -0.018524832, ACC.returns5Day = 0.000863931, ACC.returns7Day = -0.019795222, BCC.returns1Day = -0.009861859,

[R] Data transformation

2010-01-25 Thread Lisa
Dear all, I have a dataset that looks like this: x - read.table(textConnection(col1 col2 3 1 2 2 4 7 8 6 5 10), header=TRUE) I want to rewrite it as below: var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 1 0 1 0 0 0 0 0 0 0 0 2

Re: [R] Data transformation

2010-01-25 Thread Sarah Goslee
Well, I have no idea how to get from one to the other. There's col1 and col2 but no var1 var2 var3, etc. I thought perhaps col1 was the row index and col2 was the column index, but that doesn't match up either, and not all the cell values are 1. So you will need to explain more clearly what you

Re: [R] Data transformation

2010-01-25 Thread Steve Lianoglou
Hi, On Mon, Jan 25, 2010 at 5:39 PM, Lisa lisa...@gmail.com wrote: Dear all, I  have a dataset that looks like this: x - read.table(textConnection(col1 col2 3 1 2 2 4 7 8 6 5 10), header=TRUE) I want to rewrite it as below: var1 var2 var3 var4 var5 var6 var7 var8 var9 var10    1  

Re: [R] Data transformation

2010-01-25 Thread Lisa
Thank you so much. Lisa -- View this message in context: http://n4.nabble.com/Data-transformation-tp1289899p1289915.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] Data transformation

2010-01-25 Thread Seeliger . Curt
r-help-boun...@r-project.org wrote on 01/25/2010 02:39:32 PM: x - read.table(textConnection(col1 col2 3 1 2 2 4 7 8 6 5 10), header=TRUE) I want to rewrite it as below: var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 1 0 1 0 0 0 0 0 0

Re: [R] Data transformation

2010-01-25 Thread Gabor Grothendieck
Try this: t(apply(x, 1, function(r) table(factor(r, levels = seq_len(max(x)) 1 2 3 4 5 6 7 8 9 10 [1,] 1 0 1 0 0 0 0 0 0 0 [2,] 0 2 0 0 0 0 0 0 0 0 [3,] 0 0 0 1 0 0 1 0 0 0 [4,] 0 0 0 0 0 1 0 1 0 0 [5,] 0 0 0 0 1 0 0 0 0 1 If you use aaply in the plyr package instead of apply then

Re: [R] Data transformation

2009-11-11 Thread jim holtman
Try this: x - read.table(textConnection(idcode1code2 p + 148 0.1 + 157 0.9 + 218 0.4 + 262 0.2 + 243 0.6 + 356 0.7 +

Re: [R] Data transformation

2009-11-11 Thread legen
Your script works very well. Thank you very much. Legen Henrique Dallazuanna wrote: Try this also: xtabs(rep(p, 2) ~ rep(id, 2) + sprintf(var%d, c(code1, code2)), data = x) On Wed, Nov 11, 2009 at 2:10 AM, legen lege...@gmail.com wrote: Thank you for your kind help. Your script

Re: [R] Data transformation

2009-11-11 Thread legen
That's what I want. Many thanks for your help. Legen jholtman wrote: Try this: x - read.table(textConnection(idcode1code2 p + 148 0.1 + 157 0.9 + 218 0.4 + 262

[R] Data transformation

2009-11-10 Thread legen
Dear all, I have a dataset as below: idcode1code2 p 148 0.1 157 0.9 218 0.4 262 0.2 243 0.6 356 0.7 37

Re: [R] Data transformation

2009-11-10 Thread jim holtman
Is this what you want: x - read.table(textConnection(idcode1code2 p + 148 0.1 + 157 0.9 + 218 0.4 + 262 0.2 + 243 0.6 + 356

Re: [R] Data transformation

2009-11-10 Thread legen
Thank you for your kind help. Your script works very well. Would you please show me how to change NaN to zero and column variables 1, 2, ..., 8 to var1, var2, ..., var8? Thanks again. Legen jholtman wrote: Is this what you want: x - read.table(textConnection(idcode1code2

[R] data transformation using gamma

2009-05-07 Thread Roslina Zakaria
Hi R-users, I have this code to uniformise the data using gamma: length(dp1) [1] 696 dim(dp1) [1] 58 12 dim(ahall) [1]  1 12 dim(bhall) [1]  1 12 trans_dt - function(dt,a,b) + { n1 - ncol(dt) +   n2 - length(dt) +   trans  - vector(mode='numeric', length=n2) +   dim(trans) - dim(dt) +  

Re: [R] data transformation using gamma

2009-05-07 Thread Patrizio Frederic
Roslina, this code performs what you need: dt = matrix((1:(58*12))/58/12,58) # some numbers # if dt is a data.frame use dt = as.matrix(dt) a = (1:12)/12 # some a coef b = (12:1)/12 # some b coef dtgam = matrix(pgamma(dt,a,b),58) # dtgam is the transformation you're looking for

[R] data transformation

2008-07-22 Thread Christian Hof
Dear all, how can I, with R, transform a presence-only table (with the names of the species (1st column), the lat information of the sites (2nd column) and the lon information of the sites (3rd column)) into a presence-absence (0/1) matrix of species occurrences across sites, as given in the

Re: [R] data transformation

2008-07-22 Thread Marc Schwartz
on 07/22/2008 11:24 AM Christian Hof wrote: Dear all, how can I, with R, transform a presence-only table (with the names of the species (1st column), the lat information of the sites (2nd column) and the lon information of the sites (3rd column)) into a presence-absence (0/1) matrix of

[R] data transformation

2008-05-02 Thread Christian Hof
Dear all, how can I, with R, transform a presence-absence (0/1) matrix of species occurrences into a presence-only table (3 columns) with the names of the species (1st column), the lat information of the sites (2nd column) and the lon information of the sites (3rd column), as given in the

Re: [R] data transformation

2008-05-02 Thread Christos Hatzis
PM To: r-help@r-project.org Subject: [R] data transformation Dear all, how can I, with R, transform a presence-absence (0/1) matrix of species occurrences into a presence-only table (3 columns) with the names of the species (1st column), the lat information of the sites (2nd column

Re: [R] data transformation

2008-05-02 Thread Kingsford Jones
Hi Christian, Here's a way using the reshape package: dfr site lat lon spec1 spec2 spec3 spec4 1 site1 10 11 1 0 1 0 2 site2 20 21 1 1 1 0 3 site3 30 31 0 1 1 1 library(reshape) dfr - melt(dfr[, -1], id=1:2, variable_name='species')

Re: [R] data transformation

2008-05-02 Thread Henrique Dallazuanna
Try this: newx - with(x, cbind(stack(x, select = grep(spec, names(x))), lat, lon)) newx[newx$values 0, -1] On 5/2/08, Christian Hof [EMAIL PROTECTED] wrote: Dear all, how can I, with R, transform a presence-absence (0/1) matrix of species occurrences into a presence-only table (3 columns)