Displaying 20 results from an estimated 84 matches for "recast".
2011 Mar 16
1
linear regression in a data.frame using recast
...ave a very large dataset with columns of id number, actual value,
predicted value. This used to be a time series but I have dropped the
time component. So I now have a data.frame where the id number is
repeated but each value in the actual and predicted columns are
unique.
I assume I need to use recast somehow but I'm at a loss... how can I
perform a simple linear regression (using lm()?) on my two variables
for each unique id number?
additionally, I need to fix the y-intercept at zero.
Thanks for your help,
Justin
2011 Nov 29
2
Help with recast() syntax
...ULT", "YR_MO",
"POS_TESTS", "NEG_TESTS"), class = "data.frame", row.names = c(NA,
-11L))
As this is something that I understand Hadley Wickham's Reshape package is ideally suited for, I tried using the following reshape command:
ReshapeDF <- recast(DF, YR_MO~variable)
I get the following error message:
Using RESULT as id variables
Error: Casting formula contains variables not found in molten data: YR_MO
I have a work around that allows me to get to my desired endpoint that involves splitting the data.frame into two (by test result), the...
2011 Mar 16
1
linear regression in a data.frame using recast -- A fortunes candidate??
Ha! -- A fortunes candidate?
-- Bert
>
> If this is really a time series, then you will have serious validity
> problems due to auto-correlation among non-independent units. (But if you
> are just searching for a way to pull the wool over the eyes of the
> statistically uninformed, then I guess there's no stopping you.)
>
> --
>
> David Winsemius, MD
> West
2009 Dec 04
5
logical masking of a matrix converts it to a vector
...w = 2)
> a
[,1] [,2]
[1,] 1 3
[2,] 2 4
> rmask <- c(TRUE, FALSE)
> b <- a[rmask, ]
> colSums(b)
Error in colSums(b) : 'x' must be an array of at least two dimensions
To ensure the code works regardless of how the matrix gets modified, I need
to explicitly recast results to a matrix, for example:
b <- matrix(a[rmask, ], ncol = 2)
This can get messy, requiring extra work to maintain column/row names or
additional commands to determine the correct dimensions of the matrix (for
example, if I'm masking both rows and columns simultaneously). Is there a...
2006 Feb 02
4
How to force a vector to be column or row vector?
Hi all,
I tended to use rbind, or cbind to force a vector be be deemed as a column
or row vector. This is very important if I want to do things like u' * A *
u, where u' is a row vector and u is a column vector, regardless of what
originall format the "u" is... I want to recast it to column vector or row
vector... How can I do that?
----------------------------------------------------
b_hat=solve(t(X) %*% X) %*% t(X) %*% Y;
attr(b_hat, "dim")
[1] 4 1
rbind(b_hat)
[,1]
-4.814763
V -5.804245
-5.122668
-4.308326
[[alternative HTML version delet...
2010 Oct 13
2
[LLVMdev] [Q] x86 peephole deficiency
...of zapping it.
Hi Chris,
I had a look into MachineCSE, but it looks like MBB-oriented.
The above problem is an inter-block one. Also MCSE seems
to perform value numbering on virtual/physical registers, which
does not map very well to status register bits that are implicitly
defined.
Any chance to recast this issue as a target-independent
(but cmp-specific) peephole problem, that just looks into
predecessor blocks and applies (target-hook-like) subsumption
checks for 'cmp' instructions?
I am thankful for any hint,
cheers,
Gabor
>
> -Chris
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
...lder 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 dataframe:
dfc <- cast(dfm, Var1 + Var2 + Var3 + Var4 ~ species,max) # with reshape
dfc <- dcast(dfm, Var1 + Var2 + Var3 + Var4 ~ species,max) # with reshape2
but then I get (this is new to reshape2!) a warning message:
In .fun(.value[0], ...) : no non-missing arguments to max; returning...
2010 Oct 13
0
[LLVMdev] [Q] x86 peephole deficiency
...; I had a look into MachineCSE, but it looks like MBB-oriented.
> The above problem is an inter-block one. Also MCSE seems
> to perform value numbering on virtual/physical registers, which
> does not map very well to status register bits that are implicitly
> defined.
> Any chance to recast this issue as a target-independent
> (but cmp-specific) peephole problem, that just looks into
> predecessor blocks and applies (target-hook-like) subsumption
> checks for 'cmp' instructions?
I think that extending MachineCSE to do a simple dominator tree walk with llvm::ScopedHas...
2006 Feb 12
0
SUMMARY: aggregate vs. tapply
...st(A=A,B=B),sum))
tmp2 <- expand.grid(A=sort(unique(tmp$A)),B=sort(unique(tmp$B)))
merge(tmp2,tmp1,all.x=T)
hadley wickham:
Well, you can almost do this in with the reshape package:
tmp <-
data.frame(A=sample(LETTERS[1:5],10,replace=T),B=sample(letters[1:5],10,replace=T),C=rnorm(10))
a <- recast(tmp, A + B ~ ., sum)
# see also recast(tmp, A ~ B, sum)
add.all.combinations(a, row="A", cols = "B")
Good thing there are so many code cats around, 'cause we have so darn
many ways to skin 'em. Thanks again to all who took the time to answer!!
-Joseph
--
**********...
2001 Mar 20
3
Newbie question about by() -- update
Sorry about the lack of detail. I am running R v.1.2.2. I can recast my
question
(which I think I have partially answered) more succinctly as follows:
1. This seems to work (note that group takes values 1,2,3,4, or 5):
my.newfun <- function(x) myfile <- lm(award ~ ilogemp + ilogage, x)
test.by <- by(wintemp, as.factor(wintemp$group), my.newfun)
2. Thi...
2011 Nov 02
2
Proper Syntax for Logical Subset in Subset()
I have measured values for 47 chemicals in a stream. After processing
the original data frame through reshape2, the recast data frame has this
structure:
'data.frame': 256 obs. of 47 variables:
$ site : Factor w/ 143 levels "BC-0.5","BC-1",..: 1 1 1 2 2 2 2 2 2 2
...
$ sampdate : Date, format: "1996-04-19" "1996-05-21" ...
$ Acid : num NA NA NA NA NA NA N...
2012 Jan 13
1
apply transformation
...= c(0.0065, 0.0082, 0.0122)), .Names =
c("Year",
"2006", "2007"), row.names = c("Jan", "Feb", "Mar"), class =
"data.frame")
I am trying to use the apply function but the values seem to be
getting coerced to characters. I could recast in my function ... but I
suspect there should be an easier way.
I can always use a for loop to get the output I need but just
wondering if there a way to get the same using apply or some other
function ... (the number of years can be changing in my requirement)
My final output needs to be as foll...
2012 Apr 17
1
Cummerbund differential expression data analysis package issue
...altrans/tophat/0125diff_out')
Creating database
/home/sbica1/tophat/finaltrans/tophat/0125diff_out/cuffData.db
Reading
/home/sbica1/tophat/finaltrans/tophat/0125diff_out/genes.fpkm_tracking
Checking samples table...
Populating samples table...
Writing genes table
Reshaping geneData table
Recasting
Writing gene
Data table
Reading /home/sbica1/tophat/finaltrans/tophat/0125diff_out/gene_exp.diff
Error in function (classes, fdef, mtable) : unable to find an inherited
method for function "make.db.names", for signature "SQLiteConnection",
"integer"
csVolcano...
2007 Jan 09
1
contingency table analysis; generalized linear model
...as.data.frame(xtabs(~Age+Site, data=SSites.Rev, drop.unused.levels=T))
glm(Freq ~ Age + Site, data=glm.table, family='poisson')
where Site is a factor and Age is cast as a factor by xtabs() and treated as such.
**Question**:
Is it acceptable to step away from contingency table analysis by recasting Age as a numerical variable, and redoing the analysis as:
glm(Freq ~ as.numeric(Age) + Site, data=glm.table, family='poisson')
My reasons for wanting to do this are to be able to include non-linear terms in the model, using say restricted or natural cubic splines.
Thank you in advance...
2016 Apr 11
0
[FORGED] Re: identical() versus sapply()
...lain this one:
> str(1)
num 1
> str(1:2)
int [1:2] 1 2
> str(as.numeric(1:2))
num [1:2] 1 2
> str(as(1:2,"numeric"))
int [1:2] 1 2
Which doubly makes no sense. 1) Either the class is "numeric" or it isn't; I did not call as.integer() here. 2) method of recasting should not affect final class.
Thanks,
Ariel
-----Original Message-----
From: Rolf Turner [mailto:r.turner at auckland.ac.nz]
Sent: Saturday, April 09, 2016 5:27 AM
To: Jeff Newmiller
Cc: Paulson, Ariel; 'r-help at r-project.org'
Subject: Re: [FORGED] Re: [R] identical() versus sappl...
2009 May 09
1
Improve aggregate.default ...?
...oup = Group), FUN = mean))
Group x
1 1 0.6523228
2 2 0.4544317
3 3 0.4619624
4 4 0.4703156
This arises because aggregate default has:
function (x, ...)
{
if (is.ts(x))
aggregate.ts(as.ts(x), ...)
else aggregate.data.frame(as.data.frame(x), ...)
}
which recasts x as a data frame, but doesn't make any effort to supply a
name. Can we do a better job of supplying a useful name?
My first attempt is:
aggregate.default <- function(x, ...) {
if (is.ts(x))
aggregate.ts(as.ts(x), ...)
else {
nam <- deparse(substitute(x))...
2011 Sep 26
1
Restructuring data - unstack, reshape?
...th 2 sets of
offices/scores and null values in the second set if they've only applied
once for that specialty. Can anyone help me out with this? Is it possible
using stack or reshape?
Many thanks for reading,
Jan
PS Closest I've come to what I need is the sparse matrix produced by this:
recast(spec.scores, Candidate.ID ~ Specialty + Office, measure.var="Score")
[[alternative HTML version deleted]]
2011 Oct 21
2
stacked plot
...lot2 but i
think that qplot wants the data to be like this:
file.1 code.1 2
file.1 code.2 0
file.1 code.3 0
file.1 code.4 5
file.1 code.5 4
file.2 code.1 3
file.2 code.2 18
....
I think that I need to use the package "reshape", but I am not sure
whether to use cast(), melt(), or recast() and how to set up the
function.
Thanks,
Henri-Paul
--
Henri-Paul Indiogine
Curriculum & Instruction
Texas A&M University
TutorFind Learning Centre
Email: hindiogine at gmail.com
Skype: hindiogine
Website: http://people.cehd.tamu.edu/~sindiogine
2016 Apr 11
5
[FORGED] Re: identical() versus sapply()
...str(1:2)
> int [1:2] 1 2
>
>> str(as.numeric(1:2))
> num [1:2] 1 2
>
>> str(as(1:2,"numeric"))
> int [1:2] 1 2
>
> Which doubly makes no sense. 1) Either the class is "numeric" or it isn't; I did not call as.integer() here. 2) method of recasting should not affect final class.
>
> Thanks,
> Ariel
>
>
> -----Original Message-----
> From: Rolf Turner [mailto:r.turner at auckland.ac.nz]
> Sent: Saturday, April 09, 2016 5:27 AM
> To: Jeff Newmiller
> Cc: Paulson, Ariel; 'r-help at r-project.org'
> Sub...
2005 Oct 29
3
CentOS proviiding additional services > was Setting up Tomcat
...ing such a compendium of instructions on the CentOS Forum and
keeping the compendium up to date? Think how many hours of googling
and searching mail archives and copious RTFM could be saved! Instead
of firing off a mail to this list, you could first look in a well
known place on the Forum and avoid recasting a round object.
I'm not in a position to undertake such an endeavor. I keep current
with CentOS, and I want to see CentOS thrive, but I have only a
peripheral interest in CentOS, and that peripheral interst is a work
connection. My employer, like many others, prefers to have a
contractural...