It can seem like it is hung when you default to saving your workspace on
close and you have a very large workspace in memory relative to your hard
drive write speed. Are you sure it isn't that?
On Sun, Jul 7, 2019 at 1:18 PM Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:
> Thank you.
ifelse is vectorized.
On Wed, Dec 13, 2017 at 7:31 AM, Jinsong Zhao wrote:
> Hi there,
>
> I don't know why the following codes are return different results.
>
> > ifelse(3 > 2, 1:3, length(1:3))
> [1] 1
> > if (3 > 2) 1:3 else length(1:3)
> [1] 1 2 3
>
> Any hints?
>
> Best,
> Jinsong
>
> _
I TAd a course in R computing and the first thing I told students was
"inspect. inspect. inspect."
d1 <- fromJSON('
http://api.openweathermap.org/data/2.5/group?id=524901,703448,2643743&units=metric&appid=ec0313a918fa729d4372555ada5fb1f8
')
names(d1)
str(d1)
d1
d1$list
your_data = d1$list
On Fri,
As a rule never rbind in a loop. It has O(n^2) run time because the rbind
itself can be O(n) (where n is the number of data.frames). Instead either
put them all into a list with lapply or vector("list", length=) and then
datatable::rbindlist, do.call(rbind, thelist) or use the equivalent from
dply
library(data.table)
setDT(df)
setkeyv(df, c("Subject", "dates"))
unique(df) #gets what you want.
On Mon, Nov 14, 2016 at 11:38 PM, Jim Lemon wrote:
> Hi Farnoosh,
> Try this:
>
> for(id in unique(df$Subject)) {
> whichsub<-df$Subject==id
> if(exists("newdf"))
> newdf<-rbind(newdf,df[whichsu
Hi,
Didn't bother to run the code because someone else said it might do what
you intended, and also your problem description was complete unto itself.
The issue is that R copies on change. You are thinking like you have a
reference, which you do not. That is not very R like in style, but it
cer
Try changing:
v_list_of_files[v_file]
to:
v_list_of_files[[v_file]]
Also are you sure you are not generating warnings? For example,
l = list()
l["iris"] = iris;
Also, you can change it to lapply(v_files, function(v_file){...})
Have a good one,
Jeremiah
On Wed, Sep 28, 2016 at 8:02 AM, wrote:
There is also this syntax for adding variables
df[, "var5"] = 1:10
and the syntax sugar for row-oriented storage:
df[1:5,]
On Wed, Sep 14, 2016 at 11:40 AM, jeremiah rounds
wrote:
> "If you want to add variable to data.frame you have to use attach, detach.
> Right?"
&
"If you want to add variable to data.frame you have to use attach, detach.
Right?"
Not quite. Use it like a list to add a variable to a data.frame
e.g.
df = list()
df$var1 = 1:10
df = as.data.frame(df)
df$var2 = 1:10
df[["var3"]] = 1:10
df
df = as.list(df)
df$var4 = 1:10
as.data.frame(df)
Ironi
Not sure what the issue is with the provided code but note:
library(lubridate)
lubridate::dmy_hm("Thu, 25 Aug 2016 6:34 PM")
[1] "2016-08-25 18:34:00 UTC"
Though if you go that route: set the TZ because on the timestamp it is
ambiguous.
On Sun, Sep 11, 2016 at 10:57 PM, Chris Evans wrote:
>
Building on Don's example here is something that looks a lot like what I do
every day:
Sys.setenv(TZ="UTC")
mydf <- data.frame(t1=c('2011-12-31-22-30', '2011-12-31-23-30'))
library(lubridate)
mydf$timestamp = lubridate::ymd_hm(mydf$t1)
mydf$t2 = mydf$timestamp - period(minute=30)
On Wed, Aug 31,
oh I forgot I renamed sm.
dt = sm
library(data.table)
setDT(dt)
op = function(s){
mean0 = apply(s, 1, mean)
ret = s[which.max(mean0)]
ret$mean = mean0
ret
}
max_row = dt[, op(.SD), by = "Gene"]
Thanks,
Jeremiah
On Thu, Aug 18, 2016 at 3:21 PM, jeremiah rounds
wrote:
> libra
library(data.table)
setDT(dt)
op = function(s){
mean0 = apply(s, 1, mean)
ret = s[which.max(mean0)]
ret$mean = mean0
ret
}
max_row = dt[, op(.SD), by = "Gene"]
Thanks,
Jeremiah
On Thu, Aug 18, 2016 at 2:33 PM, Adrian Johnson
wrote:
> Hi Group,
> I have a data matrix sm (dput code given below).
Something like:
d = data.frame(score = sample(1:10, 100, replace=TRUE))
d$score_t = "low"
d$score_t[d$score > 3] = "medium"
d$score_t[d$score >7 ] = "high"
d$score_t = factor(d$score_t, levels = c("low", "medium", "high"),
ordered=TRUE) #set ordered = FALSE for dummy variables
X = model.matrix(
Basically using Reduce as an lapply in that example, but I think that was
caused by how people started talking about things in the first place =) But
the point is the accumulator can be anything as far as I can tell.
On Thu, Jul 28, 2016 at 12:14 PM, jeremiah rounds
wrote:
> Re:
> &qu
Re:
"What I'm trying to
work out is how to have the accumulator in Reduce not be the same type as
the elements of the vector/list being reduced - ideally it could be an S3
instance, list, vector, or data frame."
Pretty sure that is not true. See code that follows. I would never solve
this task i
Correction to my code. I created a "doc" variable because I was thinking of
doing something faster, but I never did the change. grep needed to work on
the original source "dat" to be used for counting.
Fixed:
combs = structure(list(V1 = c(65L, 77L, 55L, 23L, 34L), V2 = c(23L, 34L,
34L, 77L, 65L
If I understood the request this is the same programming task as counting
words in a document and counting character sequences in a string or
matching bytes in byte arrays (though you don't want to go down that far)
You can do something like what follows. There are also vectorized greps
in strin
by.column = FALSE),
>> roll_lm = roll_lm(coredata(z[, 1, drop = F]), coredata(z[, 2, drop =
>> F]), 4,
>> center = FALSE))[1:4]
>>
>>
>> test replications elapsed relative
>> 1 fastLm 1000.221.000
>> 2 lm
, 2, drop =
> F]), 4,
> center = FALSE))[1:4]
>
>
> test replications elapsed relative
> 1 fastLm 1000.221.000
> 2 lm 1000.723.273
> 3 roll_lm 1000.642.909
>
> On Thu, Jul 21, 2016 at 3:45 PM, jeremiah
ix multiplications may not be. This should be kept in mind when writing
> your own Rcpp code for plugging it into RcppRoll.
>
> But I haven't check what the roll package does and how reliable that is...
>
> hth,
> Z
>
>
> On Thu, 21 Jul 2016, jeremiah rounds wrote:
>
&
Hi,
A not unusual task is performing a multiple regression in a rolling window
on a time-series.A standard piece of advice for doing in R is something
like the code that follows at the end of the email. I am currently using
an "embed" variant of that code and that piece of advice is out there
Your error message is because "if" wants a single value and you are giving it a
vector.
Typically you want to use functions "all" or any" to correct this error message
(look them up ?all ?any) and eg if(any(is.na(...))) But in this case to
accomplish the task you're after I don't even t
time it is absolute essential to use the
right data structure for the job.
Hope this is of assistance,
Jeremiah Rounds
> Date: Mon, 8 Jun 2009 15:45:40 +
> From: amitrh...@yahoo.co.uk
> To: r-help@r-project.org
> Subject: [R] help to speed up loops in r
>
>
>
Here is what I got for script through your third question:
set.seed(1)
x1 = rbinom(200,1,.5)
x2 = rbinom(200,1,.5)
differ = x1 != x2
differ.indexes = (1:length(x1))[differ == TRUE]
#you were unclear if you want to round up or round down on odd index of
differ.indexes
n = floor( length(d
For school work I use png. Png files are more efficient size/quality wise
than png, and also lend themselves to more generic application/viewing than ps.
In R this typically takes the form of:
setwd(...) #set working directory before starting any work typically at the top
of scripts
at just
returning the results of your more complicated clustering in that call without
actually doing the calculations.
Jeremiah Rounds
Graduate Student
Utah State University
> > __> R-help@r-project.org
> > mailing list> https://stat.et
> Date: Wed, 14 May 2008 15:18:32 -0400
> From: [EMAIL PROTECTED]
> To: r-help@r-project.org
> Subject: [R] Newbie question about vector matrix multiplication
>
> Hello All,
>
> I have a covariance matrix, generated by read.table, and cov:
>
> co<-cov(read.table("c:/r.x"))
>
> X Y Z
>
> X 0.001
> Date: Wed, 14 May 2008 12:06:39 -0400
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: [R] strip white in character strings
>
> Dear all,
>
> I have several datasets and I want to generate pdf plots from them.
> I also want to generate automatically the names of the files. They ar
what you wanted to happen happened just fine. So the question you might
ask yourself is: what is different? And that leads to asking what class is the
SNP1 object? If you can coerce into an array you probably can avoid the issue.
Jeremiah Rounds
Graduate Student
30 matches
Mail list logo