Displaying 20 results from an estimated 10000 matches similar to: "creating a database"
2007 Dec 24
2
expand.grid function
useR's,
I have used expand.grid() several times and like the results it gives me. I
am now trying something with it that I have not been able to get to work.
For any n column matrix I would like to run this function on those n columns
and store the results.
For example, if my matrix has 1 column then this is just expand.grid(x =
column1). If my matrix has two columns, then I want
2008 Feb 20
2
intersecting rows of a matrix
useR's,
First, I would like to say thanks to John Fox for providing this segment of
code to perform intersection for multiple sets:
intersection <- function(x, y, ...){
if (missing(...)) intersect(x, y)
else intersect(x, intersection(y, ...))
}
I want to execute this function on the rows of a matrix I have:
Ik.mat.test <- matrix(c(2,3,6,1,2,6,6,1,2),byrow=T,nrow=3)
> Ik.mat.test
2008 Feb 01
2
re placing values in a matrix
useR's,
Consider:
y <- c(20, 25, 30)
> m <- matrix(c(0.0,1,NA,0.5,1.25,0.75, 0.5, NA,
> NA),byrow=TRUE,nrow=3,ncol=3)
> m
[,1] [,2] [,3]
[1,] 0.0 1.00 NA
[2,] 0.5 1.25 0.75
[3,] 0.5 NA NA
For each numeric value, I want to replace them with their corresponding
y-value. The result should look like (here, each row represents a variable
rather than the columns):
2007 Sep 03
1
using temporary arrays in R
useR's,
Is there a way to create a temporary array (or matrix) in R to hold values,
then drop or delete that temporary array from memory once I do not need it
anymore?
I am working with multidimensional arrays/matrices and I frequently perform
multiple operations on the same matrix and rename it to be another object.
I want to be able to delete the older versions of the array/matrix to free
2007 Dec 20
1
alternate storage options
useR's.
I am working with an algorithm in which I will need to create combinations
of all the points I have in a matrix. When I have 2 variables, I simply use
expand.grid() to do this. Sometimes I am faced with 3 or more variables and
if I run expand.grid(), R cannot process it due to the huge size. Is there
any efficient way to workaround this?
Thanks,
Derek
--
View this message in
2007 Nov 13
2
connection diagram
Hi
I am practically new to R, and need to construct connection diagrams,
I have a table of data, of nodes in vertical rows, and horizontally
the number of outgoing connections to other nodes, and the indices of
these nodes, each in a column, so some columns are used, and some are
not, based on how many connections I have
the node is identified by these variables (dimension, wave number,
2007 Aug 28
1
alternate methods to perform a calculation
Consider a data frame (x) with 2 variables, x1 and x2, having equal values.
It looks like:
x1 x2
1 1
2 2
3 3
Now, consider a second data frame (xk):
xk1 xk2
0.5 0.5
1.0 0.5
1.5 0.5
2.0 0.5
0.5 1
1.0 1
1.5 1
2.0 1
0.5 1.5
1.0 1.5
1.5 1.5
2.0 1.5
0.5 2
1.0 2
1.5 2
2.0 2
I have written code to calculate some differences between these
2008 Jan 08
1
using lapply()
useR's,
I am trying to find a quick way to change some values in a list that are
subject to a condition to be NA. Consider the 3x1 matrix:
delta <- matrix(c(2.5,2.5,1), nrow = 1)
And consider the list named v that has 3 elements
> v
v[[1]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[,13] [,14]
[1,] 4.25 3.25 2.25 1.25 0.25 0.75 1.75 2.75 3.75 4.25
2008 Dec 23
1
Ordered Multidimensional Arrays
Hi,
I am inquiring as to what are the best practices with respect to storing and
manipulating ordered multi-dimensional arrays. For example, suppose I have
a sequence of time-varying covariance matrices of asset returns. The data
is ordered, but the ordering is not necessarily regular (e.g. daily data
omitting weekends and holidays, etc.). The data array is say, N x N x T.
For example, the
2010 Mar 18
2
how to take multiple subsets from a matrix
useR's
I have a matrix from which I want to take multiple subsets from, according
to a particular scheme I will now describe. The matrix below (mat) is 5x5,
and I want to take 9 subsets of it, each of dimension 3x3. The best way to
explain what the result should look like is with the following:
> dat <- c(3,6,1,9,12,9,2,10,6,5,3,13,1,4,8,9,4,6,10,11,2,7,3,5,10)
> miss <-
2008 Jan 08
1
using mapply()
useR's,
This is a follow up question to one I previously asked. Consider the
3-element list below
> res
[[1]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[,13] [,14]
[1,] NA NA NA 1.25 0.25 0.75 NA NA NA NA NA NA 1.25
0.25
[2,] 1.25 0.25 0.75 NA NA NA NA NA NA 1.25 0.25 0.75 NA
NA
[3,] NA NA NA NA NA
2008 Aug 31
1
how to draw a perspective pyramid
Dear list,
I am trying to construct a perspective plot of a 2D triangle, or pyramid. I
can easily do the one dimensional plot (code below), but I can't figure out
how to do it in a perspective plot for two input variables. Does anyone
have a simple solution?
Thanks!
Derek
#code for a triangle
u <- seq(-1,1,.001)
tri <- (1-abs(u))
plot(tri~u,type="l",main="Second
2008 Jan 07
1
Avoiding FOR loops
useR's,
I would like to know if there is a way to avoid using FOR loops to perform
the below calculation.
Consider the following data:
> x
[,1] [,2] [,3]
[1,] 4 11 1
[2,] 1 9 2
[3,] 7 3 3
[4,] 3 6 4
[5,] 6 8 5
> xk
Var1 Var2 Var3
1 -0.25 1.75 0.5
2 0.75 1.75 0.5
3 1.75 1.75 0.5
4 2.75 1.75 0.5
5 3.75 1.75
2007 Sep 10
5
finding the minimum positive value of some data
useRs,
I am looking to find the minimum positive value of some data I have.
Currently, I am able to find the minimum of data after I apply some other
functions to it:
> x
[1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10
> sort(x)
[1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10
> diff(sort(x))
[1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0
> min(diff(sort(x)))
[1] 0
2008 Jan 11
3
changing the values in a list
useR's,
Does anyone know of an efficient way to change the values in a list to
different numbers stored in an object? For example, consider the following:
y <- matrix(c(20, 13, 25, 10, 17), ncol = 1)
> res
[[1]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[,13] [,14]
[1,] NA NA NA 1.25 0.25 0.75 NA NA NA NA NA NA 1.25
0.25
[2,]
2008 Jul 29
3
finding a faster way to do an iterative computation
useR's,
I am trying trying to find out if there is a faster way to do a certain
computation. I have successfully used FOR loops and the apply function to
do this, but it can take some time to fully compute, but I was wondering if
anyone may know of a different function or way to do this:
> x
[1] 1 2 3 4 5
> xk
[1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
I want to do:
2008 Jul 24
2
simple random number generation
useR's,
I want to randomly generate 500 numbers from the standard normal
distribution, i.e. N(0,1), but I only want them to be generated in the range
-1.5 to 1.5. Does anyone have a simple way to do this?
Thanks,
dxc13
--
View this message in context: http://www.nabble.com/simple-random-number-generation-tp18642611p18642611.html
Sent from the R help mailing list archive at Nabble.com.
2008 Jan 16
3
color ranges on a 2D plot
useR's
I am trying to color the points on a scatter plot (code below) with two
colors. Red for values 0.5 -1.0 and blue for 0.0 - .49. Does anyone know a
easy way to do this?
x <- runif(100, 0, 1)
y <- runif(100, 0, 1)
plot(y ~ x, pch=16)
Thanks,
dxc13
--
View this message in context: http://www.nabble.com/color-ranges-on-a-2D-plot-tp14893457p14893457.html
Sent from the R help
2003 Jan 31
4
Moterboard help Please
All,
I have been terribly pleased with openbsd 3.2 I was using it as a
mail/samba server with postifx on a pentium pro 200 with 1 gig of
memory. Well I wanted to add a larger harddrive than what I have in it
now only 6.4 gig. Well the machine would not see it and for some reason
after hours and hours of trying I can't get a tekram 395UW and a 18gig
scsi to be the boot drive and having failed
2009 May 24
2
Deleting columns from a matrix
useR's,
I have a matrix given by the code:
mat <-
matrix(c(rep(NA,10),1,2,3,4,5,6,7,8,9,10,10,9,8,NA,6,5,4,NA,2,1,rep(NA,10),1,2,3,4,NA,6,7,8,9,10),10,5)
This is a 10x5 matrix containing missing values. All columns except the
second contain missing values. I want to delete all columns that contain
ALL missing values, and in this case, it would be the first and fourth
columns. Any column