to count the number of each letter
> appearing in the string?
>
> For example, the letter "A" appeared 6 times, letter "T" appeared 5 times,
> how can I use a string function to get the these number?
>
> thanks,
>
> karena
>
--
View this message in c
Try this:
sprintf("%s_%s", rep(1:58, each = 2), c("input", "output"))
On Mon, Mar 21, 2011 at 4:03 PM, Justin Haynes wrote:
> Is there a way to do this in R? I have data in the form:
>
> 57_input 57_output 58_input 58_output etc.
>
> can i use a for loop (i in 57:n) that plots only the out
On Mon, Mar 21, 2011 at 2:03 PM, Justin Haynes wrote:
> Is there a way to do this in R? I have data in the form:
>
> 57_input 57_output 58_input 58_output etc.
>
> can i use a for loop (i in 57:n) that plots only the outputs? I want
> this to be robust so im not specifying a column id but ra
Is there a way to do this in R? I have data in the form:
57_input 57_output 58_input 58_output etc.
can i use a for loop (i in 57:n) that plots only the outputs? I want
this to be robust so im not specifying a column id but rather
something like c++ code,
%s_input, i
is that doable in R?
Thank you so much, David. Your solution exactly suits my need.
formula() seems the key.
appreciate your help!
On Sat, Mar 12, 2011 at 10:22 AM, David Winsemius
wrote:
>
> On Mar 12, 2011, at 10:10 AM, Wensui Liu wrote:
>
>> Good morning, dear listers
>>
>> I am wondering how to do string evalua
On Mar 12, 2011, at 10:10 AM, Wensui Liu wrote:
Good morning, dear listers
I am wondering how to do string evaluation such that
model <- glm(Y ~ [STRING], data = mydata) where STRING <- "x1 + x2 +
x3"
It is very doable in other language such as SAS.
Also "very doable" in R. You need to
Good morning, dear listers
I am wondering how to do string evaluation such that
model <- glm(Y ~ [STRING], data = mydata) where STRING <- "x1 + x2 + x3"
It is very doable in other language such as SAS.
Thank you so much for your insight!
__
R-help@r-
Dennis,
If I understand you correctly (your example does not point unambiguously
to one unique solution...)
you could try:
dummy<- c('ac','ac','c','ac','ac','c')
dummy.rle<-rle(dummy)
result <- paste(dummy.rle$values,dummy.rle$lengths,collapse='_',sep='')
You may need to remove the '1' in du
Try this:
> x <- c('ac','ac','c','ac','ac','c')
> rle(x)
Run Length Encoding
lengths: int [1:4] 2 1 2 1
values : chr [1:4] "ac" "c" "ac" "c"
> z <- rle(x)
> paste(z$values, ifelse(z$lengths == 1, '', z$lengths), collapse='_', sep = '')
[1] "ac2_c_ac2_c"
>
On Tue, Mar 8, 2011 at 6:33 PM, Deni
Dear [R] people
Could you please help with following
How to convert a vector
'ac','ac','c','ac','ac','c'
into a single string
'ac2_c_ac2_c'
Thank you in advance
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEAS
> * David Winsemius [2011-02-16 13:33:32 -0500]:
>
>> parse.num <- function (s) {
>> as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
>
> data[1] <- parse.num( data[[1]] ) # as.numeric and gsub are vectorized
because parse.num turned out to not be as simple as that: I need to
handle "N/A" specia
2011 9:01 PM
To: s...@gnu.org; r-h...@stat.math.ethz.ch
Subject: Re: [R] string parsing
> To: r-h...@stat.math.ethz.ch
> From: s...@gnu.org
> Date: Tue, 15 Feb 2011 17:20:11 -0500
> Subject: [R] string parsing
>
> I am trying to get s
On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold wrote:
> I am trying to get stock metadata from Yahoo finance (or maybe there is
> a better source?)
> here is what I did so far:
>
> yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
> stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY"
On Feb 16, 2011, at 2:26 PM, David Winsemius wrote:
On Feb 16, 2011, at 2:09 PM, Sam Steingold wrote:
* David Winsemius [2011-02-16 13:33:32
-0500]:
parse.num <- function (s) {
as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
data[1] <- parse.num( data[[1]] ) # as.numeric and gsub ar
On Feb 16, 2011, at 2:09 PM, Sam Steingold wrote:
* David Winsemius [2011-02-16 13:33:32
-0500]:
parse.num <- function (s) {
as.numeric(gsub("M$","e6",gsub("B$","e9",s))); }
data[1] <- parse.num( data[[1]] ) # as.numeric and gsub are
vectorized
because parse.num turned out to not be
On Feb 15, 2011, at 5:20 PM, Sam Steingold wrote:
I am trying to get stock metadata from Yahoo finance (or maybe there
is
a better source?)
here is what I did so far:
yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # j
try this:
> x <- c('15.5B', '13.6M')
> x <- sub("B", 'e9', x)
> x <- sub("M", 'e6', x)
> as.numeric(x)
[1] 1551360
On Tue, Feb 15, 2011 at 5:20 PM, Sam Steingold wrote:
> I am trying to get stock metadata from Yahoo finance (or maybe there is
> a better source?)
> here is what I
Grothendieck
Cc: r-help@r-project.org
Subject: Re: [R] String manipulation
Hi Gabor, thanks (and Jim as well) for your suggestion. However this is not
working properly for following string:
> MyString <- "ABCFR34564IJVEOJC3434.36453"
> strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d
> To: r-h...@stat.math.ethz.ch
> From: s...@gnu.org
> Date: Tue, 15 Feb 2011 17:20:11 -0500
> Subject: [R] string parsing
>
> I am trying to get stock metadata from Yahoo finance (or maybe there is
> a better source?)
search th
I am trying to get stock metadata from Yahoo finance (or maybe there is
a better source?)
here is what I did so far:
yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";;
stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # just some samples
socket <- url(paste(yahoo.url,sep="",pa
Hi Gabor, thanks (and Jim as well) for your suggestion. However this is not
working properly for following string:
> MyString <- "ABCFR34564IJVEOJC3434.36453"
> strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d +)",
c)[[1]]
[1] "ABCFR" "34564" "IJVEOJC" "3434"
Therefore there is decimal number in th
Just add '.' to the pattern specifier:
> MyString <- "ABCFR34564IJVEOJC3434.16ABC123.456KJHLKJH23452345AAA"
> # translate to the pattern sequences
> x <- chartr('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'
+ , '00111'
+ , MyString
+ )
> x.rl
On Sun, Feb 13, 2011 at 4:42 PM, Megh Dal wrote:
> Hi Gabor, thanks (and Jim as well) for your suggestion. However this is not
> working properly for following string:
>
>> MyString <- "ABCFR34564IJVEOJC3434.36453"
>> strapply(MyString, "(\\D+)(\\d+)(\\D+)(\\d+)", c)[[1]]
> [1] "ABCFR" "34564"
If you have an indeterminate number of the patterns in the string, try
the following:
> MyString <- "ABCFR34564IJVEOJC3434"
> # translate to the pattern sequences
> x <- chartr('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
+ , '0011'
+ , MyString
+
On Sun, Feb 13, 2011 at 10:27 AM, Megh Dal wrote:
> Please consider following string:
>
> MyString <- "ABCFR34564IJVEOJC3434"
>
> Here you see that, there are 4 groups in above string. 1st and 3rd groups
> are for english letters and 2nd and 4th for numeric. Given a string, how can
> I separate ou
Please consider following string:
MyString <- "ABCFR34564IJVEOJC3434"
Here you see that, there are 4 groups in above string. 1st and 3rd groups
are for english letters and 2nd and 4th for numeric. Given a string, how can
I separate out those 4 groups?
Thanks for your time
[[alternative
Try this:
embed(scan(textConnection(x), sep = ","), 2)
On Wed, Feb 2, 2011 at 10:12 AM, Romildo Martins
wrote:
> Hello,
>
>
> How to convert x into y?
>
> > x
> [1] "15, 23, 2, 21, 11, 5"
>
> > y
> [,1] [,2]
> [1,] 15 23
> [2,] 232
> [3,]221
> [4,] 21 11
> [5,] 11
Hello,
How to convert x into y?
> x
[1] "15, 23, 2, 21, 11, 5"
> y
[,1] [,2]
[1,] 15 23
[2,] 232
[3,]221
[4,] 21 11
[5,] 115
Thanks a lot!
Romildo
[[alternative HTML version deleted]]
__
R-help@r-project.o
On Tue, Feb 1, 2011 at 12:42 PM, Yan Jiao wrote:
> Dear R guru:
>
>
>
> If I got a variable
>
> aaa<- "up.6.11(16)"
>
>
>
> how can I extract 16 out of the bracket?
>
> I could use substr, e.g.
>
> substr(aaa, start=1, stop=2)
>
> [1] "up"
>
>
>
> But it needs start and stop, what if my start or s
Yan -
Here's one way. It assumes there's exactly one set of
brackets in the string, and they can be anywhere:
aaa<- "up.6.11(16)"
sub('^.*?\\((.*)\\).*$','\\1',aaa)
[1] "16"
- Phil Spector
Statistical Computi
Try this:
gsub(".*\\((\\d+)\\).*", "\\1", aaa)
On Tue, Feb 1, 2011 at 3:42 PM, Yan Jiao wrote:
> Dear R guru:
>
>
>
> If I got a variable
>
> aaa<- "up.6.11(16)"
>
>
>
> how can I extract 16 out of the bracket?
>
> I could use substr, e.g.
>
> substr(aaa, start=1, stop=2)
>
> [1] "up"
>
>
>
>
Dear R guru:
If I got a variable
aaa<- "up.6.11(16)"
how can I extract 16 out of the bracket?
I could use substr, e.g.
substr(aaa, start=1, stop=2)
[1] "up"
But it needs start and stop, what if my start or stop is not fixed, I
just want the number inside the bracket, how can I achi
Try this:
library(gsubfn)
strapply("11 - 23", "\\d{1,3}", simplify = as.numeric)
On Thu, Dec 9, 2010 at 12:24 PM, Romildo Martins
wrote:
> Hello,
>
> how convert x in xarray (numbers)?
>
> > x
> [1] "0 - 13"
> > y
> [1] "11 - 23"
> > z
> [1] "220 - 9"
> > xarray
> [1] 0 13
> > yarray
> [1] 11 2
Try
f <- function(string) as.numeric(strsplit(string, "- ")[[1]])
f(x)
f(y)
f(z)
HTH,
Jorge
On Thu, Dec 9, 2010 at 9:24 AM, Romildo Martins <> wrote:
> Hello,
>
> how convert x in xarray (numbers)?
>
> > x
> [1] "0 - 13"
> > y
> [1] "11 - 23"
> > z
> [1] "220 - 9"
> > xarray
> [1] 0 13
> > ya
"Romildo Martins" wrote in message
news:aanlktinbiaexcobzyqdbtr62xr9q=kjvwaazaqi-k...@mail.gmail.com...
> Hello,
>
> how convert x in xarray (numbers)?
>
>> x
> [1] "0 - 13"
>> y
> [1] "11 - 23"
>> z
> [1] "220 - 9"
>> xarray
> [1] 0 13
>> yarray
> [1] 11 23
>> zarray
> [1] 220 9
>
>
>
> Than
Romildo Martins gmail.com> writes:
> how convert x in xarray (numbers)?
>
> > x
> [1] "0 - 13"
> > y
> [1] "11 - 23"
> > z
> [1] "220 - 9"
> > xarray
> [1] 0 13
> > yarray
> [1] 11 23
> > zarray
> [1] 220 9
Is
as.numeric(unlist(strsplit("0 - 13","-")))
what you want?
Hello,
how convert x in xarray (numbers)?
> x
[1] "0 - 13"
> y
[1] "11 - 23"
> z
[1] "220 - 9"
> xarray
[1] 0 13
> yarray
[1] 11 23
> zarray
[1] 220 9
Thanks,
RMB
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
It took me quite some time to understand the difference between sep and
collapse.
The examples in Phil Spector's book (2008) helped me to get it:
paste(c('X','Y'), 1:5, sep='_')
"X_1" "Y_2" "X_3" "Y_4" "X_5"
paste(c('X','Y'), 1:5, collapse='|') ## sep=" " by default
[1] "X 1|Y 2|X 3|Y 4|X 5"
p
Ivan's advice is good, but understanding clearly what
"character string to separate the results" might mean is
a bit tricky!
Example:
cvec <- c("J","e"," ","m","'","a","p","p","e","l","l","e",
" ","B","e","n","o","i","t")
cstring <- paste(cvec,collapse="")
cstring
# [1] "Je m'
On Dec 7, 2010, at 10:11 AM, Benoit Wastine wrote:
Hi,
I'm running R 2.11
Does anyone know if it possible to transform one character vector to
one character string ?
?gsub
Also look at the even more powerful gsubfn package. There is also the
stringr package.
--
David Winsemius, MD
Wes
Hi,
If I understand what you mean (no example...), see ?paste and the
collpase argument
Ivan
Le 12/7/2010 16:11, Benoit Wastine a écrit :
Hi,
I'm running R 2.11
Does anyone know if it possible to transform one character vector to
one character string ?
Many thanks
Benoit
--
Ivan CALANDR
do we, what's the word... imbue it."
- Jubal Early, Firefly
r-help-boun...@r-project.org wrote on 12/07/2010 10:11:41 AM:
> [image removed]
>
> [R] string
>
> Benoit Wastine
>
> to:
>
> r-help
>
> 12/07/2010 10:14 AM
>
> Sent by:
>
> r
Hi,
I'm running R 2.11
Does anyone know if it possible to transform one character vector to one
character string ?
Many thanks
Benoit
--
Benoit Wastine
Laboratoire des Sciences du Climat et de l’Environnement (LSCE/IPSL)
CEA-CNRS-UVSQ
CE Saclay
Orme des merisiers
Bât 703 - Pte 13A
91191 Gif s
On Wed, Sep 29, 2010 at 4:15 AM, Steven Kang wrote:
> x <- rep(letters[1:3], 2)
>
> Are there any ways to transform & assign the above as the one shown below
> to an object? (in exact format; i.e length of 1 & class of character),
> i.e
>>x
> "('a', 'b', 'c', 'a', 'b', 'c')"
>
> Highly appreciate
> Cc: r-help@r-project.org
> Subject: Re: [R] String split and concatenation
>
> > paste( '(', paste( "'", rep(letters[1:3],2), "'", sep="",
> collapse=','), ')', sep="" )
> [1] "('a',
-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Steven Kang
> Sent: Wednesday, September 29, 2010 2:16 AM
> To: bill.venab...@csiro.au
> Cc: r-help@r-project.org
> Subject: Re: [R] String split and concatenation
>
> x <- rep(le
ighly appreciate for any advice.
On Wed, Sep 29, 2010 at 3:33 PM, wrote:
> dump("x", file = "x.R")
> file.show("x.R")
>
> will get you most of the way.
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@
dump("x", file = "x.R")
file.show("x.R")
will get you most of the way.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Steven Kang
Sent: Wednesday, 29 September 2010 3:11 PM
To: r-help@r-project.org
Hi Steven,
This should do it:
paste('"', unlist(strsplit(x, split="")), c(rep('",', length(x)-1), ""), sep="")
-Ista
On Wed, Sep 29, 2010 at 1:11 AM, Steven Kang wrote:
> Hi R users,
>
>
> I desire to transform the following vector consisting of repeated characters
>
> x <- rep(letters, 3)
> in
Hi R users,
I desire to transform the following vector consisting of repeated characters
x <- rep(letters, 3)
into this exact format (i.e a single string containing each characters in
quotation mark separated by comma between each; al ).
("a", "b", "c", "d", "a", "b", "c", "d",
Hi Brian,
On 07/21/2010 10:02 AM, Davis, Brian wrote:
[...]
Part 2)
My next step in the string processing is to take the characters in the output
of CleanRead and subtract 33 from the ascii value of the character to obtain an
integer. Again I have a solution that works, involving splitting the
On 07/21/2010 10:02 AM, Davis, Brian wrote:
> I have a two part question
>
> Part 1) I am trying to remove characters in a string based on the
> position of
a key character in another string. I have a solution that works but it
requires a for-loop. A vectorized way of doing this has alluded me.
H
On Wed, Jul 21, 2010 at 1:02 PM, Davis, Brian wrote:
> I have a two part question
>
> Part 1)
> I am trying to remove characters in a string based on the position of a key
> character in another string. I have a solution that works but it requires a
> for-loop. A vectorized way of doing this h
I have a two part question
Part 1)
I am trying to remove characters in a string based on the position of a key
character in another string. I have a solution that works but it requires a
for-loop. A vectorized way of doing this has alluded me.
CleanRead<-function(x,y) {
if (!is.characte
Thanks so lot
--
View this message in context:
http://r.789695.n4.nabble.com/String-truncate-tp2284045p2284069.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-h
Thanks this works
On Fri, Jul 9, 2010 at 4:32 PM, Wu Gong [via R] <
ml-node+2284062-824667456-312...@n4.nabble.com
> wrote:
> Do you mean substring?
>
> sub(".txt","", "mytest.txt")
> A R learner.
>
>
> --
> View message @
> http://r.789695.n4.nabble.com/String-trunc
one string named as: mytest.txt
how can I remove the .txt and return the mytest only.
i tried split substr, and grep didn't work it out,
Thanks so lot
--
View this message in context:
http://r.789695.n4.nabble.com/String-truncate-tp2284045p2284045.html
Sent from the R help mailing list archi
Do you mean substring?
sub(".txt","", "mytest.txt")
-
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/String-truncate-tp2284045p2284062.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-projec
You can try noquote also:
noquote(paste('abc', '"xyz"', sep = ""))
On Wed, Jun 30, 2010 at 3:31 PM, Paul Evans wrote:
> Hi,
>
> How can I get double quotes embedded in the string?
>
> Example:
>
> --
> str1 <- '"xyz"'
>
> ## desired output
> # abc"xyz"
>
> qr2 <- paste('abc',str1,s
cat() is probably what you want, but note that print()
has a 'quote=' argument that you could set to FALSE:
print(qr2, quote = FALSE)
See ?print.default
-Peter Ehlers
On 2010-06-30 13:16, Phil Spector wrote:
Paul -
When you print a string, it escapes the quotes with a backslash. That's
a
Paul -
When you print a string, it escapes the quotes with a
backslash. That's a property of the print() function,
not the string itself.
If you want to see the string, use cat(). The nchar()
function is also useful:
str1 <- '"xyz"'
qr2 <- paste('abc',str1,sep='')
print(qr2)
[1] "abc\
Hi,
How can I get double quotes embedded in the string?
Example:
--
str1 <- '"xyz"'
## desired output
# abc"xyz"
qr2 <- paste('abc',str1,sep='')
print(qr2)
-
Actual output:
> [1] "abc\"str\""
I also tried putting an escape sequence before the quote, but couldn'
Here is a slightly simpler variant of the strapply solution:
> lapply(DF, strapply, "(.)/(.)", c, simplify = rbind)
$var1
[,1] [,2]
[1,] "G" "G"
[2,] "A" "T"
[3,] "G" "G"
$var2
[,1] [,2]
[1,] "C" "T"
[2,] "C" "C"
[3,] "A" "A"
On Fri, Jun 4, 2010 at 8:08 AM, Gabor Grothendieck
w
Thank you guys very much, these help!!
--
View this message in context:
http://r.789695.n4.nabble.com/string-handling-tp2242119p2243388.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.eth
This solution using strapply in gsubfn is along the same lines as the
stringr solution. First we read in the data using as.is = TRUE so
that we get character rather than factor columns. On the other hand,
if your data is already in columns with class factor then just replace
strappy(x, ...) with
On Thu, Jun 3, 2010 at 4:06 PM, Wu Gong wrote:
>
> Hope it helps.
>
> text <- "var1 var2
> 9G/G09 abd89C/T90
> 10A/T9 32C/C
> 90G/G A/A"
>
> x <- read.table(textConnection(text), header = T)
Or with the stringr package:
library(stringr)
str_match(x$var1, "(.)/(.)")
Hadley
--
Hope it helps.
text <- "var1var2
9G/G09abd89C/T90
10A/T932C/C
90G/G A/A"
x <- read.table(textConnection(text), header = T)
x$var1.1 <- sub(".*(.)/.*", "\\1", x$var1)
x$var1.2 <- sub(".*/(.).*", "\\1", x$var1)
x$var2.1 <- sub(".*(.)/.*", "\\1", x$var2)
x$var2.2 <- sub(".*/(.
try this:
> x <- "1234C/Tasdf"
> y <- strsplit(sub("^.*(.)/(.).*", "\\1 \\2", x),' ')[[1]]
> y
[1] "C" "T"
>
On Thu, Jun 3, 2010 at 2:18 PM, karena wrote:
>
> I have a data.frame as the following:
> var1 var2
> 9G/G09 abd89C/T90
> 10A/T9 32C/C
> 90G/G A/A
> . .
> .
I have a data.frame as the following:
var1var2
9G/G09abd89C/T90
10A/T932C/C
90G/G A/A
. .
. .
. .
10T/C 00G/G90
What I want is to get the letters which are on the left and right of '/'.
for example, for "9G/G09", I only want "G", "G",
On May 8, 2010, at 10:05 AM, Webby wrote:
Dear community,
I have a problem with a string conversion:
text
[1] "" "and""\xc1d\xe1m"
[4] "graphical" "interface" "MLP"
[7] "Nagy" "networks" "Networks"
[10] "neural"
See
?Encoding and ?iconv:
iconv("\xc1d\xe1m", from = '', to = 'latin1')
On Sat, May 8, 2010 at 11:05 AM, Webby wrote:
>
> Dear community,
>
> I have a problem with a string conversion:
>
> > text
> [1] "" "and""\xc1d\xe1m"
> [4] "graphical" "interf
Dear community,
I have a problem with a string conversion:
> text
[1] "" "and""\xc1d\xe1m"
[4] "graphical" "interface" "MLP"
[7] "Nagy" "networks" "Networks"
[10] "neural" "Neural" "RBF"
[13] "
See ?strwidth
On Sat, Mar 27, 2010 at 3:42 PM, Dennis Fisher wrote:
> Colleagues,
>
> I am trying to create a PDF document in which I use margin text with two
> different fonts. The resulting text might be:
> XyZZZ
> where X and Z are one font and Y is the other.
>
> My plan was to d
Colleagues,
I am trying to create a PDF document in which I use margin text with two
different fonts. The resulting text might be:
XyZZZ
where X and Z are one font and Y is the other.
My plan was to do this in the following manner:
mtext("X ZZZ", cex=2, adj=0.5, family=S
Thank you
I am waiting for the R to finish running the loop..I hope it will work..
muting
Quoting "jholtman [via R]" :
>
>
>
> try this:
>
> x <- lapply(v.fundno, function(.fund){
>sqlQuery(channel, paste("select mret from monthly_return where
> crsp_fundno =",
>.fund, 'and caldt >
Hi Charlie:
I tried
gmret<-sqlQuery(channel,
paste( "select mret from Monthly_returns where crsp_fundno =",
v.fundno[1] )
)
It works well.. I think you got my problem solved,R just need time to run
the loop, not dead..
Thank you very much
Muting
--
View this message in context:
http:/
try this:
x <- lapply(v.fundno, function(.fund){
sqlQuery(channel, paste("select mret from monthly_return where
crsp_fundno =",
.fund, 'and caldt > 19700630 order by caldt')
})
result <- do.call(rbind, x)
On Fri, Mar 26, 2010 at 2:07 PM, muting wrote:
>
> Hi Charlie
>
> Thank you fo
Hi Charlie
Thank you for your advice, but it makes my R dead...
My head(v.fundno) is
> head(v.fundno)
[1] "2899" "2903" "2960" "3094" "3095" "3211"
I tried to plug in the specific value like 2890 and 2960 :
gmret.2899<-sqlQuery(channel,"select caldt, mret from Monthly_returns where
crsp_fundno
Muting Zhang wrote:
>
> Hello all
>
> I have been working on my thesis using R. I am a newbie to R and met a
> problem
> that bothered me for a while due to my lack of acquaintance of R.
>
> I am using R to query from SQL. I got a list of crsp_fundno of G-style
> mutual
> funds which is still
Hello all
I have been working on my thesis using R. I am a newbie to R and met a problem
that bothered me for a while due to my lack of acquaintance of R.
I am using R to query from SQL. I got a list of crsp_fundno of G-style mutual
funds which is still alive. I use the following codes and got wh
The '[[' is just the index access to an object. type:
?'[['
to see the help page.
Actually I should have used '[' in this case:
> sapply(y, '[', 1)
[1] "1234567" "1234567" "1234567"
is equivalent to:
> sapply(y, function(a) a[1])
[1] "1234567" "1234567" "1234567"
>
So set a value based o
Yes, that was perfect! Thank you so much!
Just to clarify, since I'm kind of new to string manipulation-- is that '[['
in the sapply function what is designating splits/elements within the
string? So that's the part that says "I want this particular element" and
the "1" or "2" or "number" is what
On Fri, Feb 5, 2010 at 9:29 AM, jim holtman wrote:
> Does this help:
>
>> x <-
>> c("1234567.z3.abcdef-gh.12","1234567.z3.abcdef-gh.12","1234567.z3.abcdef-gh.12")
>> y <- strsplit(x, '[.]')
Here's another way with the stringr package:
library(stringr)
x <-
c("1234567.z3.abcdef-gh.12","1234567.
Does this help:
> x <-
> c("1234567.z3.abcdef-gh.12","1234567.z3.abcdef-gh.12","1234567.z3.abcdef-gh.12")
> y <- strsplit(x, '[.]')
>
> y
[[1]]
[1] "1234567" "z3""abcdef-gh" "12"
[[2]]
[1] "1234567" "z3""abcdef-gh" "12"
[[3]]
[1] "1234567" "z3""abcdef-gh" "12"
> y
I am currently attempting to split a long list of strings (let's call it
"string.list") that is of the format:
"1234567.z3.abcdef-gh.12"
I have gotten it to:
"1234567" "z3" "abcdef-gh" "12"
by use of the strsplit function.
This leaves me with each element of "string.list" having a split stri
How about union() ?
> a <- as.character(c("a", "b", "c", "d", "e"))
> b <- as.character(c("d", "a", "c", "e", "f", "b"))
>
> union(a,b)
[1] "a" "b" "c" "d" "e" "f"
HTH,
Jorge
On Sun, Jan 31, 2010 at 10:31 PM, stephen sefick <> wrote:
> a <- as.character(c("a", "b", "c", "d", "e"))
> b <- as.cha
a <- as.character(c("a", "b", "c", "d", "e"))
b <- as.character(c("d", "a", "c", "e", "f", "b"))
How would I get a list of only the unique values of these two
character vectors. I would like the output a b c d e f there is no
reason to have these in order. I am looking at to character vectors
of
m <- c(1,4,2,3,7,5)
S <- "which(m==4)"
P <- parse(text=S)
R <- eval(P)
R
Before you do this, see fortune(106)
> fortune(106)
If the answer is parse() you should usually rethink the question.
-- Thomas Lumley
R-help (February 2005)
On Wed, Jan 27, 2010 at 8:59 AM, Joe Trubisz wrote:
> He
On 28/01/2010, at 2:59 AM, Joe Trubisz wrote:
Hello...
In other languages (e.g. php, perl), you have the ability to create a
valid string and execute the string to get the result. For example (in
pseudo-R):
S<-"which(m==4)"
R<-exec(S)
I know this does not work, but was wondering if there was
Hello...
In other languages (e.g. php, perl), you have the ability to create a
valid string and execute the string to get the result. For example (in
pseudo-R):
S<-"which(m==4)"
R<-exec(S)
I know this does not work, but was wondering if there was an
equivalent mechanism that I cannot fin
Maybe I don't understand the question. I can think of four ways to
count, none of which give me 7:
a <- "Hello World"
b <- "Hello Peter"
#counting duplicates and the space:
sa <- strsplit(a, split="")[[1]]
sb <- strsplit(b, split="")[[1]]
length(which(sb %in% sa == TRUE))
#counting the space but
Laetitia,
One approach:
lettermatch <- function(stringA, stringB) {
sum(unique(unlist(strsplit(stringA, ""))) %in%
unique(unlist(strsplit(stringB, ""
}
lettermatch("Hello World","Hello Peter")
yields 6, as the l is only singly counted.
This treats uppercase and lowercase as different
On 1/9/10, Laetitia Schmid wrote:
> Does anybody know a string function that would calculate how many characters
> two strings share? I.e. ("Hello World","Hello Peter") would be 7.
>
Perhaps package ‘stringr’ has something related?
Liviu
__
R-help@r-p
Hi!
Does anybody know a string function that would calculate how many
characters two strings share? I.e. ("Hello World","Hello Peter") would
be 7.
Thanks.
Laetitia
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PL
Knut Krueger wrote:
Will this do?
temp <- paste("m", 1:3, sep="",collapse=",")
Unfortunately not, because I explained the example not detailed enough.
The string could have different Items, like November, December, Monday,
Tuesday, Daylight and so on
Therefore I must count the Items of t
On Wed, Dec 23, 2009 at 11:21 AM, Knut Krueger wrote:
> Hi to all
>
> I need a string like
> temp <- paste("m1","m2","m3",sep=",")
> But i must know how many items are in the string,afterwards
> the other option would be to use a vector
> temp <- c("m1","m2","m3")
> No problem to get the count of
Hi
r-help-boun...@r-project.org napsal dne 23.12.2009 12:08:02:
> Jim Lemon schrieb:
> >
> > Not as easy as I thought it would be, but:
> >
> > mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
> > do.call("paste",c(mlist,sep=","))
> >
>
> Hi Jim,
> yes it works :-)
>
> temp <- c("November",
Hi Baptiste,
Isn't paste doing exactly this?
yes indeed - surprising
temp <- c("November", "December","Monday","Tuesday")
paste(temp, collapse=",")
paste(temp, sep=",") I tried to use sep :-(
Arguments
|...| one or more *R* objects, to be converted to character vectors.
|sep|
On 23-Dec-09 11:40:12, baptiste auguie wrote:
> Isn't paste doing exactly this?
>
> temp <- c("November", "December","Monday","Tuesday")
> paste(temp, collapse=",")
># "November,December,Monday,Tuesday"
>
> HTH,
> baptiste
Yes, spot-on! I got involved in the confusion resulting from
the use of "
Isn't paste doing exactly this?
temp <- c("November", "December","Monday","Tuesday")
paste(temp, collapse=",")
# "November,December,Monday,Tuesday"
HTH,
baptiste
2009/12/23 Ted Harding :
> On 23-Dec-09 11:08:02, Knut Krueger wrote:
>> Jim Lemon schrieb:
>>> Not as easy as I thought it would be
101 - 200 of 243 matches
Mail list logo