Displaying 20 results from an estimated 4000 matches similar to: "Transform a dataset from long to wide using reshape2"
2010 Nov 01
2
transforming a dataset for association analysis RESHAPE2
I get the following message when using the reshape2 package line
> tDat.m<- melt(Dataset)
Using Item, Subject as id variables
> tDatCast<- acast(tDat.m,Subject~Item)
Aggregation function missing: defaulting to length
Note Problem Statement-
convert dataframe
Subject Item Score
1 Subject 1 Item 1 1
2 Subject 1 Item 2 0
3 Subject 1 Item 3 1
4 Subject 2 Item 1 1
5
2011 Aug 08
1
Reshape2 sytax
Hi Hadley et all,
I am struggling with reshape2 and melt works and melt_check
(filtered151) seems fine
My cast command was acast (filtered151, Time ~ Species ~ Number)
> melt_check (filtered151)
Using time, Species as id variables
$id
[1] "time" "Species"
$measure
[1] "Number"
When I execute cast the data matrix is in the correct order but the data
2011 Aug 08
1
Help on reshape2 data frame rearrangement
Dear help list: I am trying to reshape a data frame from long to wide format and with a reduced variable list using reshape2. The original data frame format is: Site Obs_no LengthSite 1 Obs 1 10Site 1 Obs 2 13Site 1 Obs 3 14.........Site 2 Obs 1 5Site 2 Obs 2 7Site 2 Obs 3 9 Site and Obs_no are factors and Length is a numeric variable. There are 15
2010 Sep 10
0
reshape2: a reboot of the reshape package
Reshape2 is a reboot of the reshape package. It's been over five years
since the first release of the package, and in that time I've learned
a tremendous amount about R programming, and how to work with data in
R. Reshape2 uses that knowledge to make a new package for reshaping
data that is much more focussed and much much faster.
This version improves speed at the cost of functionality,
2010 Sep 10
0
reshape2: a reboot of the reshape package
Reshape2 is a reboot of the reshape package. It's been over five years
since the first release of the package, and in that time I've learned
a tremendous amount about R programming, and how to work with data in
R. Reshape2 uses that knowledge to make a new package for reshaping
data that is much more focussed and much much faster.
This version improves speed at the cost of functionality,
2011 Jan 04
0
reshape2 1.1
Reshape2 is a reboot of the reshape package. It's been over five years
since the first release of the package, and in that time I've learned
a tremendous amount about R programming, and how to work with data in
R. Reshape2 uses that knowledge to make a new package for reshaping
data that is much more focussed and much much faster.
This version improves speed at the cost of functionality,
2011 Jan 04
0
reshape2 1.1
Reshape2 is a reboot of the reshape package. It's been over five years
since the first release of the package, and in that time I've learned
a tremendous amount about R programming, and how to work with data in
R. Reshape2 uses that knowledge to make a new package for reshaping
data that is much more focussed and much much faster.
This version improves speed at the cost of functionality,
2017 Jul 03
3
reshaping the data
Dear all,
I would appreciate please a piece of help regarding the use of acast/dcast
functions in reshape2 package.
Specifically, I'm working with a data frame, that has information about
SAMPLE, GENE, and TYPE of MUTATION (as shown below):
Sample Gene Type
22M AEBP1 SNV
17M AEBP1 SNV
22M ATR INDEL
22M ATR SNV
11M BTK SNV
11M BTK
2013 Jun 05
2
reshape2 issue continued
Hi again all,
Several replied ASAP that I also needed reshape loaded and not just
reshape2.
Hmmm tried that and I had some output but not the correct format.
What I need is to run simulations of time overlap between species as per
the simulation program data input constraints:
The basis for the simulations is a species by _time-use matrix in which
species are arranged in rows, and time
2012 Jul 24
3
Simple reshape problem I am completely missing
I seem to be doing something really stupid or missing something really obvious but what?
I have a simple three column data.frame that I would like to reshape to wide preferably using reshape2.
An example from http://stackoverflow.com/questions/9617348/reshape-three-column-data-frame-to-matrix looked perfect except I wanted a data frame but it seemed okay. I just changed acast to dcast and it
2010 Oct 30
2
transforming a dataset for association analysis
Hi
I would like to transform a data frame like
Subject Item Score
Subject 1 Item 1 1
Subject 1 Item 2 0
Subject 1 Item 3 1
Subject 2 Item 1 1
Subject 2 Item 2 1
Subject 2 Item 3 0
....
*to *
Subject Item1 Item2 Item3 .....Item N
Subject1 1 0 1
Subject2 1 1 0
........
SubjectP..
Apologize for the simple nature of my query but I am stuck.
2011 Aug 02
2
Data frame to matrix - revisited
Hi,
I've tried to look through all the previous related Threads/posts but can't find a solution to what's probably a simple question.
?
I have a data frame comprised of three columns e.g.:
?
ID1?ID2?Value
a?b?1
b?d?1
c?a?2
c?e?1
d?a?1
e?d?2
?
I'd like to convert the data to a matrix i.e.:
?
?a b c d e
a n/a 1 2 1 n/a
b 1 n/a n/a 1 n/a?
c 2 n/a n/a n/a 1
d 1 1 n/a n/a 2
e n/a n/a 1
2010 Oct 01
3
scoping goes wrong when some functions are used within others.
Dear,
I'm following the r tag on stackoverflow.com, and couldn't but notice
there are quite some questions popping up that deal with scoping in
relation to custom functions. I grinded my teeth on it already, and I
have absolutely no clue what goes wrong. The general pattern is as
follows :
ff <- function(x){
y <- some_value
some_function(y)
}
> ff(x)
Error in eval(expr,
2017 Jul 03
0
reshaping the data
Hi
Do you want something like
dcast(test, Sample~Gene, fun=function(x) paste(x, collapse=","))
or
dcast(test, Sample~Gene, fun=function(x) sum(as.numeric(x)))
1 means INDEL, 2 means SNV and three means both
Cheers
Petr
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Bogdan
> Tanasa
> Sent: Monday, July 3, 2017 9:22 AM
2011 Feb 23
1
Fwd: Re: sum data from data.frame in a matrix
Hi Dennis,
Thanks for your quick response and sorry for not being clear. That
helped, but I need an actual matrix of e.g., 12 x 12 and those functions
give me a matrix with only the "filled" locations. I need a 12 by 12
matrix with sums (0 if there's not data and the actual sum where there
is) as follows:
1 2 3 4 5 6 7 8 9 10 11 12
1 0 0 0 . . . . . . 0 0 0
2 0 0 0 .
3 0
2010 Oct 04
3
can't find and install reshape2??
Hi everyone,
I’m trying to install reshape2.
But when I click on “install package” it’s not coming up!?!?! I’m getting
reshape, but no reshape2?
I’ve also tried download.packages(reshape2, destdir="c:\\") &
download.packages(Reshape2, destdir="c:\\")…but no luck!!!
Does anyone have any ideas what could be going on?
Chris Howden
Founding Partner
Tricky
2013 Feb 03
1
problem in installing reshape2 (urgent)
Dear R users,
In order to install reshape2 package, I gave the following command:
install.packages("reshape2",dep=TRUE)
However, it is not getting installed.
The message that I am getting is:
Warning: dependencies ‘plyr’, ‘stringr’, ‘testthat’ are not available
trying URL '
http://ftp.ctex.org/mirrors/CRAN/src/contrib/reshape2_1.2.2.tar.gz'
Content type
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
Hi,
I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before.
What I did/want to do:
1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far:
dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE)
2) Recast the
2011 Dec 23
2
cast in reshape and reshape2
> library(reshape2)
> x = melt(airquality, id=c('month', 'day'))
With reshape I can cast with multiple functions:
> library(reshape)
> cast(x, month+variable~., c(mean,sd))
month variable mean sd
1 5 ozone 23.615385 22.224449
2 5 solar.r 181.296296 115.075499
3 5 wind 11.622581 3.531450
4 5 temp 65.548387
2017 Jul 05
0
Help with reshape/reshape2 needed
This does not use reshape/reshape2, but it is pretty straightforward. Assuming X is your example data:
> Y <- split(X[, 2], X[, 1])
> vals <- sapply(Y, length)
> pad <- max(vals) - vals
> Y2 <- lapply(seq_along(Y), function(x) c(Y[[x]], rep(NA, pad[x])))
> names(Y2) <- names(Y)
> X2 <- do.call(cbind, Y2)
> X2[, 1:6]
1957 1958 1959