Not a new approach, but some benchmark data (the perl=TRUE speeds up Jim's
suggestion):
x - c('18x.6','12x.9','302x.3')
y - rep(x,10)
system.time(temp - unlist(lapply(strsplit(y,.,fixed=TRUE),function(x)
x[1])))
user system elapsed
1.203 0.018 1.222
system.time(temp2 -
df$a[is.infinite(df$a) | is.nan(df$a) ] - NA
df
a
1 NA
2 NA
3 NA
4 1
5 2
6 3
On 5/26/11 3:18 PM, Albert-Jan Roskam fo...@yahoo.com wrote:
Hi,
I want to recode all Inf and NaN values to NA, but I;m surprised to see
the
result of the following code. Could anybody enlighten me about
Everything looks OK. Does this help?
test -
data.frame(alpha=as.factor(c(A,A,B,B,C)),number=c(1,2,3,4,5))
mode(test)
[1] list
class(test)
[1] data.frame
sapply(test, mode)
alphanumber
numeric numeric
sapply(test, class)
alphanumber
factor numeric
On 5/25/11 10:42 AM,
Gregory: Would setting limit.list - NULL at the start do the trick? See
example below:
Analogue of your example:
lower - 0
upper - 0
limit.list-data.frame(lower,upper)
for(i in 1:12) {
some.data - rnorm(2)
lower - min(some.data)
upper - max(some.data)
one.month - data.frame(lower,
24.5178851225 28.248711925
-Original Message-
From: Ian Gow [mailto:iand...@gmail.com]
Sent: Tuesday, May 24, 2011 8:58 AM
To: Graves, Gregory; Nungesser, Martha; r-help@r-project.org
Cc: Kemp, Susan K SAJ; patrick_pi...@fws.gov
Subject: Re: [R] how to eliminate first row in datafile created
(DROPBOX_PATH)
to access the path. It seems from looking at forums for Dropbox that there
is no easily accessed environment variable that Dropbox sets for the path
to the Dropbox folder.
--
Ian Gow
Accounting Information and Management
Kellogg School of Management
Northwestern University
2001 Sheridan
Geoffrey:
There may be something for this in one of the packages dealing with dates.
If not, here's one (incomplete) idea, based on something I used for a similar
issue a little while ago. Essentially, make a data frame that ranks each
weekday over a period in ascending order. This data frame
Hi:
Reordering the dimensions, then doing a vectorized addition, then reordering
(back) again is faster, it seems.
m - 20; n - 30; p - 40; q - 30
a - NA
length(a) - m * n * p * q
dim(a) - c(m, n, p, q)
x - 1:n
a[1:m,,1:p,1:q] - 0
b - a
# Approach 1
system.time({
+ c -
Hi:
This is a bit of a kluge, but works for your test case:
df2[,setdiff(names(df1),names(df2))] - NA
df1[,setdiff(names(df2),names(df1))] - NA
df3 - rbind(df1,df2)
df3
a b c
1 A B NA
2 A B NA
3 NA b c
4 NA b c
-Ian
On 5/15/11 7:41 PM, Jonathan Flowers jonathanmflow...@gmail.com wrote:
That approach relies on df1 and df2 not having overlapping values in b.
Slight variation in df2 gives different results:
df1 - data.frame(a=c(A,A),b=c(B,B))
df2 - data.frame(b=c(B,B),c=c(c,c))
merge(df1,df2,all=TRUE)
b a c
1 B A c
2 B A c
3 B A c
4 B A c
On 5/15/11 11:19 PM, William Dunlap
If I assume that the third column in data.frame.2 is named val then in
SQL terms it _seems_ you want
SELECT a.time, b.val FROM data.frame.1 AS a LEFT JOIN data.frame.2 AS b ON
a.time BETWEEN b.start AND b.end;
Not sure how to do that elegantly using R subsetting/merge, but you might
try a
3
7 7003
8 8005
9 9005
10 1000NA
@David I don't know what you mean by 2 merges,
René
Zitat von David Winsemius dwinsem...@comcast.net:
On May 14, 2011, at 9:16 AM, Ian Gow wrote:
If I assume that the third column in data.frame.2 is named val then in
SQL
12 matches
Mail list logo