Re: [R] Transforming data

2021-05-06 Thread Jeff Newmiller
>- replace NA with 0's > >Not sure it’s the most elegant but gets the gob done > > >-Original Message- >From: R-help On Behalf Of Jeff Reichman >Sent: Thursday, May 6, 2021 2:37 PM >To: R-help@r-project.org >Subject: [R] Transforming data > >R Help F

Re: [R] Transforming data

2021-05-06 Thread Jeff Reichman
rsday, May 6, 2021 2:37 PM To: R-help@r-project.org Subject: [R] Transforming data R Help Forum I am attempting to transform the data frame in Table 1 to the form shown in Table 2. Any suggestions. I ve started by removing duplicate rows Jeff Table 1 Taxon Importer Guarouba gua

[R] Transforming data

2021-05-06 Thread Jeff Reichman
R Help Forum I am attempting to transform the data frame in Table 1 to the form shown in Table 2. Any suggestions. I�ve started by removing duplicate rows Jeff Table 1 Taxon Importer Guarouba guarouba AE Acipenser gueldenstaedtii AE Caiman crocodilus fuscus AE Caiman croc

Re: [R] Transforming data for nice output table

2018-08-21 Thread Paul Johnson
On Mon, Aug 20, 2018 at 2:17 PM David Doyle wrote: > > Hello everyone, > > I'm trying to generate tables of my data out of R for my report. > > My data is setup in the format as follows and the example can be found at: > http://doylesdartden.com/R/ExampleData.csv > > LocationDateYe

Re: [R] Transforming data for nice output table

2018-08-21 Thread David L Carlson
d L. Carlson Department of Anthropology Texas A&M University -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Monday, August 20, 2018 11:39 PM To: David Doyle ; r-help@r-project.org Subject: Re: [R] Transforming data for nice output table Sor

Re: [R] Transforming data for nice output table

2018-08-20 Thread Rui Barradas
Sorry, there is no need to subset the data frame, reshape2::dcast(dta, etc) will do the same. Rui Barradas On 21/08/2018 05:10, Rui Barradas wrote: Hello, One of those would be with package reshape2. dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv";) subdta <- dta[, c("Locat

Re: [R] Transforming data for nice output table

2018-08-20 Thread Rui Barradas
Hello, One of those would be with package reshape2. dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv";) subdta <- dta[, c("Location", "Year", "GW_Elevation")] res <- reshape2::dcast(subdta, Location ~ Year, value.var = "GW_Elevation") names(res)[-1] <- paste("GW_Elevation", names

Re: [R] Transforming data for nice output table

2018-08-20 Thread Jeff Newmiller
If departing from base R into contributed territory, tidyr::spread is well-suited to this. library(dplyr) library(tidyr) dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv"; , header = TRUE , as.is = TRUE ) result <- ( dta # starting with

Re: [R] Transforming data for nice output table

2018-08-20 Thread Jim Lemon
Hi David, As you want the _values_ of Year from the initial data frame appended to the _names_ of GW_Elevation, you can't do it the easy way: dddf<-read.table(text="LocationDateYear GW_Elevation 127(I)5/14/2006 2006 752.46 119(I)5/14/2006 2006

Re: [R] Transforming data for nice output table

2018-08-20 Thread Rui Barradas
Hello, This is a very frequent question. I could rewrite one or two answers taken from StackOverflow: https://stackoverflow.com/questions/5890584/how-to-reshape-data-from-long-to-wide-format But there you will have more options. Hope this helps, Rui Barradas On 20/08/2018 20:17, David Doyl

[R] Transforming data for nice output table

2018-08-20 Thread David Doyle
Hello everyone, I'm trying to generate tables of my data out of R for my report. My data is setup in the format as follows and the example can be found at: http://doylesdartden.com/R/ExampleData.csv LocationDateYear GW_Elevation 127(I)5/14/2006 2006 752.46

[R] transforming data prior to CCA

2013-04-05 Thread SRuhl
Hi everyone, I´m a student and relatively new to R so apologies in advance if this question seems stupid or obvious to you. I have collected a dataset with about 60 species of diatoms (count data from 19 different sample sites) and environmental variables for each site (salinity, pH, etc.). It´s al

Re: [R] transforming data based on factors in a dataframe

2012-04-25 Thread David Winsemius
On Apr 25, 2012, at 10:57 AM, Carly Huitema wrote: Hello R-help list, I would really appreciate help with my factoring problem. My generated data is this: df <- expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2)) df$curve <- as.factor(rep(1:6, each=length(seq(10,80, by=5 df$count

Re: [R] transforming data based on factors in a dataframe

2012-04-25 Thread jim holtman
try this: (uses 'ave') > df <- expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2)) > df$curve <- as.factor(rep(1:6, each=length(seq(10,80, by=5 > df$counts <- 3*df$T/df$conc + rnorm(df$T,0,2) > > plot(counts~T, df) > df$zero <- ave(df$counts, df$curve, FUN = function(x) x - min(x)) > > d

[R] transforming data based on factors in a dataframe

2012-04-25 Thread Carly Huitema
Hello R-help list, I would really appreciate help with my factoring problem. My generated data is this: df <- expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2)) df$curve <- as.factor(rep(1:6, each=length(seq(10,80, by=5 df$counts <- 3*df$T/df$conc + rnorm(df$T,0,2) plot(counts~T, df)

Re: [R] transforming data glm

2009-08-24 Thread Ben Bolker
Mcdonald, Grant wrote: > > Dear sir, > > I am fitting a glm with default identity link: > > > > model<-glm(timetoacceptsecs~maleage*maletub*relweight*malemobtrue*femmobtrue) > > the model is overdisperesed and plot model shows a low level of linearity > of the residuals. > > >> I don't

[R] transforming data glm

2009-08-24 Thread Mcdonald, Grant
Dear sir, I am fitting a glm with default identity link: model<-glm(timetoacceptsecs~maleage*maletub*relweight*malemobtrue*femmobtrue) the model is overdisperesed and plot model shows a low level of linearity of the residuals. The overdispersion and linearity of residulas on the normal Q-Q

Re: [R] Transforming data

2008-03-23 Thread jim holtman
Here are some examples of the transformations that you can do: > x <- 1:6 > x [1] 1 2 3 4 5 6 > (z <- matrix(x, ncol=2, byrow=TRUE)) [,1] [,2] [1,]12 [2,]34 [3,]56 > as.vector(z) [1] 1 3 5 2 4 6 > as.vector(t(z)) [1] 1 2 3 4 5 6 > On Sun, Mar 23, 2008 at 8:12 AM, jen

[R] Transforming data

2008-03-23 Thread jenny
My data look like this: Col1 1 2 3 4 5 6 ... My questions are: (1) How do I get it in the following format? Col1 Col2 12 34 56 ... (2) How do I transform the data in 2 column format above back to the single column format? Thanks in advance for your reply!