Displaying 20 results from an estimated 2000 matches similar to: "Problem with "outer" function"
2005 Mar 28
2
Generating list of vector coordinates
Hi.
Can anyone suggest a simple way to obtain in R a list of vector
coordinates of the following form? The code below is Mathematica.
In[5]:=
Flatten[Table[{i,j,k},{i,3},{j,4},{k,5}], 2]
Out[5]=
{{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,1,5},{1,2,1},{1,2,2},{1,2,3},{1
,2,4},{1,2,
5},{1,3,1},{1,3,2},{1,3,3},{1,3,4},{1,3,5},{1,4,1},{1,4,2},{1,4,3},
{1,4,
2003 Sep 17
3
all possible samples
Dear all, there is an R function that return all possible samples of size n,
with replacement, from a vector of length N ?
Best regards
2004 Nov 25
2
Turning strings into expressions
Hello,
I am running R 1.9.1 om Windows 2000 SP4. My problem is as follows:
Say I have a dataframe my.frame with column names A and B. I have a string,
>my.string
[1] "A==1 & B==2"
And I would like to retrieve the subset corresponding to my.string, that is,
from my.frame and my.string I would like to get the result of
subset(my.frame,A==1 & B==2)
So I need to find a way
2004 Nov 25
4
Creating lists from matrices
Hello,
I am using R 1.9.1 on Windows 2000 SP4. I have the following problem:
Say I have a matrix,
>my.matrix
[,1] [,2] [,3]
[1,] "A" "B" "C"
[2,] "D" "E" "F"
[3,] "G" "H" "I"
I would like to apply an operation to this matrix which returns a list my.list
containing the
2008 Jul 23
18
Simple... but...
Hi R,
If
x=c(1,3,5)
y=c(2,4,6)
I need a vector which is c(1,2,3,4,5,6) from x and y.
How do I do it? I mean the best way....
Thanks, Shubha
This e-mail may contain confidential and/or privileged i...{{dropped:13}}
2008 Dec 05
1
array indexing
Hi.
I have been pondering array indexing via matrices.
> a <- array(1:27,rep(3,3))
> index <- matrix(c(1,1,1,1,2,3),2,3,byrow=TRUE)
> a[index]
[1] 1 22
as expected and documented. But what was the thinking
behind the decision to access the array by rows rather
than columns?
The 'index' matrix is ordered as [1,1,1,2,1,3] and so
the extraction is a[index[c(1,3,5)]]
2010 Jun 17
3
ask a question about data sets element
for example, I have
a1=c(1,3,5)
a2=c(2,4,6)
a3=c(7,8)
a4=c(9,10)
now if I have i=5, so i in a1, then I get a feedback tag[5]=1
i=8, so i in a3, then can get tag[8]=3
in there any function to do this to check the element belongs to which
group?
thank you!!!
[[alternative HTML version deleted]]
2004 Nov 04
5
Conversion of strings to expressions
Hello,
I'm not sure how to state my question in a technically accurate manner, so
I'll use a short example to clarify my problem:
Say I have a vector,
vec<-c(1,2,3,2)
I would like to be able to "reference" the vector by using the string
containing the name of the vector - that is, I would like to know of some
function which is able to convert the string "vec"
2000 Mar 29
2
regularly lattice & neighbors
Dear R-users,
Is there a procedure to identify neighbors in a regular lattice using either a
"rook" or a "queen" criterium? To be more specific, suppose:
My lattice:
1 2 3
4 5 6
7 8 9
"Rook" Neighbors
1 has neighbors 2,4
2 has neighbors 1,3,5
...
5 has neighbors 2,4,6,8
"Queen Neighbors"
1 has neighbors 2,4,5
2 has neighbors 1,3,4,5,6
For each case,
2011 Aug 02
1
matrix indexing (igraph ?)
I realize that matrix indexing has been addressed in various flavors, but I''m stumped and didn''t find anything in the archives. It''s not clear if it is an igraph issue or a more general problem. Thanks in advance for your patience.
I am using igraph to read a gml file (http://www-personal.umich.edu/~mejn/netdata/football.zip
). The gml file contains vertex attributes
2017 Oct 06
2
Time series: xts/zoo object at annual (yearly) frequency
Hi,
I'd like to make a time series at an annual frequency.
> a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993"))
Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) :
order.by requires an appropriate time-based object
> a<-xts(x=c(2,4,5), order.by=1991:1993)
Error in xts(x = c(2, 4, 5), order.by =
2013 Jan 21
4
compare and count data
Dear r-users,
I have these data below:
I would like to compare each column with a certain value and count how many in each column less than that specified value.
odd column (1,3,5) will compare with 1.61 and even column (2,4,6) will compare with 75 and I would like to count how many for each column.
I tried these below but it give me just one set of data.
critical <-
2006 Apr 01
3
has_and_belongs_to_many construction
Hi there,
I''ve got a table construction like this:
presentation contactstate
Hilton new
Mc Donalds emailed
etc. called
visited
etc.
Now i''ve created an join table presentationcontactstate with extra
fields like comment and date time. so i know for example when i called a
specific presentation.
Now
2011 Oct 18
2
About an integral univariate problem
Hello all R users
I want to calculate this univariate integral:
exp(-x)*sum(y^x) respect to x from 0 to 3 where y is a vector y=(2,3,5).
In fact, the original y vector has a large number of elements but I propose
with 3 elements.
I know that I can resolve this problem doing
fun <- function(x) exp(-x)*(2^x+3^x+5^x)
integrate(fun,0,3)
When the y vector has a large number of elements the
2009 Apr 16
2
Count data with several numbers separated by commas
Dear all,
I have a data file with 3 variables (x1, x2, x3) where variable x1
have data that consists of several numbers separated by commas.
id name x1 x2 x3
aa101 1,4,5 2 1
aa102 1,2,5 1 2
aa103 1,2,5 1 1
aa104 1,2,3 1 2
aa105 1,5 2 2
aa106 1,2,5 2 2
aa107 1,2,5 2 1
aa108 1,4,5 2 1
aa109 1,2 1 2
aa110 3,5 1 2
I want to count the number of data for each
2010 Sep 02
2
lower triangle of the correlation matrix with xtable
Dear all,
mydata<-data.frame(x1=c(1,4,6),x2=c(3,1,2),x3=c(2,1,3))
cor(mydata)
x1 x2 x3
x1 1.0000000 -0.5960396 0.3973597
x2 -0.5960396 1.0000000 0.5000000
x3 0.3973597 0.5000000 1.0000000
I wonder if it is possible to fill only lower triangle of this
correlation matrix? Using 'dist' doesn't seem to be useful as it doesnt
allow to convert this table
2005 Aug 10
1
Why only a "" string for heading for row.names with write.csv with a matrix?
Consider:
> x <- matrix(1:6, 2,3)
> rownames(x) <- c("ID1", "ID2")
> colnames(x) <- c("Attr1", "Attr2", "Attr3")
> x
Attr1 Attr2 Attr3
ID1 1 3 5
ID2 2 4 6
> write.csv(x,file="x.csv")
"","Attr1","Attr2","Attr3"
"ID1",1,3,5
2007 Nov 19
4
sequence of vectors
Dear All,
I wonder if there is any R function to generate a sequence of vectors from existing ones. For example:
x 1<- c(1,2,3)
x2 <- c(4,5)
x3 <- c(6,7,8)
The desired output is a list of all 3*2*3 = 18 possible combinations of elements of x1,x2 and x3. One element for example is (1,4,6).
Many thanks in advance,
Bernard
2004 Apr 02
4
Extending a vector
I believe this should be an easy thing to do...
I have a function I repeatably call which takes input parameters and
outputs columns to various data frames. I also wish to keep a summary of
certain values as I call the function. I though keeping the values in a
vector then appending the vector by the new amounts would be the way to
do this.
Example: (this is what I want even thought the below
2011 Feb 01
3
sum the values in a vector as a complete number
Hi
I am trying to create a function that is able to calculate this sum:
a<-c(2,3,5)
b<-(8,7)
with "a" meaning 235 and "b" 87. So the result of this sum would be 235 + 87
= 322.
I've searched a function like strsplit but that worked for integers and in
reverse - not spliting but combining.
Can you give me a hand on this please?
thanks
AD
--
View this message in