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
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
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
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
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
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
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
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
8 matches
Mail list logo