Hi,
I have written a function "harvest" and I would like to run the function for
each value in a vector c(1:1000). The function returns 4 list objects
(obj_1, obj_3, obj_3, obj_4) using the following code at the end of the
function: return(list(obj_1 = obj_1, obj_2 = obj_2, obj_3 = obj_3, obj_4 =
Thanks Arun, this helps a lot!
--
View this message in context:
http://r.789695.n4.nabble.com/Reduce-paste-x-question-tp4648151p4648228.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.et
I should have been more specific:
y <- list()
a <- c("A", "K")
b <- c("B", "L")
c <- c("C", "M")
d <- c("D", "N")
e <- c("E", "O")
y[[1]] <- a
y[[2]] <- b
y[[3]] <- c
y[[4]] <- d
y[[5]] <- e
y
[[1]]
[1] "A" "K"
[[2]]
[1] "B" "L"
[[3]]
[1] "C" "M"
[[4]]
[1] "D" "N"
[[5]]
[1] "E" "O"
How do I
I have a question about the Reduce function:
x <- list()
x[[1]] <- LETTERS[1:5]
x[[2]] <- LETTERS[11:15]
Reduce(paste, x)
[1] "A K" "B L" "C M" "D N" "E O"
How do I get this?:
[1] "A" "K"
[2] "B" "L"
[3] "C" "M"
[4] "D" "N"
[5] "E" "O"
Thanks for your help!
--
View this message in context
Thanks Gabor for your invaluable help! I learned a lot.
--
View this message in context:
http://r.789695.n4.nabble.com/strapply-and-characters-adjacent-to-the-matched-pattern-tp4637673p4637939.html
Sent from the R help mailing list archive at Nabble.com.
___
, 5th and 6th elements
strapply(c("abc", "ab", "abdef", "defc", "def", " def "),
"(def|ab)($|[^[[:alpha:]])")
The outcome should look like this:
[[1]]
NULL
[[2]]
[1] "ab"
[[3]]
NULL
[[4]]
NULL
[[5]]
[1] "def"
Hi,
In the example below, one of the searched patterns "SE" is matched in the
word "second". I would like to ignore all matches in which the character
following the match is one of [:alpha:]. How do I do this without removing
the "ignore.case = T" argument of the strapply function? Thank you very
Hi,
I have a minor follow-up question:
In the example below, "ann" and "nn" in the third element of text are
matched. I would like to ignore all matches in which the character following
the match is one of [:alpha:]. How do I do this without removing the
"ignore.case = TRUE" argument of the strap
Hi,
I have the following sequence:
in <- c(0, 0, 0, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0, 2, 0, 0, 2)
>From this sequence I would like to get to the following sequence:
out <- c(0, 0, 0, 3, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1
Thanks! That worked like a charm.
Math
Gabor Grothendieck wrote
>
> On Fri, Jul 13, 2012 at 1:41 PM, mdvaan <mathijsdevaan@> wrote:
>> Here's some data (which should give you the error messages):
>>
>> # read in data
>> data <- read.csv
rma
Holdings")
# match
strapplyc(text, data1)
strapplyc(text, data2a)
strapplyc(text, data2b)
Thanks in advance!
Math
Gabor Grothendieck wrote
>
> On Fri, Jul 13, 2012 at 9:40 AM, mdvaan <mathijsdevaan@> wrote:
>> Thanks, I see that it is working i
expression pattern: parentheses () not
balanced.
batch[[l]] is similar to your "re" string except that there is a larger
variety of characters. I haven't been able to figure out which characters
are causing trouble here. Any thoughts?
Thank you very much.
Math
Gabor Grothendie
is to be able to diagnose and fix it?
>
> Also, note that your "working" example simply overwrites
> array$chunk1[j] four times.
>
> Sarah
>
> On Fri, Jul 6, 2012 at 10:45 AM, mdvaan <mathijsdevaan@> wrote:
>> Hi,
>>
>> I am using R's grep fu
Hi,
I am using R's grep function to find patterns in vectors of strings. The
number of patterns I would like to match is 7,700 (of different sizes). I
noticed that I get an error message when I do the following:
data <- array()
for (j in 1:length(x))
{
array[j] <- length(grep(paste(patterns[1:77
Thanks, all solutions worked like a charm.
Math
arun kirshna wrote
>
> - Forwarded Message -
> From: arun <smartpink111@>
> To: mdvaan <mathijsdevaan@>
> Cc: R help <r-help@>
> Sent: Thursday, June 28, 2012 1:44 AM
> Subject: Re: [R] Extract up
t <- "TheWeatherIsVeryNice"
How do I extract the upper case letters? - TWIVN
Thanks!
--
View this message in context:
http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html
Sent from the R help mailing list archive at Nabble.com.
__
AM, Duncan Temple Lang wrote:
>> To just enable cookies and their management, use the cookiefile
>> option, e.g.
>>
>> txt = getURLContent(url, cookiefile = "")
>>
>> Then you can pass this to readHTMLTable(), best done as
>>
>> content = readHTMLT
t; The function readHTMLTable() doesn't use RCurl and doesn't
>> handle cookies.
>>
>>D.
>>
>> On 6/7/12 7:33 AM, mdvaan wrote:
>>> Hi,
>>>
>>> I am trying to access a website and read its content. The website is a
>>>
Hi,
I am trying to access a website and read its content. The website is a
restricted access website that I access through a proxy server (which
therefore requires me to enable cookies). I have problems in allowing Rcurl
to receive and send cookies.
The following lines give me:
library(RCurl)
l
with
> /Software/Embedded Controllers) .OO#. .OO#.
> rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> mdvaan <mathijsdevaan@> wrote:
>
>>Thanks! That works lik
Thanks! That works like a charm, but I am not sure if I fully understand the
syntax. I looked at the gsub page but still couldn't figure it out. What
does the pattern part (",{0,1} Inc[.]{0,1}") do? What do the 0 and 1 within
the curly brackets refer to? Also, what if, for example, I would want to
Hi,
I have a vector like this:
DF <- c("Aetna, Inc.", "Alexander's Inc.", "Allegheny Energy, Inc")
For each element in the vector I would like to remove the "incorporated"
info, so that my vector looks like this:
DF <- c("Aetna", "Alexander's", "Allegheny Energy")
That means that I have to str
Hi,
The following returns an error message. How do I evaluate (TRUE or FALSE)
the function?
require(XML)
readHTMLTable("http://www.sec.gov/Archives/edgar/data/2969/95012399010952/950123-99-010952.txt";)
Thanks in advance!
Math
--
View this message in context:
http://r.789695.n4.nabble
Hello,
I am using the plot.igraph function in the igraph package to plot a network.
How do I keep vertices from overlapping? One option would be to pass an
argument that restricts vertices to occupy the same coordinates given their
size. A second option would be to increase the area of the plot (a
Hello,
The Scopus bibliographic database allows one to manually download batches of
2000 publications. The data is rich but does not provide one with a field
containing the author id. However, author id's can be retrieved through the
hyperlinks on the Scopus website. I have two questions:
1. My i
Hi,
This is probably an easy one, but I am new to ggplot2 and cannot find an
answer online.
I am bar plotting values of 10 groups. These values are all within a 90-100
range, so I would like leave out the area of the bars below 90. If I say
"graph + scale_y_continuous(limit=c(90, 100))", it does
Hi Jean and Peter,
Thanks for the help. Both options are indeed faster than my initial
procedure.
Best,
Mathijs
--
View this message in context:
http://r.789695.n4.nabble.com/Merging-fully-overlapping-groups-tp4470999p4473013.html
Sent from the R help mailing list archive at Nabble.com.
_
Hi,
I have data on individuals (B) who participated in events (A). If ALL
participants in an event are a subset of the participants in another event I
would like to remove the smaller event and if the participants in one event
are exactly similar to the participants in another event I would like t
Thanks. That worked great!
--
View this message in context:
http://r.789695.n4.nabble.com/Select-elements-from-text-tp4323947p4327711.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.c
Thanks for the quick response. I get the latter part, but reading the text
from MS word into R is problematic. I am able to read in (scan) all unique
elements (following sep=" ") from the text, but unable to past everything
together again. Any id on how to solve this? It looks like this now:
text
Hi,
I have a series of MS word files and each file contains plain text. From
these texts I would like to extract only those elements (read: words) that
are between square brackets. Example of a text:
Most fundamentally, it has led to an effort to clarify the organizational
form concept. According
Anyone any idea on how to tackle this problem? Thanks a lot!
--
View this message in context:
http://r.789695.n4.nabble.com/Selecting-and-multiplying-tp3784901p3793908.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.or
Thanks David and Jorge for your comments!
--
View this message in context:
http://r.789695.n4.nabble.com/Selections-in-lists-tp3768562p3784816.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://st
Hi,
I have created two objects: object c contains yearly "distances" between
cases and object g contains yearly interactions between cases. For each case
and every year I would like to calculate the following value:
Vit = sum(Dabt * Iait * Ibit)
Where Vit is the value of case i in year t, Dabt i
Hi,
I have produced a list g and I would like to reduce the amount of
information contained in each object in g.
For each matrix I would like to keep the values where the column name equals
g[year][[1]][[x]] and the row names equals g[year][[1]][[-x]]. So in
g$`1999`$`8029`, year = 1999 and x = 8
Thanks Jean, changing c[[t]] to c[[year]] solved the issue.
Math
Jean V Adams wrote:
>
>> Re: [R] Selecting cases from matrices stored in lists
>> mdvaan
>> to:
>> r-help
>> 08/22/2011 09:46 AM
>>
>> Jean V Adams wrote:
>> >
&
Jean V Adams wrote:
>
>> [R] Selecting cases from matrices stored in lists
>> mdvaan
>> to:
>> r-help
>> 08/22/2011 07:24 AM
>>
>> Hi,
>>
>> I have two lists (c and h - see below) containing matrices with similar
>> cases but
Hi,
I have two lists (c and h - see below) containing matrices with similar
cases but different values. I want to split these matrices into multiple
matrices based on the values in h. So, I did the following:
years<-c(1997:1999)
for (t in 1:length(years))
{
year=as.character(ye
t;-sapply(colnames(h[[year]]), function(var)
h[[year]][h[[year]][,var]>0, h[[year]][var,]>0])
}
David Winsemius wrote:
>
> On Aug 15, 2011, at 6:09 AM, mdvaan wrote:
>
>> Hi,
>>
>> I have a question concerning the selection of data. Let's say th
Hi,
I have a question concerning the selection of data. Let's say that given
list h created below, I would like to select a section of the 1999 matrix.
For a case (rownames and colnames) I would like to select the cells that
have a value > 0. So for case 8025
8025 8026 8027
802511
#Hi list,
#From the code below I get two list objects (n$values and n$vectors):
dat <- matrix(1:9,3)
n<-eigen(dat)
n
# How do I add another object to n that replicates n$vectors and is called
n$vectors$test?
# Thanks a lot!
--
View this message in context:
http://r.789695.n4.nabble.com/Addi
I am still thinking about this problem. The solution could look something
like this (it's net yet working):
k<-lapply(h, function (x) x*0) # I keep the same format as h, but set all
values to 0
years<-c(1997:1999) # I define the years
for (t in 1:length(years))
{
year = as.characte
Hi,
I am trying to use the objects from the list below to create more objects.
For each year in h I am trying to create as many objects as there are B's
keeping only the values of B. Example for 1999:
$`1999`$`8025`
B
B 8025 8026 8027 8028 8029
802511100
8026
Hi,
I still haven't found a solution for this problem. Is there a way in which I
can slice the objects in c based on the info in h? Thanks a lot!
--
View this message in context:
http://r.789695.n4.nabble.com/Divide-matrix-into-multiple-smaller-matrices-tp3552399p3591868.html
Sent from the R hel
Thank you very much! I really liked the first solution, it worked great for
my larger dataset.
M
Gabor Grothendieck wrote:
>
> On Fri, Jun 3, 2011 at 8:11 AM, mdvaan <mathijsdev...@gmail.com>
> wrote:
>> Would it be possible to use the sqldf package and the ave functio
Would it be possible to use the sqldf package and the ave function to simply
run ave over a limited set? So something like:
DF = data.frame(read.table(textConnection(" A B
8025 1995
8026 1995
8029 1995
8026 1996
8025 1997
8026 1997
8025 1997
8027 1997
8026 1999
8027 1999
802
Hi list, based on the following data.frame I would like to create a variable
that indicates the number of occurrences of A in the 3 years prior to the
current year:
DF = data.frame(read.table(textConnection(" A B
8025 1995
8026 1995
8029 1995
8026 1996
8025 1997
8026 1997
8025 1997
8027
Hi list,
Using the script below, I have generated two lists (c and h) containing
yearly matrices. Now I would like to divide the matrices in c into multiple
matrices based on h. The number of matrices should be equal to:
length(unique(DF1$B))*length(h). So each unique value in DF1$B get's a
yearly
48 matches
Mail list logo