Ideally you'd have the next two items available:
- tests that ensure that your code carries out what it should and as it should.
- a coverage analysis tool that reports what parts of your code have
been and have not been executed by your tests above.
Neither of those are mandatory though, but they
Some hints:
list.files() will return the list of files in a directory
readLines() will allow you to load text files as vectors of lines
strsplit() will allow you to break lines into words
c(x,y) concatenates vectors x and y ; x <- c(x,y) appends vector y to x
unique() will allow you to get rid of r
gfcoeffs <- function(s, n) {
t <- seq(-n,n,1) ## assuming 2*n+1 taps
return ( exp(-(t^2/(2*s^2)))/sqrt(2*pi*s^2) )
}
2011/6/29 Martin Wilkes :
> I want to filter my time series with a low-pass filter using a Gaussian
> smoothing function defined as:
>
> w(t) = (2πσ^2)^0.5 exp(-t^2/2σ^2)
>
> I
Ops!
Thank-you Duncan for clarifying the 2 vs. 3 colon difference and a
couple of other things.
Working like a charm now.
Cheers,
jcb!
> If you are using ::: (three colons), then you may be looking into the
> unexported functions in log4r. The only normal way to see unexported
> functions is to u
Dear all,
It looks like I do not grasp the concept of masked functions enough as
to solve this trivial problem.
The code that replicates the problem (a source code tree that realizes
a R package actually) is under github so one can call it clone it
easily from the command line (though more experien
Dear all,
What is the simplest way of producing a bar graph using ggplot but
avoiding calling qplot?
That is, given:
d <- data.frame(x=seq(1,5), y=seq(1,5))
Why does the following line return an error?
ggplot(d, aes(x=x, y=y)) + stat_identity() + geom_bar(bindwidth=1)
Thanks in advance,
jcb!
__
# The code demonstrating the final version I am going to use is as follows
rm(list=ls()) # Beware of this one so it doesn't spoil your workspace
N <- 100
M <- 2
x <- matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N)
y <- matrix(c(1,-2,-2,1), ncol=M, nrow=M)
z <- data.frame(x %*% y)
colnames(z) <-
Kenn,
I find your solution more elegant.
2011/4/8 Kenn Konstabel :
> 2011/4/8 Juan Carlos Borrás :
>> #Use the indexes of S in a sapply function.
>>
>> N <- 10
>> S <- sample(c(0,1), size=N, replace=TRUE)
>> v1 <- sapply(c(1:N-1), function(i) S[i]&
#Use the indexes of S in a sapply function.
N <- 10
S <- sample(c(0,1), size=N, replace=TRUE)
v1 <- sapply(c(1:N-1), function(i) S[i]&&S[i+1])
# Then
v2 <- (P > m)
# And I guess you can fill up the rest. Beware of the boundary
condition (the NA in v1)
Cheers,
jcb!
___
http:/
"coln"
#end code
What I want is to know whether I can customize the column name of the
result of the transform() call.
Your hint is fantastic, thanks there, but I keep getting into that
particular pattern of computation over and over and I wonder if it's
possible to skip a column c
Hi all,
I am whitening my data:
# code begins
N <- 300
M <- 2
x <- matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N)
y <- matrix(c(1,-2,-2,1), ncol=M, nrow=M)
z <- data.frame(x %*% y)
colnames(z) <- c('x','y')
par(mfrow=c(1,3))
plot(z, pch=5, col="blue")
whiten <- function(x) { (x-mean(x))/sd(x) }
Dear all,
I'm deep into Chambers' SoDA and R-exts.html but I can't find all
answers. The thing is that I would like to run my unit tests right
after a package installation.
That is while the command "R CMD check " runs all files
named /tests/*.R (so unit tests can be placed there) I
wonder if it is
12 matches
Mail list logo