Displaying 20 results from an estimated 7000 matches similar to: "Create a new variable and concatenation inside a "for" loop"
2016 Apr 27
3
Create a new variable and concatenation inside a "for" loop
...
"(R is case sensitive, so "C" has no such problem)."
Well, not quite. Try ?C
To add to the previous comments, Dr. Gordon appears to need to do
her/his homework and spend some time with an R tutorial or two before
posting further here. There are many good ones on the web. Some
recommendations can be found here:
https://www.rstudio.com/online-learning/#R
Cheers,
Bert
2016 Apr 27
0
Create a new variable and concatenation inside a "for" loop
"c" an extremely commonly-used function. Functions are first-class objects that occupy the same namespaces that variables do, so they can obscure each other. In short, don't use variables called "c" (R is case sensitive, so "C" has no such problem).
Wherever possible, avoid incremental concatenation like the plague. If you feel you must use it, at least
2016 Apr 28
0
Create a new variable and concatenation inside a "for" loop
Maybe I wasn't clear about my query.
I'm very familiar with pre-allocation and vectorization and I had already wrote an R code for this problem in this way. My question wasn't about the most efficient way to solve the problem. It was about whether in R it was possible to use the same index used in the loop to create a new variable and store the results in as in the example showed
2010 Feb 11
1
Sweve/cacheSweave
Hi there
I have a problem with using Sweave in combination with the option driver = cacheSweave.
Whichever code I try to run - when it comes to converting the tex file into pdf it comes up with the same errors (\csname \endcsname errors). Does anybody have an idea what it going wrong?
> Sweave("pgfSweave-example.Rnw",driver = cacheSweaveDriver)
Writing to file
2006 Feb 28
4
subsetting a list of matrices
Hi All,
I have a list of matrices:
> x
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> y
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 18 21 24 27 30 33
[2,] 19 22 25 28 31 34
[3,] 20 23 26 29 32 35
> z =list(x,y)
I want to create a second list that is has a subset each matrix in the
list subsetting so I get the 2nd and 3rd row of each (and
2010 Oct 17
1
Wrong box.
Oct 16 22:52:42 mta0 dovecot: lda(luciano.moreira at metal.eeimvr.uff.br):
sieve: msgid=<a04f508ac9d299a0733a09ce714ae56f at localhost.localdomain>:
stored mail into mailbox 'luciano/moreira at metal/eeimvr/uff/br'
Oct 16 22:52:48 mta0 dovecot: lda(fabiana at vm.uff.br): sieve: msgid=<
4CB3CFE3.4060206 at wspc.com.sg>: stored mail into mailbox 'fabiana at vm/uff/br'
Oct
2007 Jun 26
2
fisher information matrix
Hi All,
a colleague wants to calculate the Fisher information matrix for a model he
wrote (not in R). He can easily get the neg-log-likelihood and the best fit
parameters at the minimum. He can also get negLLs for other parameter values too.
Given these data, is there a way in R to calculate the Fisher information matrix?
Best,
Federico
--
Federico C. F. Calboli
Department of Epidemiology
2010 Aug 17
1
confidence intervals for Harrell's c-index in survival setting
Dear All,
Is it possible to get confidence intervals for Harrell's concordance index or, equivalently, Somer's D using the rms package or in some other way ?
I have survival data it would be the c-index in the Cox model setting
Many thanks
Dr Bernard North
Statistical Consultant
Statistical Advisory Service
Advice and Courses on Research Design and Methodology
Imperial College South
2005 Mar 08
5
removing message: [Previously saved workspace restored]
Dear All,
I saved by mistake the environment I was working in after typing q(),
and now I get the annoying message:
[Previously saved workspace restored]
I have already deleted all the objects in the environment, saving it as
an empty environment, so it's just a matter of nitpicking I suppose. The
message does not appear if I start R from any other place in the
directory tree.
I am
2006 Sep 26
5
putting stuff into bins...
Hi All,
I have a vector of data, a vector of bin breakpoints and I want to put my data
in the bins and then extract fanciful informations like the mean value of each bin.
I know I can write my own function, but I would have thought that R should have
somewhere a function that took as arguments something like (data, breaks, what
to do with the data in the bins). I surey could not find it
2006 Oct 26
2
pairs matchning
Hi
You could try to find an equivalent representation as a string and try to
match those.
> (A <- cbind(sample(1:2, 10, rep=TRUE), sample(1:2, 10, rep=TRUE)))
[,1] [,2]
[1,] 1 2
[2,] 1 2
[3,] 1 2
[4,] 2 2
[5,] 1 1
[6,] 1 2
[7,] 1 2
[8,] 1 1
[9,] 1 2
[10,] 1 1
> (B <- unique(A))
[,1] [,2]
[1,] 1 2
2006 Feb 08
2
logical condition in vector operation
HI All,
I have a data frame such as:
> test
x y p d
[1,] 1 0 10 21 0
[2,] 2 3 11 12 0
[3,] 3 4 12 23 0
[4,] 3 5 13 24 0
and I want to perfor some operations on the first two coulums,
conditional on the uneqaulity values on the 3rd and 4th columns.
For instance:
j = 3
test[test[,1] == j, 5] = test[test[,1] == j,2] + test[test[,2] == j,1]
gives me the result:
test:
x y p d
2006 Mar 08
3
'less' for R?
Hi All,
is there an equivalent of the Unix command 'less' (or 'more'), so I can
look at what's inside a data.frame or a matrix without having it printed
out on console?
I am using R on Debian Linux and Mac OS 10.4.5
Cheers,
F
--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG
Tel +44
2006 Mar 12
1
finding warning point in function
Hi everyone,
I would like to find out when and where exactly I get the following
warning in a piece of code I've written:
Error in "[<-"(`*tmp*`, iseq, value = numeric(0)) :
nothing to replace with
The code is a for () loop performing a somewhat trivial calculation,
modulated by a number of logical if(){} else(){} conditions, involving
the creation of a number of
2007 Jun 25
3
fractional calculations
Hi All,
is there a function in R that allows me to work with fractions without
transforming them to floats (or whatever) in between?
Something that would calculate something like:
(1/2 + 1/8) * 1/2 = 5/16
without ever transforming to 0.5 and 0.125?
Best,
Federico
--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place,
2006 Apr 21
2
forcing apply() to return data frame
Hi All,
I am (almost) successfully using apply() to apply a function recursively
on a data matrix. The function is question is as.genotype() from the
library 'genetics'
apply(subset(chr1, names$breed == 'lab'),2,as.genotype,sep ="")
Unfortuantely apply puts it's results into a matrix object rather than a
data frame, tranforming my factors into numerics and
2006 Jun 07
3
smoothing plot(x, type ='l')
Hi All,
I am using plot(x, type = 'l') for some plotting, but I would like rounded edges
rather than jagged edges in the plot (purely for aestetic reasons).
How could I achieve that?
Cheers,
Federico
--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG
Tel +44 (0)20 7594 1602 Fax (+44) 020
2006 Mar 28
2
as.matrix and one row
Hi All,
I have the following problem:
x = c(1,2)
x
[1] 1 2
as.matrix(x)
[,1]
[1,] 1
[2,] 2
BUT, if I add:
y = c(3,4)
as.matrix(rbind(x,y))
[,1] [,2]
x 1 2
y 3 4
It does not transpose. Since I will need as.matrix() for a list of data
that is in one or more lines, I need as.matrix to behave in a consisten
fashions, so I get
as.matrix(x, whatever)
[,1] [,2]
x 1
2008 May 08
3
lme nesting/interaction advice
Hi everyone,
I am confused on how to specify some nesting and interaction terma with lme().
I have a dataset where some flies where selected for accessory gland size, made
to mate in presence/absence of another male and the level of some protein
measured. Now the complex stuff.
The selection has been replicated twice, so that the selection term has got two
levels (large and small) with
2009 Nov 10
1
when vectorising does not work: silent function fail?
Dear All,
I'm using apply to do some genetic association analysis along a chromosome, with
many thousands markers. For each marker the analysis is the same, so I was
planning to use apply(chrom, 2, somefunction)
In the specific case I do:
my.results = apply(chr, 2, function(x){anova(lrm( cpstc.f ~ x + time.cpstc + age
+ sex + mri))[1,3]})
This is all good and well in theory, but in