Displaying 20 results from an estimated 5000 matches similar to: "Using as.formula() with the reshape package cast"
2008 Sep 28
1
reshape package does not recognize second id variable
I am trying to use the reshape package for the first time. I have two
waves of a survey, so the id variables include a subject
identification number and a variable denoting the wave of the survey.
I used the following arguments:
library(reshape)
svy.melt <- melt(svy, id=c("id", "WAVE"))
svy.wide <- cast(svy.melt, id ~ WAVE + ...)
and got the following error:
2009 Aug 17
3
Reshape package: Casting data to form a grid
Dear R Users,
I'm trying to use the 'cast' function in the 'reshape' package to convert column-format data to gridded-format data. A sample of my dataset is as follows:
head(finalframe)
Latitude Longitude Temperature OrigLat p-value Blaney
1 -90 -38.75 NA -87.75 17.10167 NA
2 -90 135.75 NA -87.75 17.10167 NA
3 -90 80.25
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>
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 =
2008 Jul 01
2
plot.zoo labels
I would like to know if there is a way to use plot(zoo) and suppress the
label text to increase the amount of the screen that if for the plot and
not the labels. I tried xy.labels=FALSE, but that had no effect. Thanks
[[alternative HTML version deleted]]
2009 Jan 26
1
reshape problem: id and variable names not being recognized
Hi everyone. Long time listener, first-time caller here.
I have a data set that's been melted with the excellent reshape package, but
I can't seem to cast it the way I need to.
Here's the melted data's structure:
> str(mdat)
'data.frame': 6978 obs. of 4 variables:
$ VehType : Factor w/ 2 levels "Car","Truck": 1 1 2 1 1 2 1 1 1 1 ...
$ Year :
2009 Mar 31
1
Reshape: 'melt' numerous objects
Dear R Users,
I'm trying to use the reshape package to 'melt' my gridded data into column format. I've done this before on individual files, but this time I'm trying to do it on a directory of files (with variable file names) - therefore I have to also use the 'assign' command. I have come up against a couple of problems however and am therefore seeking advice...
>
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 Apr 19
1
Formatting data, adding column names, use reshape, a newbie question
Hi all,
I'm an R novice.
I have data that's already formatted as "molten" that reshape should be able
to work with. For example, the following was read in with
read.csv(filename,sep=" ", header=FALSE)
V1 V2 V3 V4
V5
1 original book book.source1.txt 328900494 3039.525
2 original book book.source1.txt
2012 Apr 23
1
ggplot2 - geom_bar
Hello,
I've some problem with the ggplot2. Here's a small example:
--8<--
library(ggplot2)
molten <- data.frame(date=c('01','01','01','01',
'02','02','02','02'),
channel=c('red','red','blue','blue',
2008 Feb 15
2
For Subset or Reshaping the Table
Hi R users
I am a new user in the field of R.
I want to subset or reshape a data.frame.
For example I have a matrix like
A B C D E F G
a 1 2 3 4 5 6 7
b 4 6 8 9 5 5 6
c 3 4 4 4 3 3 6
d 1 2 4 6 8 8 9
e 5 6 7 8 9 2 3
I want to reshape the matrix in this format
Row Col Value
a D 4
a E 5
a F 6
. . ..
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
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 <-
2011 Nov 29
2
Help with recast() syntax
Dear Help-Rs,
I have data similar to the following:
DF <- structure(list(X = 1:22, RESULT = structure(c(2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = c("NEG", "POS"), class = "factor"), YR_MO = c(201011L,
201012L, 201101L, 201102L, 201103L, 201104L, 201105L, 201106L,
201107L, 201108L, 201109L, 201011L,
2008 Mar 25
2
ggplot2 - facetting
Dear All,
After having overcome the issue of legends (thanks, Thierry, once
more), I am trying to use facetting, but here also I can not find how
to do this. I do not want to use qplot, but rather the more flexible
options. However, it seems I am doing still something pretty stupid,
because I always get an error, even if it seems I am doing everything
like the examples.
My code is below.
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
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
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
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
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 <-