Displaying 12 results from an estimated 12 matches for "phaebz".
Did you mean:
phab
2012 Apr 05
3
Apply function to every 'nth' element of a vector
Dear R users,
how do I e.g. square each second element of a vector with an even
number of elements? Or more generally to apply a function to every
'nth' element of a vector. I looked into the apply functions, but
found no hint.
For example:
v <- c(1, 2, 3, 4)
mysquare <- function (x) { return (x*x) }
w <- applyfun(v, mysquare, 2)
then w should be c(1, 4, 3, 16)
Thanks for
2011 Mar 24
5
subset and as.POSIXct / as.POSIXlt oddness
Dear R users,
Given this data:
x <- seq(1,100,1)
dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00")
dfx <- data.frame(dx)
Now to play around for example:
subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00"))
Ok. Now for some reason I want to extract the datapoints between hours
10:00:00 and 14:00:00, so I thought well:
subset(dfx, dx >
2012 Mar 25
2
avoiding for loops
I have data that looks like this:
> df1
group id
1 red A
2 red B
3 red C
4 blue D
5 blue E
6 blue F
I want a list of the groups containing vectors with the ids. I am
avoiding subset(), as it is
only recommended for interactive use. Here's what I have so far:
df1 <- data.frame(group=c("red", "red", "red", "blue",
2011 Mar 08
0
HoltWinters forecasting method
Dear All,
I was wondering why the forecast for an additive HoltWinters model is given
by Yhat[t+h] = a[t] + h * b[t] + s[t + 1 + (h - 1) mod p].
I am a student and new to time series analysis and forecasting. That said, I
considered t = 13 and h = 1: Yhat[13+1] = a[13] + b[13] + s[13 + 1]
It seems odd that to predict Yhat[14], you would need a s[14] which in turn
depends on Y[14], given that
2011 Apr 29
1
Specify custom par(mfrow()) layout for defined plot()
Dear R Users,
I am doing stats::decompose() on 4 different time series. When I issue
csdA <- decompose(tsA)
plot(csdA)
I get a summary plot for observed, trend, seasonal and random components
of decomposed time series tsA. As I understand it, the object returned
by decompose() has it's own plot method where mfrow(4,1) etc. is
defined. Now suppose I wanted to wrap those mfrow(4,1) into
2011 Feb 23
1
lattice.wireframe missing wireframe
Hello Everyone,
I am using R ver. 2.10.1 (2009-12-14). I installed lattice today via install.packages.
I am doing this minimal example:
M = read.csv("/path/to/csv")
cloud(x ~ y * z, data = M)
this correctly gives me a scatterplot of the csv data which has 3 columns. Every column contains 1800 numeric 0 < values < 1300
when I want to plot the corresponding wireframe via
2011 Mar 24
1
debug R device plot
Hi there,
I was doing great with R, ggplot and tikzDevice, when suddenly it stopped
working.
I can do a plot just fine on the R online graphics device. I can also open a
tikzdevice via tikz(). However, the plot (both ggplot and R graphics plot)
call leads to the error:
"createLockFile(lockname): cannot create lock file"
I see that this is related to my OS, namely Ubuntu 10.04. I
2012 Apr 02
0
R2wd: Insert MS Word field
Hello Everyone,
the basic idea is to generate an initial (MS Word) report by R (plots,
tables and outline structure), pass this document around so everyone
can add / change content (except plots and tables) and later to be
able to update the R plot / table logic and update the already
modified word file.
I was toying around with the R2wd [1] package to test whether it is a
viable way of writing
2012 Sep 06
3
unique with tolerance
Dear R Users and Developers,
I am trying to do the equivalent of
v <- c(1,2,3,3,2,1,)
vu <- unique(v)
for a vector such as
v2 <- c(1.02, 2.03, 1.00, 3.04, 3.06)
vut <- ...
As indicated in the subject, we need approximately unique values with a defined
tolerance, i.e. for the v2 vector the resulting vut vector using a tolerance of
.1 should return e.g.
[1] 1.02 2.03 3.06
Also,
2013 Mar 01
1
.Call interface: Use R SEXP as C mutable *char
Dear R Developers,
DISCLAIMER: I am new to package development in R and new to this list.
I am trying to do something along the lines of:
SEXP test_fun (SEXP filename) {
const char *inputfile = translateChar(STRING_ELT(filename, 0));
int abc = some_function(inputfile);
...
}
The code compiles fine, but I get a warning:
"passing argument of 'some_function' discards qualifiers
2011 Mar 18
1
akima::interp "scales of x and y are too dissimilar"
Dear R users,
I want to do a fitted.contour plot of selected columns of a dataframe M with
M$AM and M$Irradiance as x and y axes respectively. The level of the contour
shall be determined by M$PR.
Some words on my data first. Dataframe M looks like:
head(M$Irradiance)
[1] 293 350 412 419 477 509
head(M$AM)
[1] 2.407 2.161 1.964 1.805 1.673 1.563
head(M$PR)
[1] 70.102 72.600 75.097 80.167
2011 Apr 19
2
Data frame with 3 columns to matrix
Dear R Users,
Lets assume I have this data frame:
x y z
1 1.00 5 0.5
2 1.02 5 0.7
3 1.04 7 0.1
4 1.06 9 0.4
x and y columns are sorted and the values not necessarily integers. z
values are not sorted. Now I would like to create a matrix out of this
with x as first column values and y as first row values. Matrix element
a_11 shall be left NA. The a_ij should have the z value for the