Displaying 20 results from an estimated 2000 matches similar to: "Regular expression to define contents between parentheses"
2008 Aug 22
1
grep, gsub and metacharacters
Hello,
I have an expression that I want to substitute for something else.
myvector<-c("ajkhfkiuwe","Variable(kg/min)")
if I use the following code to extract "variable(kg/min)" and substitute it for "va"
gsub(myvector[grep("var", myvector, ignore=T)], "va", myvector)
grep identifies the element of the vector that matches my
2012 Mar 10
2
Window on a vector
Dear all,
I have a large vector (lets call it myVector) and I want to plot its value with the logic below
yaxis<-myVector[1]
yaxis<-c(xaxis,mean(myvector[2:3])
yaxis<-c(xaxis,mean(myvector[4:8])
yaxis<c(xaxis,mean(myvector[9:16])
yaxis<c(xaxis,mean(myvector[17:32])
this has to stop when the new ..... yaxis<c(xaxis,mean(myvector[1024:2048]) will not find the correspondent number
2008 Nov 06
2
Fwd: SWIG with R and C++ STL
Hi, all
I didn't get any response from swig for my question.
see if I can get some help here
Thanks
---------- Forwarded message ----------
From: charlie <charlie.xia.fdu@gmail.com>
Date: Tue, Nov 4, 2008 at 1:55 PM
Subject: SWIG with R and C++ STL
To: swig-user@lists.sourceforge.net
Hi all,
I am new to SWIG. I encountered some problem when I try to SWIG to R some
C++ modules.
Here
2007 Dec 18
6
All anchored series from a vector?
>From: Johannes Graumann <johannes_graumann at web.de>
>Date: 2007/12/18 Tue PM 04:40:37 CST
>To: r-help at stat.math.ethz.ch
>Subject: [R] All anchored series from a vector?
lapply(1:length(myvector) function(.length) {
c(myvector[1}:myvector[.length])
})
but test it because i didn't.
>Hi all,
>
>What may be a smart, efficient way to get the following result:
2009 Feb 15
1
Overloading in R
I have been trying to write a new class that reimplements the vector
class. As a test of my overloading I decided to try and and call
t.test on two vectors which were objects of my class rather than the
default class.
The overloaded length I wrote seems to work correctly. I used
setMethod("length", "myvector", ...)
setMethod("mean", "myvector", ...)
2013 Aug 27
1
R Language Newbie
Hi,
set.seed(29)
myVector<- rnorm(100)
?seq(1,100,by=2)
# [1]? 1? 3? 5? 7? 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
#[26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
myVector[seq(1,100,by=2)]
rev(myVector)
?sum(myVector>0)
#[1] 46
#or
?table(myVector>0)
#
#FALSE? TRUE
?#? 54??? 46
A.K.
Hey guys, this is my first week
2012 Feb 26
6
loop for a large database
Yes, I am a newbie.
I have a data.frame (MyTable) of 1445846 rows and 15 columns with
character data.
And a character vector (MyVector) of 473491 elements.
I want simply to get a data.frame with the count of how many times each
element of MyVector appears in MyTable.
I've tried a loop with : for (i in 1 : length (myvector)) sum (MyTable== i)
but it crashes my computer.
I've also
2006 Apr 04
2
Selecting out certain values from a MATRIX
I have two objects, one matrix and one vector.
I want to use my vector to subset certain values out of my matrix.
For example:
I want to tell R, to select out all rows in myMatrix into a new myMatrix2 IF
that corresponding row is less than a 0.5 in myVector.
So:
myMatrix = a matrix of 8000 by 20
myVector = vector of 8000
myMatrix2 = a matrix of < 8000 by 20 (based on selection criteria in
2011 Sep 30
3
is member
Dear all,
I have a vector with number that some of them are part of the
seq(1,800,4). How can I check which of the numbers belong to the seq(1,800,4)
LEt's say that is called myvector the vector with the numbers.
Is there in R something like this?
is.member(myvector,seq(1,800,4))
I would like to thank you in advance for your help
B.R
Alex
[[alternative HTML version deleted]]
2012 Mar 14
1
check for data in a data.frame and return correspondent number
Dear R-ers,
still the newbie. With a question about coordinates of a vector appearing or
not in a data.frame.
I have a data.frame (MyData) with 3 columns which looks like this:
V1 V4 redNew
red-j 10.5032 appearance blood-n
red-j 9.3749 appearance ground-n
red-j 10.2167
2006 Mar 06
4
Contingency table and zeros
Hello,
Let's assume I have a vector of integers :
> myvector <- c(1, 2, 3, 2, 1, 3, 5)
My purpose is to obtain the cumulative distribution of these numerical
data, i.e. something like :
value nb_occur.
<=1 2
<=2 4
<=3 6
<=4 6
<=5 7
For this, I create a table with ;
> mytable <- table(myvector)
1 2 3 5
2 2 2 1
However, table() returns an array
2012 Jan 16
3
list: index of the element, that is TRUE
Dear People,
I have got the following example for a vector and the index of the TRUE
element:
Myvector <- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
which(Myvector)
Now I would like to find out the same for a list:
Mylist <- list(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
...
Does anyone know how to do this?
Thank you very much in advance,
Marion
[[alternative HTML
2008 Feb 05
6
Sampling
Hi there,
I want to generate different samples using the
followindg code:
g<-sample(LETTERS[1:2], 24, replace=T)
How can I specify that I need 12 "A"s and 12 "B"s?
Thank you,
Judith
____________________________________________________________________________________
Be a better friend, newshound, and
2008 Jul 10
2
Finding Values that Occur Most Often in a Vector
Hi,
Is there a way to do it?
For example I have the following vector:
> print(myvector)
> [1] -295.8045 -295.8045 -295.8045 -295.8045 -325.4754 -295.8045 -295.8045
[8] -295.8045 -413.2099 -295.8045
I want it to return -295.8045, which occur most often.
- Gundala Viswanath
Jakarta - Indonesia
2008 Feb 21
3
R console closes on its own
Dear R-experts,
I am running a script that has the following
structure:
windows(height=5.5,width=8)
dat<-read.csv("myfile.csv")
names(dat)<-c('a','b','c','d')
dat<-dat[,1:4]
xyplot(dat$a~dat$b)
Then I usually save the plot as a PDF (from the
menu in the R console). I can save the PDF twice in a
row; but at the third time, right when I
2012 Mar 24
1
plotting with line types... bit confusing
Dear all,
I would like to print an empirical cdf on a vector I have
while the plot(ecdf(myVector)) works great when I try to specify the line type to be a line (I get points) with
plot(ecdf(myVector),type="lines")
Error in plot.default(NA, NA, type = "n", xlim = xlim, ylim = ylim, xlab = xlab, :
formal argument "type" matched by multiple actual arguments
I get
2011 Sep 29
1
multiplying list with vector
hello everybody,
i have got a question about lists:
i have got the following commands:
mylist <- list("v1"=c(1,2,2,1),"v2"=c(2,2,2,1),"v3"=c(1,1,1,1))
myvector <- c(100,10000,1000000)
now i would like to multiply each element of the list with the corresponding
element of the vector, that is to say:
v1*100
v2*10000
v3*1000000
i only could think of lapply
2007 Jun 13
2
Removing Inf and Inf values from a fata frame
Hi,
I have a csv file with empty values, when I apply
the different functions (mean, std, etc.) I create a
new data frame, the empty values generate Inf and -Inf
values. How can I remove those Inf and -Inf values
from the new data frame? I already specified na.rm in
the mean and std functions, but the values are still
there.
Thank you,
Judith
2007 Jul 02
2
Substitution of Variables
Hi,
I need to run a script under the variable (that
comes from a csv file) that is assigned to another
variable. This is very a simplified version of what I
want to do:
data<-read.csv('name.csv')
names(data)<-("VA","VB","VC")
v<-VA
mn(v)
Thank you in advance,
Judith
2008 Feb 26
2
Multiple lines with a different color assigned to each line (corrected code)
Sorry, I just realized I didn't type in the correct
names of the variables I am working with, this is how
it should be:
plot(1,1,type="n")
for (i in summ$tx) {
points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
}
Thank you,
Judith
____________________________________________________________________________________