Displaying 20 results from an estimated 60000 matches similar to: "Listing the data contents of a package"
2008 Mar 14
2
using nrow to identify one row
Hi fellow R-users,
I have run into a problem when trying to identify the number of rows in a matrix. Say we have an arbitrary 5 by 5 matrix called temp:
temp <- matrix(norm(25), nrow=5)
The problem is that nrow(temp[1,]) returns NULL. I would like it to return 1 because in my larger program I am indexing the rows of large matrices according to another variable and I need to test when the
2010 Sep 10
3
Is there a bisection method in R?
Dear fellow R-users,
Is there a function that does the bisection method? I was unable to find one.
Thanks in advance.
Gregory
[[alternative HTML version deleted]]
2005 Jun 25
2
optimization problem in R ... can this be done?
Im trying to ascertain whether or not the facilities of R are sufficient for solving an optimization problem I've come accross. Because of my limited experience with R, I would greatly appreciate some feedback from more frequent users.
The problem can be delineated as such:
A utility function, we shall call g is a function of x, n ... g(x,n). g has the properties: n > 0, x lies on the
2008 Jan 07
1
evaluating a vector of characters
Dear R users,
I'd like to evaluate a vector of characters. For example, say I have a data frame called Data including the field names x1, x2, x3, and I'd like to a list out of paste("Data$x", 1:3, sep=""). How can I get list to evaluate paste("Data$x", 1:3, sep="") as an R object rather than a string?
Thanks in advance for you assistance.
Gregory
2008 May 21
2
how to do pairwise sums in a matrix
I am looking for an efficient way to solve the following problem. I have a large matrix of continuous values with a small proportion of missing values. Columns correspond to variables where each variable has two measurements, call them A and B. The matrix is such that the columns are in sequence with respect to the variables. I would like to sum up the two measurements for each variable and each
2009 Oct 06
4
Text editors for Sweave (rnw) files
Hi fellow R-users,
Are there any text editors that recognize sweave (.rnw) files? I am running Windows Vista and in the past I used Tinn-R for R files but it (surprisingly) doesn't recognize rnw files and does not do any syntax highlighting for them.
Thanks in advance,
Greg
__________________________________________________________________
Make your browsing faster, safer, and
2007 Jul 28
8
generating symmetric matrices
Greetings,
I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it:
p <- 6
Rmat <- diag(p)
dat.cor <- rnorm(p*(p-1)/2)
Rmat[outer(1:p, 1:p, "<")] <- Rmat[outer(1:p, 1:p, ">")] <- dat.cor
However, the problem is that the matrix
2007 Jul 30
3
Constructing correlation matrices
Greetings,
I have a seemingly simple task which I have not been able to solve today and I checked all of the help archives on this and have been unable to find anything useful. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it:
p <- 6
Rmat <- diag(p)
dat.cor <- rnorm(p*(p-1)/2)
Rmat[outer(1:p, 1:p, "<")] <-
2010 Jan 27
3
Function for describing segements in sequential data
Dear R-users,
Say that I have a sequence of zeroes and ones:
x <- c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0)
The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient
2006 Jun 24
3
getting the smoother matrix from smooth.spline
Can anyone tell me the trick for obtaining the smoother matrix from smooth.spline when there are non-unique values for x. I have the following code but, of course, it only works when all values of x are unique.
## get the smoother matrix (x having unique values
smooth.matrix = function(x, df){
n = length(x);
A = matrix(0, n, n);
for(i in 1:n){
y = rep(0, n); y[i]=1;
yi =
2005 Jul 28
3
using integrate with optimize nested in the integration
Hi guys
im having a problem getting R to numerically integrate for some function,
say f(bhat)*optimize(G(bhat)), over bhat. Where id like to integrate this over some finite range, so that here as we integrate over bhat optimize would return a different optimum.
For instance consider this simple example for which I cannot get R to return the desired result:
f <- function(bhat) exp(bhat)
g
2008 Mar 10
1
How can I sample from a two-dimensional grid of points
Hi everyone,
My goal is to sample from a two-dimensional grid. Consider the following example of code:
n.grid <- 500
muA.grid <- seq(-4,4, length=n.grid)
muB.grid <- seq(-4,4, length=n.grid)
mu.p <- matrix(NA, nrow=n.grid, ncol=n.grid)
for(i in 1:n.grid){
for(j in 1:n.grid){
mu.p[i,j] <- dnorm(muA.grid[i], 0, 1)*dnorm(muB.grid[j], 0, 0.5)
}
}
mu.p <-
2007 Nov 21
2
matrix elementwise average with NA's
Hello fellow R users,
I have a matrix computation that I imagine should be relatively easy to do, however I cannot figure out a nice way to do it. I have two matrices, for example
mat1 <- matrix(c(1:5,rep(NA,5), 6:10), nrow=3, byrow=T)
mat2 <- matrix(c(2:6, 6:10, rep(NA,5)), nrow=3, byrow=T)
I'd like to compute the element-wise average for non-NA entries. Of course
(mat1+mat2)/2
2007 Dec 06
5
relationship between two factors
I have a dataset with two variables that are factors:
1) Decision Making Satisfaction (DMS), values = A - Completely, B -
Mostly, C - Partly, D - Not at all
2) IT Satisfaction values (ITS), values = A - Completely, B - Mostly, C
- Partly, D - Not at all
I would like to produce a table (matrix) and a chart of the factors,
with counts at the cross sections:
A B C D
A
B
2010 Jul 02
1
Producing residual plots by time for lme object
Fellow R-users,
I have a longitudinal data set with missing values in it. I would like to produce a residual plot for each time using panel.xyplot function but I get an error message. Here's a simple example,
library(nlme)
set.seed(1544)
longdata <- data.frame(ID=gl(10,1,50), y=rnorm(50), time = as.numeric(gl(5,10,50)), x = rnorm(50))
longdata$y[5] <- NA
longdata$x[35] <- NA
2006 Dec 19
4
nonparametric significance test for one sample
Hello, Gurus:
I tried to test if the sample mean of a dataset is zero.
The data has 1500 numbers with a lot of zeros and some small
positive numbers. The data range on [0,1] but the distribution is unknown.
It is zero inflated anyway.
I tried to use the Wilcoxon Signed Ranks test. But I read from this website
that it does assume the population pdf is symmetric.
2005 Nov 30
3
strange plots with type = "h" option
Hello,
With the new version 2.2.0, I get strange plots when using the
histogram-like option in plot(). For example, a plot of binomial
probabilities:
> plot(0:10,dbinom(0:10,10,.1), type = "h", lwd = 30)
gives me weird fat cirular bars, with mass out at values with low
probability. What is the issue here? This never happened with earlier
versions.
R on Windows XP SP 2
Intel
2006 Oct 31
2
Put a normal curve on plot
I would like to be able to place a normal distribution surrounding the
predicted values at various places on a plot. Below is some toy code
that creates a scatterplot and plots a regression line through the data.
library(MASS)
mu <- c(0,1)
Sigma <- matrix(c(1,.8,.8,1), ncol=2)
set.seed(123)
x <- mvrnorm(50,mu,Sigma)
plot(x)
abline(lm(x[,2] ~ x[,1]))
Say I want to add a normal
2008 Mar 20
4
little subplot in corner
I want to draw a little subplot ("overview") into my detailed plot. It
should be placed in say the top right corner and have the size of some
legend (like legend(x="topright", inset=0.03, ...)
#main plot
plot(rnorm(100))
#give little density in corner
plot(seq(-2,2,length=300),dnorm(seq(-2,2,length=300)),type="l")
I don't want something like par(mfrow=c(1,2)) as
2007 Mar 02
2
plot with fixed axis proportion
I want to plot something (eg a circle) with a fixed ratio of the x and
y axis, or (even better) with a fixed size when I print it. Output
should then be a circle (actually it'll be someting more complicated)
with radius 5cm and not an ellipse.
I'm _sure_ this is not new, but after looking 45min for a solution, I
post here...
Thanks for help
Thomas