Displaying 20 results from an estimated 2000 matches similar to: "understanding the FUNCTION function"
2009 May 22
1
regrouping factor levels
Hi all,
I had some trouble in?regrouping factor levels for a variable. After some experiments, I have figured out how I can recode to modify the factor levels. I would now like some help to understand why some methods work and others don't.
Here's my code :
rm(list=ls())
###some trials in recoding factor levels
char<-letters[1:10]
fac<-factor(char)
levels(fac)
print(fac)
##first
2010 Apr 21
5
Bugs? when dealing with contrasts
R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with
2012 May 29
1
GAM interactions, by example
Dear all,
I'm using the mgcv library by Simon Wood to fit gam models with interactions and I have been reading (and running) the "factor 'by' variable example" given on the gam.models help page (see below, output from the two first models b, and b1).
The example explains that both b and b1 fits are similar: "note that the preceding fit (here b) is the same as
2003 Feb 14
2
factorial function
Sorry for the stupid question, but is there the factorial function in
R? I tried to find it using help.search('factorial') but got nothing
appropriate.
Many thanks,
-Serge
2012 Feb 29
2
Using a FOR LOOP to name objects
Hello,
I am trying to use a for loop to name objects in each iteraction. As in the
following example (which doesn't work quite well)
my_list<-c("A","B","C","D","E","F")
for(i in c(1:length(my_list))){
url<- "http://finance.yahoo.com"
doc = htmlTreeParse(url, useInternalNodes = T)
tab_nodes = xpathApply(doc,
2012 Apr 24
2
Use quotes on a FOR LOOP R
Hello All!
I need some help to get a FOR LOOP to print the interactor with the
quotation mark.
Let me be more specific:
I have the following:
cbind("Michael","Dana","Rob")->LIST
outcome:
[,1] [,2] [,3]
[1,] "Michael" "Dana" "Rob"
UNFORTUNATELY, I need to do the following:
as.data.frame.list(LIST)->LIST2
rm(LIST)
2012 Apr 01
3
Filling empty List in a FOR LOOP
Hello all,
I am trying to automate a list to be filled in a FOR LOOP.
Basically I need to load info from a third source and store it into a list.
This list goes to object "A"; The next list brought in by the LOOP goe to
object "B".. os on ans so forth.
When the iteration on the LOOP goes well (which means it isn't empty) I get
something like this:
A
[[1]]
2012 Nov 29
5
bootstrapped cox regression (rms package)
Hi,
I am trying to convert a colleague from using SPSS to R, but am having
trouble generating a result that is similar enough to a bootstrapped cox
regression analysis that was run in SPSS. I tried unsuccessfully with
bootcens, but have had some success with the bootcov function in the rms
package, which at least generates confidence intervals similar to what is
observed in SPSS. However, the
2004 May 12
6
Design matrix not identity
Hello again,
I was too quick before. What I was looking for was a function that
constructs the design (or incidence) matrix (X in a linear model) from a
factor. Uwe Ligges suggested using model.matrix and this does almost what I
want, but it is first necessary to construct a data variable. It also asigns
ones to all rows of the first column (because this is set to be the
contrast, not really what
2008 Sep 09
1
How do I compute interactions with anova.mlm ?
Hi,
I wish to compute multivariate test statistics for a within-subjects repeated measures design with anova.mlm.
This works great if I only have two factors, but I don't know how to compute interactions with more than two factors.
I suspect, I have to create a new "grouping" factor and then test with this factor to get these interactions (as it is hinted in R News 2007/2),
but
2011 Oct 03
1
function recode within sapply
Dear List,
I am using function recode, from package car, within sapply, as follows:
L3 <- LETTERS[1:3]
(d <- data.frame(cbind(x = 1, y = 1:10), fac1 = sample(L3, 10,
replace=TRUE), fac2 = sample(L3, 10, replace=TRUE), fac3 = sample(L3,
10, replace=TRUE)))
str(d)
d[, c("fac1", "fac2")] <- sapply(d[, c("fac1", "fac2")], recode,
"c('A',
2003 Nov 16
1
DOE support in R and fac.design
Hi,
I've searched through the contributed packages and found conf.design
which supports factorial design generation - is there any way to specify
the values of the levels in the functions in this library? Currently the
default for 2 level designs are the levels 0 and 1. Reason I ask is I'd
like to create a Central Composite design and to do this by appending to
a factorial design, it
2007 Oct 17
1
passing arguments to functions within functions
Dear R Users,
I am trying to write a wrapper around summarize and xYplot from Hmisc
and am having trouble understanding how to pass arguments from the
function I am writing to the nested functions.
There must be a way, but I have not been able to figure it out.
An example is below.
Any advice would be greatly appreciated.
Thanks, Dan
# some example data
df=expand.grid(rep=1:4,
2002 Jun 04
2
Scaling on a data.frame
Hey,
hopefully there is an easy way to solve my problem.
All that i think off is lengthy and clumsy.
Given a data.frame d with columns VALUE, FAC1, FAC2, FAC3.
Let FAC1 be something like experiment number,
so that there are exactly the same number of rows for each level of FAC1
in the data.frame.
Now i would like to scale all values according to the center of its
experiment.
So i can apply s
2009 Jun 03
1
Need help understanding output from aov and from anova
Hi all,
I noticed something strange when I ran aov and anova.
vtot=c(7.29917, 7.29917, 7.29917) #identical values
fac=as.factor(c(1,1,2)) #group 1 has first two elements, group 2 has
the 3rd element
When I run:
> anova(lm(vtot~fac))
Analysis of Variance Table
Response: vtot
Df Sum Sq Mean Sq F value Pr(>F)
fac 1 1.6818e-30 1.6818e-30 0.3333 0.6667
Residuals 1
2009 Jul 09
5
Best way to export values from a function?
Maybe there is a great website out there or white paper that discusses this but again my Google skills (or lack there of) let me down.
I would like to know the best way to export several doubles from a function, where the doubles are not an array.
Here is a contrived function similar to my needs:
multipleoutput<-function(x)
{
squared<-x^2
cubed<-x^3
exponentioal<-exp(x)
2006 Feb 09
4
sip to oh323 converter converts sip uri to h.323 number and not h.323 url
Hello,
i have set up an asterisk sip to h.323 convertor, it is working OK. The only problem i have is this :
For example when my identity is 12345@some.domain , and i call a sip number from a sip phone, the called party sees my identity (caller identity) as 12345@some.domain, which is the way it has to be.
But when i call from the same phone with the same identity a h.323 endpoint (asterisk
2009 Aug 08
4
how to get id of other table
Hi All,
I have a doubt regarding join tables
I''m having 2 models
1)Fac
2)Cont
and both models have " has and belong to many" relationships
so there are 3 tables
1)facs
2)conts
3)conts_facs
then i''m fetching the data in controller as
@conts=Cont.find(:all])
@cfacs=Fac.all(:joins=>:conts, :select=>"facs.name")
but i dont know how to get the
2013 Jan 17
3
Colors in interaction plots
Hi,
I am trying to plot an interaction.plot with different color for each
level of a factor. It has an erratic behavior.
For example, it works for the first interaction.plot below, with the
example from the ALDA book, but not with the other plots, from the NPK
dataset:
# from http://www.ats.ucla.edu/stat/r/examples/alda/ch2.htm
tolerance <-
2006 Apr 14
5
vector-factor operation
I found myself wanting to average a vector [vec] within each level of a
factor [Fac], returning a vector of the same length as vec. After a
while I realised that
lm1 <- lm(vec ~ Fac)
fitted(lm1)
did what I want.
But there must be another way to do this, and it would be good to be
able to apply other functions than mean() in this way.
Cheers, Murray
--
Dr Murray Jorgensen