Displaying 20 results from an estimated 20000 matches similar to: "break a vector into classes"
2008 Jun 16
4
Superimposing Line over Histogram in Density Plot
Hi,
Currently I have a density plot generated with this
snippet.
Is there a way I can add a line curve on top of it?
I mean in one figure
__BEGIN__
myhist <- hist(x
col="blue",
main = "Density Plot",
xlab = "Exp Level",
)
__END__
- Gundala Viswanath
Jakarta - Indonesia
2006 Sep 07
2
Axes of a histogram
Hello everyone,
I would be glad if you could help out an R-beginner here... I have a
vector of categorial data like this
> v <- c(1, 1, 2, 2, 2, 3, 3, 4, 4, 4)
When I do
> hist(v)
I get the x-axis of the histogram with floating point labels: 1.0, 1.5,
2.0, etc. Is it possible to tell R that the data consists of categories,
i.e. that I only want the category names (1, 2, 3, 4) on my
2005 May 20
5
getting the unique values and counts from a vector
Hi all,
>From a vector, I want to get the unique values and the counts of these
unique values in the vector. For example,
x<-c(2 ,1 ,2, 1, 4 ,2 ,1, 4 ,1 ,1)
xu<-unique(x)
xn<-numeric(length(xu))
for (i in 1:length(xu)) {xn[i]<-length(which(x==xu[i]))}
There must be a very much simpler method of doing this. Can somebody
direct me to the functions that I must read in order to do
2005 Dec 13
8
superimpose density line over hist
Hi all,
I'm trying to superimpose a rchisq density line over a histogram with
something like:
hist(alnlength)
lines(density(rchisq(length(alnlength), 4)),col="red")
But the rchisq line won't appear anywhere,
Anyone knows what I am missing here?
Thanks in advance,
Albert.
2004 Sep 22
5
t test problem?
Hello,
I got two sets of data
x=(124738, 128233, 85901, 33806, ...)
y=(25292, 21877, 45498, 63973, ....)
When I did a t test, I got two tail p-value = 0.117, which is not significantly different.
If I changed x, y to log scale, and re-do the t test, I got two tail p-value = 0.042, which is significantly different.
Now I got confused which one is correct. Any help would be very appreciated.
2006 Nov 14
2
dividing vectors into bins with equal widths
Hi R-users,
I am trying to divide a vector (say X) into equal frequency bins. If one uses the hist()
function, then a histogram is plotted, but with bins of equal widths, and not with bins
having the same number of data points.
I have then tried the histogram() function as follows:
histogram(X, nint=10, breaks=NULL, equal.widths=F)
This works as I want. However, I can't extract which
2005 Feb 16
4
Passing colnames to graphics title
Hi,
Just a quick query - if I'm creating a function to produce a number of
histograms per page of output (one per column from a matrix), how can I
pass the column name of the matrix into the title (or indeed to form part
of the x-axis label)?
TIA,
Laura
Laura Quinn
Institute of Atmospheric Science
School of Earth and Environment
University of Leeds
Leeds
LS2 9JT
tel: +44 113 343 1596
fax:
2005 Mar 23
4
sampling from a mixture distribution
Dear R users,
I would like to sample from a mixture distribution p1*f(x1)+p2*f(x2). I
usually sample variates from both distributions and weight them with their
respective probabilities, but someone told me that was wrong. What is the
correct way?
Vumani
2005 Feb 28
2
How to plot
Hello,
I would like to know if R provides the similar function to produce
the 4-in-1 graph ("Normal Plot of Residuals", "I Chart of Residuals",
"Histogram of Residuals" & "Residuals vs Fits") as MiniTab. If do not
have, could anyone please tell me how to produce above-mentioned
individual chart?
Your help is greatly appreciated.
2006 Jun 16
3
Vector Manipulation
I have a vector that has 1,974 elements and each element is one of the
following (B, F, N, Y). How do I recreate that vector accept in the
place of N put 0 and in the place of B, F or Y put a 1?
Thanks,
Jacob
[[alternative HTML version deleted]]
2008 Jun 19
2
Draw curve for histogram
Hi all,
What parameter should I feed to the hist function to draw a line, not bar
graph for a histogram? Smoothed line would be great too.
I've looked at curve() for normal distribution but it's not what I need. I
need some curve on top of the histogram (fit to the actual data). Just as a
way to illustrate, rather than bargraph.
Thanks
--
Regards,
Anh Tran
UCLA NeuroOncology Lab
2007 Jul 22
4
using R for a reaction-time experiment
I want to use R to run a reaction-time experiment: Something appears on the
screen, I respond by typing something (one keystroke), the system measures
the speed of my response. R would be great for this if only I didn't have to
hit Enter to enter that keystroke. I am doing such experiments now but they
require two actions per trial: hit keystroke, hit Enter.
Is there some way that R can be
2005 May 04
1
lme versus proc mixed in SAS
Dear all,
I am trying to simulate the null distribution for the likelihood ratio
test statistic for testing 1 random effect versus no random effect. The
asymptotic null distribution should be a mixture of a chi-squared
distribution with 0 degrees of freedom and a chi-squared distribution
with 1 degree of freedom. This means that I expect a point mass of 50%
on 0 for the likelihood ratio
2005 Oct 25
8
Can anyone please tell me how to strip the white spaces from a character vector?
for example:
> a$tic[1:10]
[1] "AIR " "ABCB " "ABXA " "ACMR " "ADCT " "ADEX "
[7] "ABM " "AFCE " "AG " "ATG "
Can anyone please tell me how to strip the white spaces from a$tic?
Thanks,
Roger
[[alternative HTML version deleted]]
2006 Oct 16
5
Re : Generate a random bistochastic matrix
Thanks, I tried someting like this, but computation takes times for large matrices
btransf <- function(y,X=length(y)^4) {
N <- length(y)
bm <- matrix(rep(1/N,N^2),N,N)
for(j in 1:X){
coord <- sample(1:N,4,replace=T)
d <- runif(1,0,min(bm[coord[1],coord[2]],bm[coord[3],coord[4]]))
2006 May 12
3
Maximum likelihood estimate of bivariate vonmises-weibulldistribution
Thanks Dimitris!!! That's much clearer now. Still have a lot of work to
do this weekend to understand every bit but your code will prove very
useful.
Cheers,
Aziz
-----Original Message-----
From: Dimitrios Rizopoulos [mailto:Dimitris.Rizopoulos at med.kuleuven.be]
Sent: May 12, 2006 4:35 PM
To: Chaouch, Aziz
Subject: RE: [R] Maximum likelihood estimate of bivariate
2008 Apr 09
4
apply lm() for all the columns of a matrix
Hi all,
My question is not really urgent. I can write a loop and solve the
problem. But I know that I'll be in a similar situation many more times so
it would be useful to find out the answer
Is there a fast way to perform linear fit to all the columns of a matrix?
(or in the one dimension of a multi-dimensional array.) I'm talking about
many single linear fits, not about a multiple fit.
2006 Mar 02
2
'...' passed to both plot() and legend()
Dear R-devels,
I'd like to create a plot method for a class of objects that passes
the '...' argument to both plot() and legend(), e.g.,
x <- list(data = rnorm(1000))
class(x) <- "foo"
plot.foo <- function(x, legend = FALSE, cx = "topright", cy = NULL,
...){
dx <- sort(x$data)
plot(dx, dnorm(dx), type = "l", ...)
if (legend)
2007 May 20
2
Number of NA's in every second column
Hi R-users,
How do I calculate a number of NA's in a row of every second column in my
data frame?
As a starting point:
dfr <- data.frame(sapply(x, function(x) sample(0:x, 6, replace = TRUE)))
dfr[dfr==0] <- NA
So, I would like to count the number of NA in row one, two, three etc. of
columns X1, X3, X5 etc.
Thanks in advance
Lauri
[[alternative HTML version deleted]]
2005 May 19
2
plot question
hi all:
xlim and ylim are used to define the interval limits of a plot. I'm interested in the scale of values between this limits.
suppose xlim=c(0,10)
we can have e.g.
0 5 10
0 2 4 6 8 10
0 1 2 3 4 5 6 7 8 9 10
which is the parameter that allows me to modify this?
thanks in advance
alexandre