similar to: reshape package cast() function

Displaying 20 results from an estimated 900 matches similar to: "reshape package cast() function"

2011 Jun 24
0
reshape: cast(x, a ~ b ~ .) vs. cast(x, a ~ b) difference
Hi, I have a problem with understanding what the function cast() from the package reshape is doing. In the example below I have a 2x2x2 array which I first melt and then cast to get the averages over the field 'strain' for every combination of the fields 'treatement' and 'gene': ------ > mdat <- melt(array(rnorm(8), dim=c(2,2,2),
2008 Jun 17
1
re sultant column names from reshape::cast, with a fun.aggregate vector
try this: scores.melt = data.frame(grade = floor(runif(100, 1,10)), variable = 'score', value = rnorm(100)); cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, length)) it has the nice column names of: grade score_mean score_length 1 1 0.08788535 8 2 2 0.16720313 15 3 3 0.41046299 7 4 4 0.13928356 13 ... but
2008 Jul 30
1
bug in 'margins' behavior in reshape - cast
according to the documentation of the cast function in the reshape function, I would expect this bit of code from the examples to calculate marginal means over only the 'diet' variable. #Chick weight example names(ChickWeight) <- tolower(names(ChickWeight)) chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE) cast(chick_m, diet + chick ~ time, mean, margins="diet") But,
2011 May 31
1
reshape::cast: invalid 'yinds' argument
Hi, I'm using reshape to cast molten data. When I use the following command, R either crashes (when I use Notepad++) or gives an error (when I use Rgui or source()), BUT the error occurs not always, maybe only on half the attempts: w <- cast(v, id + code + productname + year + begin + end + specificDesc + specificDesc2 ~ type) Error in merge.data.frame(data, all.combinations, by =
2012 Aug 14
1
reshape cast to a sparse matrix?
I am using the reshape package to convert a series of values into a binary matrix. The binary matrix is very sparse with many zeros and I'd like to use cast to generate a sparse matrix using any of the sparse matrix packages of choice. Is there functionality to support this use? Are there strategies or other packages that that may be useful? Due to memory constraints, it would be best to
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
2008 Aug 05
1
RESHAPE cast help.
I have a set of data that is basically sales figures for a given year. It has columns for Yeaqr, Day Of Year, Sku, SubCatetory, and Category. The first few lines of data look like: Year DayOfYear Sku Quantity CatId Category SubCategory 1 2007 1 100091 1 10862 HOLIDAY Christmas 2 2007 1 100138 1 11160 PET COSTUMES Famous
2012 May 21
1
help with melt/cast in reshape-package
I'm sorry everyone for the inconvenience of spamming the R-help... Here's the complete post: Hi everyone, > > Since it's quite a while that I used the reshape package, I now feel kind > of rusty. > > I have a data.frame like this: > > > > id Sample.Name Marker Allele.1 > Allele.2 sample_id species
2011 Oct 01
2
Help with cast/reshape
I realize that this is terribly basic, but I just don't seem to see it at this moment, so I would very much appreciate your help. How shall I transform this dataframe: > df1 ? Name Index Value 1??? a???? 1?? 0.1 2??? a???? 2?? 0.2 3??? a???? 3?? 0.3 4??? a???? 4?? 0.4 5??? b???? 1?? 2.1 6??? b???? 2?? 2.2 7??? b???? 3?? 2.3 8??? b???? 4?? 2.4 into this dataframe: > df2 ??? Index?
2009 Nov 23
1
recognizing variable-names of cast() (package: reshape)
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091123/3b4cbdd5/attachment-0001.pl>
2010 Aug 16
1
Problem with cast {reshape}: Error in match.fun(FUN) : could not find function "Negate"
Dear All I'm having problem with some script which worked a few months ago (on a different computer that might well have had a different version of R installed, so perhaps it has to do with the old version of R?): library(reshape) Loading required package: plyr > tble.data <- melt.array(interp, varnames=c("tme","lon","lat")) > > allyrs.interp <-
2009 Apr 07
2
Using as.formula() with the reshape package cast
I am trying to use the "cast" function from the reshape package, where the formula is not passed in directly, but as the result of the as.formula() function. Using reshape v. 0.7.2 I am able to properly melt() by data with: > molten <- melt(x, id=1:2) then I can properly cast with this: > cast(molten, days ~ variable) but if I try > cast(molten,
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
2009 Apr 17
1
cast function in package reshape
Hello R useRs, I have a function which returns a list of functions : freq1 <- function(x) { lev <- unique(x[!is.na(x)]) nlev <- length(lev) args <- alist(x=) if (nlev == 1) { body <- c("{", "sum(!is.na(x))", "}") f <- function() {} formals(f) <- as.pairlist(args) body(f) <- parse(text = body) namef <-
2007 Nov 21
1
Help Required in using cast (reshape package) function
Hello everyone, I am new to R. I have data in the form of excel pivot table format and I want to cast it into a format which can make it compatible with computation. Since I already have the package in pivot format; I avoid melt function and use the cast directly. I inspect the dataread <- read.csv(".....", header=TRUE) Data in the format Id Region Country Industry
2011 Mar 10
2
Reshape, melt and cast query
I have a dataset that is based on crop output for a single crop *sugarcane*...but each observation is further subdivided into 3 kinds of sugarcane i have read the file and have also used melt it to sort it on the basis of *crop group* using melt(sugarcane, m=c("Crop_group")) -> canefile this is how it has cast the data variable value 1 Crop_group Sugarcane
2009 Jul 10
2
ReShape/cast question - sum of value in table
Hi, I've tried to capture the basics of this problem I'm having. Been working on this for a couple of days and just cannot get past it. As a test of this list software I've attached is a small text file zipped up. I hope it gets through but if it doesn't I'll post the actual text which is only 26 lines. Put it somewhere sensible and change the first line in the code to point
2011 Jun 09
2
Reshape:cast; error using "..." in formula expression.
Whenever I use "..." in the formula of the cast function, from the reshape package, I get the following error: Error in `[.data.frame`(data, , variables, drop = FALSE) : undefined columns selected For example: data(french_fries) #available in the reshape package > head(french_fries) time treatment subject rep potato buttery grassy rancid painty 61 1 1 3 1
2010 Mar 12
1
Length as fun.aggregate in cast function of reshape package: unexpected error
Dear Everyone, I am having problems with use of the reshape package's cast function using length as an aggregating function. Unexpectedly, I receive the error: 2 arguments passed to 'length' which requires 1 I don't understand this at all - the data I'm using is very simple, and appears almost identical to that used in the ChickWeight example in the package. The problem can
2008 Feb 07
1
Problems reshaping data with cast()
Hi, I'm trying to cast() some data, but keep on getting the following error... > norm.all.melted.height <- transform(all.melted.height, + norm.height = value / ave(value, SNP, Pool, FUN = max) + ) Warning messages: 1: In FUN(X[[147L]], ...) : no non-missing arguments to max; returning -Inf 2: In FUN(X[[147L]],