t;> #2 foo 36 33
>> #3 foo 35 39
>> #4 foo1 29 37
>> #5 foo1 37 29
>> #6 foo1 34 30
>> A.K.
>>
>>
>> - Original Message -
>> From: Abhishek Pratap
>> To: "r-help@r-project.org"
>> Cc:
>> Sen
r-project.org"
Cc:
Sent: Monday, June 10, 2013 2:15 AM
Subject: [R] reshaping a data frame
Hi Guys
I am trying to cast a data frame but not aggregate the rows for the
same variable.
here is a contrived example.
**input**
temp_df <-
data.frame(names=c('foo','foo'
---
> From: abhishek@gmail.com
> Sent: Sun, 9 Jun 2013 23:15:48 -0700
> To: r-help@r-project.org
> Subject: [R] reshaping a data frame
>
> Hi Guys
>
> I am trying to cast a data frame but not aggregate the rows for the
> same variable.
>
> here is a contrived ex
Abhi,
In the example you give, you don't really need to reshape the data ... just
rename the column "value" to "w".
Here's a different example with more than one category ...
tempdf <- expand.grid(names=c("foo", "bar"), variable=letters[1:3])
tempdf$value <- rnorm(dim(tempdf)[1])
tempdf
library(r
Hi Guys
I am trying to cast a data frame but not aggregate the rows for the
same variable.
here is a contrived example.
**input**
temp_df <-
data.frame(names=c('foo','foo','foo'),variable=c('w','w','w'),value=c(34,65,12))
> temp_df
names variable value
1 foow34
2 foow
Hi Bill,
Here is a reshape package version. The key thing to notice is that you
have multiple pieces of information in your original column names.
These can be split out using the colsplit() function:
# Read in the data
cattle <- read.csv("http://n4.nabble.com/attachment/1745223/0/CattleGrowth.csv
Try this:
cattle <- read.csv("http://n4.nabble.com/attachment/1745223/0/CattleGrowth.csv";)
long <- reshape(cattle, dir = "long", idvar = "Steer.ID",
varying = list(grep("Date", names(cattle)), grep("Days",
names(cattle)), grep("Wt",names(cattle
On Tue, Mar 30, 2010 at 9:34 AM, wclapham
Ista,
I have looked at the reshape package and have used Âmelt¹ successfully on
simpler tables. I tried it here, but have not been successful. I think I
just need to gain experience. I am loving R and am having a difficult time
with data structure issues.
I am attaching the data set that I
Hi Bill,
Without an example dataset it's hard to see exactly what you need to
do. But you can get started by looking at the documentation for the
reshape function (?reshape), and by looking at the reshape package.
The reshape package has an associated web page
(http://had.co.nz/reshape/) with links
I have a data frame that I created using read.table on a csv spreadsheet.
The data look like the following:
Steer.ID stocker.trt Finish.trt Date Days Wt ..
Steer.Id, stocker.trt, Finish.trt are factors-- Date, Days, Wt are data
that are repeated 23 times (wide format).
I want t
On 10/27/2009 07:09 AM, Erin Hodgess wrote:
Dear R People:
Suppose I have a data.frame, x.df, which has one column and 100 rows.
Sometimes I need to see it as 20 rows and 5 columns, sometimes I need
to see it as 10 rows with 10 columns.
Is there a quick way to make those transformations, pleas
matrix(bb, nrow=20))
--- On Mon, 10/26/09, Erin Hodgess wrote:
> From: Erin Hodgess
> Subject: [R] reshaping a data frame
> To: "R help"
> Received: Monday, October 26, 2009, 4:09 PM
> Dear R People
Dear R People:
Suppose I have a data.frame, x.df, which has one column and 100 rows.
Sometimes I need to see it as 20 rows and 5 columns, sometimes I need
to see it as 10 rows with 10 columns.
Is there a quick way to make those transformations, please?
Thanks in advance,
Sincerely,
Erin
PS Happ
13 matches
Mail list logo