Displaying 20 results from an estimated 3000 matches similar to: "grep, gsub and metacharacters"
2009 Aug 25
3
Regular expression to define contents between parentheses
Hello dear R-helpers,
I haven't been able to figure out of find a solution in the R-help archives about how to delete all the characters contained in groups of parenthesis. I have a vector that looks more or less like this:
myvector<-c("something (80 km/h, sd) & more (6 kg/L,sd)", "somethingelse (48 m/s, sd) & moretoo (50g/L , sd)")
I want to extract all
2013 Feb 05
2
R Regular Expressions - Metacharacters
I thought that I can use metacharacters such as \w to match word characters
with one backslash. But for some reason, I need to include two backslashes.
> grepl(pattern='\w', x="what")
Error: '\w' is an unrecognized escape in character string starting "\w"
> grepl(pattern='\\w', x="what")
[1] TRUE
I can't find the reason for this
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
2008 Aug 06
1
Matching a period in grep...
Hi folks,
Can anyone enlighten me as to why I get the following when I search for
".csv" at the end of a string?
> grep("\.csv$","Blah.csv",value=TRUE)
[1] "Blah.csv"
Warning messages:
1: '\.' is an unrecognized escape in a character string
2: unrecognized escape removed from "[\.]csv$"
R reference for regular expressions says
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
2024 Aug 02
1
grep
?s 02:10 de 02/08/2024, Steven Yen escreveu:
> Good Morning. Below I like statement like
>
> j<-grep(".r\\b",colnames(mydata),value=TRUE); j
>
> with the \\b option which I read long time ago which Ive found useful.
>
> Are there more or these options, other than ? grep? Thanks.
>
> dstat is just my own descriptive routine.
>
> > x
> ?[1]
2007 Dec 03
3
Ordering the levels of a vector
Hi,
I have a vector in a data frame that looks
something like this:
day<-c('Day -1','Day 6','Day 10')
This vector specifies the order in which several
panel will appear in a lattice plots. But the order in
which such plots will appear will be the following:
Day -1, Day 10, Day 6. Which makes sense, but I cannot
name the Days like this: Day -01,Day 10, Day 06,
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
____________________________________________________________________________________
2008 Feb 27
2
Add a rectangle behind a plot
Hi there,
I found one reference to add a reactangle behind a
plot using plot(...,add=T), I tried this but didn't
obtain the desired result.
If a I have the following code:
plot(x,y)
rect(xleft, ybottom, xright,ytop,col='green)
The rectangle appear on top of the plot.
Any help will be greatly appreciated,
Judith