Displaying 20 results from an estimated 3000 matches similar to: "Correlated Columns in data frame"
2003 Nov 21
3
speeding up a pairwise correlation calculation
Hi,
I have a data.frame with 294 columns and 211 rows. I am calculating
correlations between all pairs of columns (excluding column 1) and based
on these correlation values I delete one column from any pair that shows
a R^2 greater than a cuttoff value. (Rather than directly delete the
column all I do is store the column number, and do the deletion later)
The code I am using is:
ndesc
2011 Feb 09
2
Generate multivariate normal data with a random correlation matrix
Hi All.
I'd like to generate a sample of n observations from a k dimensional
multivariate normal distribution with a random correlation matrix.
My solution:
The lower (or upper) triangle of the correlation matrix has
n.tri=(d/2)(d+1)-d entries.
Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99)
Populate a triangle of the matrix with the sampled correlations
Mirror the
2002 Jan 15
1
acf conf intervals +speed
Hi,
I'm trying to obtain confidence intervals for auto and
cross correlation estimates. I've adapted code made
available by Stock and Watson that uses the Bartlett
Kernel and the delta method. In R it runs really,
really slow because of the loops it uses and I have 9
series that I'd like to examine (81 total
combinations). It was easy enough to replace one of
the while loops with a
2010 Dec 02
2
Hmisc label function applied to data frame
Hello,
I'm attempting to create a data frame with correlations between every pair
of variables in a data frame, so that I can then sort by the value of the
correlation coefficient and see which pairs of variables are most strongly
correlated.
The sm2vec function in the corpcor library works very nicely as shown here:
library(Hmisc)
library(corpcor)
# Create example data
x1 = runif(50)
x2 =
2009 May 15
2
Using column length in plot gives error
Hi
I'm trying to write a generic script for processing some data which finishes
off with some plots. Given Im never sure how many columns will be in my
dataframe I wanted to using the following
plot(spectra.wavelength, cormat, type = "l", ylim=c(-1,1), xlab="Wavelength
(nm)", ylab="Correlation")
however even if I specify as type="l" it appears plot
2013 Feb 20
1
Problem with levelplot() in a loop
Dear R users,
I am trying to print heatmaps in a loop (with a pause). Idea is to
visualize changing correlations over time and for testing I wrote this
simple (reproducible) code below.
My problem is that levelplot() does not produce any output when I run the
code (though heatmap does). Ideally I would like to use levelplot() as it
produces a neat index on the side indicating the color and the
2008 Jul 19
3
Graphics not working for R in ubuntu
Dear list members,
I have installed R in Ubuntu successfully but issuing
command like R in terminal will able to see only the R
working in command mode, the regular GUI which I use to
have in my windows installation of R missing in linux..I am
new to linux and so clueless how I can go about that and
How I could enable it in linux? More, I never got any
problem in configuration and compilation
2013 Feb 02
1
Why replacement has length zero? And How can I fix it?
Hi
for the loop section runif needs curved brackets
Try
IAP <-NA
for (i in 1:Sample.Size){
if (DataSet$SES[i]>0) {
IAP[i] <- ifelse(runif(1)>0.75, 1, 0) # High SES, higher chance to be in
Treatment #
}
else {
IAP[i] <- ifelse(runif(1)<=0.25, 1, 0) # Low SES, lower chance to be in
Treatment #
}
} # End loop #
IAP
IAP
zjiaqi19880219 wrote
> Hi,
2023 Oct 16
1
Create new data frame with conditional sums
If one makes the reasonable assumption that Pct is much larger than
Cutoff, sorting Cutoff is the expensive part e.g O(nlog2(n) for
Quicksort (n = length Cutoff). I believe looping is O(n^2). Jeff's
approach using findInterval may be faster. Of course implementation
details matter.
-- Bert
On Mon, Oct 16, 2023 at 4:41?AM Leonard Mada <leo.mada at syonic.eu> wrote:
>
> Dear
2009 Jul 23
1
ROCR - confidence interval for Sens and Spec
Dear List,
I am new to ROC analysis and the package ROCR. I want to compute the confidence intervals of sensitivity and specificity for a given cutoff value. I have used the following to calculate sensitivity and specificity:
data(ROCR.simple)
pred <- prediction(ROCR.simple$predictions, ROCR.simple$labels)
se.sp <- function (cutoff, performance) {
sens <-
2023 Oct 16
1
Create new data frame with conditional sums
Dear Jason,
The code could look something like:
dummyData = data.frame(Tract=seq(1, 10, by=1),
?? ?Pct = c(0.05,0.03,0.01,0.12,0.21,0.04,0.07,0.09,0.06,0.03),
?? ?Totpop = c(4000,3500,4500,4100,3900,4250,5100,4700,4950,4800))
# Define the cutoffs
# - allow for duplicate entries;
by = 0.03; # by = 0.01;
cutoffs <- seq(0, 0.20, by = by)
# Create a new column with cutoffs
dummyData$Cutoff
2023 Oct 14
1
Create new data frame with conditional sums
That's very helpful and instructive, thank you!
Jason Stout, MD, MHS
Box 102359-DUMC
Durham, NC 27710
FAX 919-681-7494
________________________________
From: John Fox <jfox at mcmaster.ca>
Sent: Saturday, October 14, 2023 10:13 AM
To: Jason Stout, M.D. <jason.stout at duke.edu>
Cc: r-help at r-project.org <r-help at r-project.org>
Subject: Re: [R] Create new data frame with
2023 Oct 15
2
Create new data frame with conditional sums
Under the hood, sapply() is also a loop (at the interpreted level). As
is lapply(), etc.
-- Bert
On Sun, Oct 15, 2023 at 2:34?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote:
>
> That's very helpful and instructive, thank you!
>
> Jason Stout, MD, MHS
> Box 102359-DUMC
> Durham, NC 27710
> FAX 919-681-7494
> ________________________________
> From: John
2009 Aug 17
1
how to pass more than one argument to the function called by lapply?
Dear R helpers:
I wonder how to pass more than one argument to the function called by
lapply.
For example,
#R code below ---------------------------
indf <- data.frame(id=I(c('a','b')),y=c(1,10))
#I want to add an addition argument cutoff into the function called by
lapply.
outside.fun <- function(indf, cutoff)
{
unlist(lapply(split(indf, indf[,'id']),
2023 Oct 14
2
Create new data frame with conditional sums
Well, here's one way to do it:
(dat is your example data frame)
Cutoff <- seq(0, .15, .01)
Pop <- with(dat, sapply(Cutoff, \(p)sum(Totpop[Pct >= p])))
I think there must be a more efficient way to do it with cumsum(), though.
Cheers,
Bert
On Sat, Oct 14, 2023 at 12:53?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote:
>
> This seems like it should be simple but I
2009 Mar 27
1
ROCR package finding maximum accuracy and optimal cutoff point
If we use the ROCR package to find the accuracy of a classifier
pred <- prediction(svm.pred, testset[,2])
perf.acc <- performance(pred,"acc")
Do we?find the maximum accuracy?as follows?(is there a simplier way?):
> max(perf.acc at x.values[[1]])
Then to find the cutoff point that maximizes the accuracy?do we do the
following?(is there a simpler way):
> cutoff.list <-
2006 Jul 24
1
deparse - width.cutoff
I have a question about "deparse" function in R
What is the reason that "deparse" use an argument like "width.cutoff" ?
Why the maximum cutoff is 500?
I was manipulating an R formula and used "deparse". Since the length of user's formula was greater then 500, my code didnt work.
thanks
Johan
johan Faux <johanfaux@yahoo.com> wrote: I have a
2023 Oct 13
1
Create new data frame with conditional sums
This seems like it should be simple but I can't get it to work properly. I'm starting with a data frame like this:
Tract Pct Totpop
1 0.05 4000
2 0.03 3500
3 0.01 4500
4 0.12 4100
5 0.21 3900
6 0.04 4250
7 0.07 5100
8 0.09
2024 Oct 23
1
OSX-specific Bug in randomForest
I've cc'd this to the package maintainer, Andy Liaw
<andy_liaw at merck.com>. I'm not sure he reads this list.
Duncan Murdoch
On 2024-10-23 1:26 a.m., Stevie Pederson wrote:
> Hi,
>
> It appears there is an OSX-specific bug in the function
> `randomForest.default()` Going by the source code at
>
2007 Jun 30
1
graphic for the R profiler
Hello all,
I just wanted to share a small perl script that generates a dot file
from the result of the R profiler. The dot file can than be used to
create a graphical display of the profiling. You can save this file in
the bin directory of your R installation and then create a graph, for
example an SVG by piping the output of the script to dot:
$ R CMD Rprof2dot Rprof.out | dot -Tsvg >