Displaying 20 results from an estimated 10000 matches similar to: "How to locate the difference from two data frames"
2009 Oct 13
7
lapply() reccursively
Hi all,
I was wondering whether it is possible to use the lapply() function
to alter the value of the input, something in the spirit of :
a1<-runif(100)
a2<-function(i){
a1[i]<-a1[i-1]*a1[i];a1[i]
}
a3<-lapply(2:100,a2)
Something akin to a for() loop, but using the lapply() infrastructure.
I haven't been able to get rapply() to do this.
The reason is that the "real"
2008 Dec 09
2
Better way to find distances between points in a set?
I was playing around a bit to see how I could find the two points in a
set of points (or ordered pairs) furthest from each other.
Here's what I did:
1) created a Nrow by 2col matrix, so each row contains an x,y coordinate
pair.
2) fed the matrix to a nested mapply (cv is my matrix):
mapply(function(k,l) mapply(function(x,y,a,b)
+
2010 Jul 07
3
How do I test against a simple null that two regressions coefficients are equal?
Hi there,
I run two regressions:
y = a1 + b1 * x + e1
y = a2 + b2 * z + e2
I want to test against the null hypothesis: b1 = b2. How do I design the test?
I think I can add two equations together and divide both sides by 2:
y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1 + e2).
or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
If I run this new regression, I can test against
2011 Jan 24
2
Help with expression
I have a problem with expressions. I am trying to create a title where
the parameter of interest is displayed as a Greek character. Which
parameter is being considered is stored in a character variable.
As an example, if I have
param <- "alpha"
and then do
plot(0, 0, main = bquote(Parameter==.(param)))
then in the title I get "Parameter = alpha",
whereas I want the
2008 May 27
4
help with simple function
I have a matrix of frequency counts from 0-160.
x<-as.matrix(c(0,1,0,0,1,0,0,0,1,0,0,0,0,1))
I would like to apply a function creating a new column (x[,2])containing
values equal to:
a) log(x[m,1]) if x[m,1] > 0; and
b) for all x[m,1]= 0, log(next x[m,1] > 0 / count of preceding zero values
+1)
for example, x[1,2] should equal log(x[2,1]/2) = log(1/2) = -0.6931472
whereas x[3,2] should
2008 Dec 11
3
check if a certain ... argument has been passed on to my user-defined function
Hi,
How can I check if a certain ... argument has been passed on to my
user-defined function or not?
foo <- function(data, ...)
{
### here I want to check whether xlab was passed with the ... arguments
### or if the ... arguments did not contain an xlab argument
}
I tried missing(xlab) , exists(xlab) and several other things but did not
find a solution.
TIA,
Mark
2008 Jan 23
4
image question
Hi,
I have a question regarding the image function. Is there a way to specify a
separate color set for each column in the matrix?
TIA,
ajar.
[[alternative HTML version deleted]]
2009 Nov 16
3
Cluster analysis: hclust manipulation possible?
I am doing cluster analysis [hclust(Dist, method="average")] on
data that potentially contains redundant objects. As expected,
the inclusion of redundant objects affects the clustering result,
i.e., the data a1, = a2, = a3, b, c, d, e1, = e2 is likely to
cluster differently from the same data without the redundancy,
i.e., a1, b, c, d, e1. This is apparent when the outcome is
visualized
2009 Feb 16
2
Using eval in multinom argument
Hi,
I am having difficulty entering a 'programmable' argument into the multinom function from the nnet package. Interactively, I can get the function to work fine by calling it this way:
z1=multinom(formula = class.ind(grp[-outgroup])~ (PC1 + PC2 + PC3), data=data.frame(scores))
However I need to be able to change the number of variables I am looking for in 'scores' and so am
2008 Oct 30
3
why does sample(x, n) give the same n items in every separate runs?
Hello R users,
I have gene expression data of two groups of genes (large and small). Gene expression intensities of those genes are classified into 1 to 10 levels. What I want is to make a random set of genes that have the same levels as the small group from large group using sample().
I used smallvec to hold the number of genes in each levels (1 to 10) for small group, largevec for large group.
2011 Dec 21
4
qqnorm & huge datasets
Hi,
When qqnorm on a vector of length 10M+ I get a huge pdf file which
cannot be loaded by acroread or evince.
Any suggestions? (apart from sampling the data).
Thanks.
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://mideasttruth.com http://honestreporting.com http://camera.org
http://openvotingconsortium.org http://pmw.org.il
2010 Aug 04
2
discrete ECDF
Dear list;
I just created a utility function that replicates what I have done in
the past with Excel or OO.org by putting a formula of the form
=sum($A1:A$1) in an upper-corner of a section and then doing a "fill"
procedure by dragging the lower-rt corner down and to the right. When
divided by the grand sum of the entries this function then calculates
a 2D-discrete-ECDF.
I
2009 Jan 13
2
Using fortran code which call LAPACK subroutines
Hello
I'm trying to run a fortran code which use LAPACK subroutines. I think I
should use some points shown in the manual 5.5 Creating shared objects
but it is too technical for me :-(... Could anyone help me for the
procedure to do:
-which part of the manual is relevant for this type of question?
actually I'm speaking from writing R extensions, should I read R admin?
-point 1.2
2007 Aug 04
2
Mixture of Normals with Large Data
All:
I am trying to fit a mixture of 2 normals with > 110 million observations. I
am running R 2.5.1 on a box with 1gb RAM running 32-bit windows and I
continue to run out of memory. Does anyone have any suggestions.
Thanks so much,
Tim
[[alternative HTML version deleted]]
2010 Apr 16
3
GSL in C code for R
Dear fellow R users,
I am now investing time in learning how to use compiled C code to produces functions that can be used in R. I am just starting, and there is much that I need to learn, so I have a question that might be straight forward. I am learning how to use function in the C library GSL (gnu scientific library), to write C code, that I then plant to use in R. Is there any problem in
2008 Aug 28
2
sample consecutive integers efficiently
Hi all,
I have some rough code to sample consecutive integers with length
according to a vector of lengths
#sample space (representing positions)
pos<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
#sample lengths
lengths<-c(2,3,2)
From these two vectors I need a vector of sampled positions.
the sampling is without replacement, making things tough as the sampled
integers need
2010 Nov 27
1
Bug in parseNamespaceFile or switch( , ... ) ?
parseNamespaceFile() doesn't seem to detect misspelled directives. Looking
at its code I see
switch(as.character(e[[1L]]),
<lots of args omitted here>,
stop(gettextf("unknown namespace directive: %s",
deparse(e)), call. = FALSE, domain = NA))
but this doesn't seem to function as I expect, viz. to stop with an error
if I type a wrong directive.
2008 Jul 11
1
Suggestion: 20% speed up of which() with two-character mod
Hi,
by replacing 'll' with 'wh' in the source code for base::which() one
gets ~20% speed up for *named logical vectors*.
CURRENT CODE:
which <- function(x, arr.ind = FALSE)
{
if(!is.logical(x))
stop("argument to 'which' is not logical")
wh <- seq_along(x)[ll <- x & !is.na(x)]
m <- length(wh)
dl <- dim(x)
if (is.null(dl)
2010 Sep 30
2
Sweave and LaTeX beamer class
I am failing to uncover Sweave chunks step by step using the LaTeX beamer
class.
The following minimal example:
\documentclass{beamer}
\usepackage{Sweave}
\begin{document}
\begin{frame}[fragile]
In the year \uncover<2->{25}\uncover<3->{\Sexpr{5*5}}
\uncover<4->{
<<echo=TRUE, print=TRUE>>=
5*5*101
@
}
\end{frame}
\end{document}
leads to an error message when
2009 Dec 02
2
Error when running Conditional Logit Model
Dear R-helpers,
I am very new to R and trying to run the conditional logit model using
"clogit " command.
I have more than 4000 observations in my dataset and try to predict the
dependent variable from 14 independent variables. My command is as follows
clmtest1 <-
clogit(Pin~Income+Bus+Pop+Urbpro+Health+Student+Grad+NE+NW+NCC+SCC+CH+SE+MRD+strata(IDD),data=clmdata)
However, it