Displaying 20 results from an estimated 20000 matches similar to: "code patterns in vector"
2011 Jun 03
2
Arules: R Crashes when running eclat with tidLists=TRUE
Hello,
I'm using the eclat function of the arules package (1.0-6) for the
identification of frequent itemsets. I need the tidLists, but if I set
in the function tidLists=TRUE R crashes (Windows XP Professional SP3,
32 bit, R version 2.12.1 (2010-12-16), reproducible on two different
computers) with two different error messages or non at all. Minimum
examples are:
library(arules)
2012 Oct 08
1
Any better way of optimizing time for calculating distances in the mentioned scenario??
Dear All,
I'm dealing with a case, where 'manhattan' distance of each of 100
vectors is calculated from 10000 other vectors. For achieving this,
following 4 scenarios are tested:
1) scenario 1:
> x<-read.table("query.vec")
> v<-read.table("query.vec2")
> d<-matrix(nrow=nrow(v),ncol=nrow(x))
> for (i in 1:nrow(v)){
+ d[i,]<-
2010 Jul 12
2
findInterval and data resolution
Hello Wise Ones...
I need a clever way around a problem with findInterval. Consider:
vec1 <- 1:10
vec2 <- seq(1, 10, by = 0.1)
x1 <- c(2:3)
a1 <- findInterval(x1, vec1); a1 # example 1
a2 <- findInterval(x1, vec2); a2 # example 2
In the problem I'm working on, vec* may be either integer or numeric, like
vec1 and vec2. I need to remove one or more sections of this vector;
2009 Jun 22
2
Help on creating a sequence of vectors
I want to create a number of vectors like :
vec1 <- rnorm(1)
vec2 <- rnorm(2)
vec3 <- rnorm(3)
and so on...........
Here I tried following :
for (i in 1:10) paste("vec", i, sep="") <- rnorm(i)
However obviously that is not working. Here vectors I need to be seperated
i.e I do not want to create a "list". How to modify above code?
--
View this
2013 Jun 18
1
transform 3 numeric vectors empty of 0/1
Dear all,
Without a loop, I would like transform 3 numeric vectors empty of 0/1 of
same length
Vec1 : transform 1 to A and 0 to ""
Vec2 : transform 1 to B and 0 to ""
Vec3 : transform 1 to C and 0 to ""
to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC,
BC, AC, AB,...)
Any idea ?
Thank you for your help
--
Michel ARNAUD
2001 Nov 12
2
[Q] Setting elements of a vector
Hi!
I'm new to R and have problems with the following code:
<code>
awprob<-c(0.4,0.4,0.1,0.1)
awsample<-sample(c(1:4),3,awprob,replace=TRUE)
vec<-vector(mode="numeric",10000)
vec[]<-sum(sample(c(1:4),20,awprob,replace=TRUE))
</code>
My problem: The elements of vec have the same value. How
can I tell R that I want to have a *new* sample for each value
and
2010 Aug 24
3
multiple assignments ?
Simple one, have read and googled, still no luck!
I want to create several empty vectors all of the same length.
I would like multiple empty vectors (vec1, vec2, vec3) and want to create them all in one line.
I've tried
vec1,vec2,vec3 <- vector(length=5)
and
c(vec1,vec2,vec3) <- vector(length=5)
and several other attempts but nothing seems to work ... suggestions?
Thanks
Jim
2013 Apr 22
1
Print occurrence / positions of words
Hi,
May be this helps:
vec<- "this is a nice text with nice characters"
library(stringr)
?vec2<-unlist(str_match_all(vec,"\\w+"))
#or
# vec2<-str_split(vec," ")[[1]]
res<-unique(lapply(vec2,function(x) which(!is.na(match(vec2,x)))))
?names(res)<- unique(vec2)
res
#$this
#[1] 1
#
#$is
#[1] 2
#
#$a
#[1] 3
#
#$nice
#[1] 4 7
#
#$text
#[1] 5
#
#$with
#[1]
2007 Feb 01
2
Losing factor levels when moving variables from one context to another
Hi, there
I'm currently trying to figure out how to keep my "factor" levels for a
variable when moving it from one data frame or matrix to another.
Example below:
vec1<-(rep("10",5))
vec2<-(rep("30",5))
vec3<-(rep("80",5))
vecs<-c(vec1, vec2, vec3)
resp<-rnorm(2,15)
dat<-as.data.frame(cbind(resp, vecs))
2008 Oct 20
2
R Newbie Question
Hello list,
I just started R today and tried something quite simple. I wanted to
create a colored plot and eventually after hours of fiddling around got
it working. However, my solution seems very suboptimal and I'd really
appreciate your hints on how to improve. I believe that R already offers
many functions I coded (e.g. distance between two vectors, vector
length, vector normalization and
2002 Jun 18
5
insert number in vector
Hello R-users,
I need to create a vector inserting an 1 after each value of another vector.
For example:
vec1<-c(2,3,4)
I need to create a vector with the values 2,1,3,1,4
Does anyone know how create this vector without loops (vec1 could have 1000
elements)
Thank you,
Juan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read
2008 Dec 30
2
[LLVMdev] Folding vector instructions
Hello.
Sorry I am not sure this question should go to llvm or mesa3d-dev mailing
list, so I post it to both.
I am writing a llvm backend for a modern graphics processor which has a ISA
very similar to that of Direct 3D.
I am reading the code in Gallium-3D driver in a mesa3d branch, which
converts the shader programs (TGSI tokens) to LLVM IR.
For the shader instruction also found in LLVM IR,
2006 Apr 15
1
Removing Rows/Records from a Table
I would like to selectively remove rows from a table.
I had hoped that I could create a table and
selectively add rows with something like
> NewTable<-table(nrow=100, ncol=4)
> NewTable[1,]<-OldTable[10,]
but that doesn't work. The former call gives
> NewTable
ncol
nrow 4
100 1
while the latter call gives a table the length of
OldTable. Making a matrix, m, with the
2011 Apr 01
1
How to paste a vector of expressions and a character vector?
Dear expeRts,
I know I can't paste expressions in the normal way, but I just couldn't figure out
how to get the following (I want to paste a character vector to an expression vector)
right with bquote() or substitute.
vec1 <- c("a", expression(tilde(b)), "c")
vec2 <- c("1", "2", "3")
main <- as.expression(paste(vec1, vec2))
2013 Apr 25
2
Selecting and then joining data blocks
Hi all,
I have 4 matrices, each having 5 columns and 4 rows .....denoted by
B1,B2,B3,B4.
I have generated a vector of 7 indices, say (1,2,4,3,2,3,1} which refers to
the index of the matrices to be chosen and then appended one on the top of
the next: like, in this case, I wish to have the following mega matrix:
B1over B2 over B4 over B3 over B2 over B3 over B1.
1> How can I achieve this?
2013 Apr 18
1
vectors with equal values
Hi,
Try:
?vec1<-c(1,1,1,1,1,1,1,1,1)
if(all(vec1==1)) "xxxxxxxxx" else? "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
?vec2<-c(rep(1,4),2)
?if(all(vec2==1)) "xxxxxxxxx" else? "yyyyyyyyyyy"
#[1] "yyyyyyyyyyy"
#or
if(length(unique(vec1))==1) "xxxxxxxxx" else? "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
? if(length(unique(vec2))==1)
2008 May 12
1
lexicographic comparison of two vectors
Is there any built-in way to lexicographically compare two vectors of
the same length in R? The textbook algorithm could be coded as follows:
lex.cmp <- function (vec1,vec2) {
for (j in 1:length(vec1)) {
if (vec1[j] < vec2[j]) { return(-1) }
if (vec1[j] > vec2[j]) { return(1) }
}
return(0)
}
Thanks,
Gabriel
1996 Nov 25
2
XMCD v2.1 released (was: Security Problems in XMCD)
This is to announce that XMCD 2.1 patchlevel 0 has been released
which fixes all of the issues previously raised by David Meltzer.
It also contains a number of other minor feature and functionality
enhancements. The new version may be obtained via the xmcd web page at:
http://sunsite.unc.edu/~cddb/xmcd/
Users of xmcd with older versions are encouraged to upgrade.
-Ti
--
\\ // XMCD - Motif CD
2008 Jun 27
0
[LLVMdev] Vector instructions
On Jun 27, 2008, at 8:02 AM, Stefanus Du Toit wrote:
>>>> <result> = shufflevector <a x <ty>> <v1>, <b x <ty>> <v2>, <d x
>>>> i32>
>>>> <mask> ; yields <d x <ty>>
>>>
>>> With the requirement that the entries in the (still constant) mask
>>> are
>>> within
2008 Nov 18
2
random value changes in a vector
To clear up a question regarding my earlier posting regarding random changes in a vector:
Say you have a vector (1, -1, -1, 1, 1, -1). I want each value in the vector to have a probability that it will change signs when this vector is regenerated. For example, probability = 50%. When the vector is regenerated, the first value in the vector (1) has a 50% chance of switching to -1. If I