Displaying 20 results from an estimated 3000 matches similar to: "Apply function to every 'nth' element of a vector"
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",
2001 Mar 28
4
How to extract every nth element from a vector
R-helpers:
Is there a simple way to extract every nth element from a very long vector?
[The vector I want to sample from is an object returned by lowess(). It is
so long (11,628 pairs of elements) that it is causing non-R-related memory
problems elsewhere. I don't see a better way other than sampling the output
returned from lowess.]
Thanks in advance.
Barry Cooke
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 >
2011 Oct 21
2
plotting with a symbol on every nth point
Hi,
I would like to produce a plot with a symbol on every nth point in a time
series data, like the one in the following:
http://www.phon.ucl.ac.uk/home/yi/ProsodyPro/EnglishFocus.png
x <- seq(-100,1000,25)
plot(x,type="l")
Could someone help me out with the above example?
Thanks....
[[alternative HTML version deleted]]
2005 Oct 25
1
selecting every nth item in the data
I want to make a glm and then use predict. I have a fairly small sample
(4000 cases) and I want to train on 90% and test on 10% but I want to do
it in slices so I test on every 10th case and train on the others. Is
there some simple way to get these elements?
Stephen
--
21/10/2005
[[alternative HTML version deleted]]
2008 Feb 25
1
Plotting series marked with a symbol on every nth data point, preferably in ggplot...
Hello!
I am working with signals and a plot of several signals on the same
axes can get quite messy. With lines that are very fractured,
distinction by only the linestyle is not very clear. If I add symbols
to the plot however, there are so many symbols, that they overplot and
the whole plot is unreadable once again. I am looking for advice on
how to make a plot with continuous lines and symbols
2012 Dec 02
2
How to calculate mean of every nth time series data with zoo or xts ?
Hello,
I have 1-minute time series stock data and I'd like to calculate mean of every n-th candle data of m-days.
result = c(mean of 1th data, mean of 2nd data, ...)
mean of 1th data = (1th data of 2012-1-1 + 1th data of 2012-1-2 + 1th data of 2012-1-3) / 3
mean of 2nd data = (2nd data of 2012-1-1 + 2nd data of 2012-1-2 + 2nd data of 2012-1-3) / 3
...
Could you let me know the fastest
2009 Jul 07
3
Answering the nTh call ...
Curious to know if anyone's created something similar to the following,
if so and you'd care to share an AGI or dialplan, much appreciated.
I will be eventually write a script to answer the nTH call. (if I can't
find it (why reinvent wheels).
Looking to do some testing sending anywhere between 50-200 calls to a
machine. I'd like a Snom/Polycom/whatever to pick up after the nTh
2009 Mar 19
2
nth root
Hi,
Is there a function in R to calculate the nth root, similar to the
MATLAB function NTHROOT()?
Thanks,
Martin Biuw
[[alternative HTML version deleted]]
2005 Apr 29
1
problem with nth patch, counter parameter...I think
Hi all, I need some guidance to get my problem fixed. I believe there
is an issue with the ''nth'' patch from the patch-o-matic, which is
labeled as status ''works''.
I have tunnels back and forth across the internet, using ''nth'' to
balance packets between different public networks (over the tunnels).
I need to access some networks over two
2012 Jul 11
4
MODE , VARIANCE , NTH PERCENTAILE
Hi,
Here i have an matrix like this,
ABC PQR XYZ MNO
------ ------- ------ --------
3 6 7 15
2 12 24 15
20 5 1 2
25 50 15 35
i need to get the
"MODE" - for each column-wise
"VARIANCE" - for
2008 Apr 22
2
nth step transition matrices
Hello,
I have a question in regards to markov chains and transition
probabilities.
I am trying to figure out a way to calculate the "kth-step transition
matrix" of a given matrix.
Say for example I have a single step 2x2 matrix:
1 2
P= 1 .95 .05
2 .01. 99
If I were to convert this matrix to a 2-step transition probability
matrix I would get:
2005 Feb 02
2
Packet Level Load Balance inbound/outbound success with nth and route
First of all, I''d like to thank Andy Furniss for his direction and for
helping me get a working example up and running.
For the following set up to work, you will need a linux computer at
the ISP (server), a linux computer at the client location (client),
and some a public range of IP''s you plan to send down to your client.
(as this configuration involves patching the linux
2009 Aug 18
2
value of nth percentile
Dear All,
I have to get the value of say 90th percentile of precipitation time series.. The series is of daily precipitation value of 96 years, I have to to get 90the percentile value of daily precipitation each year. If you know the R code or command for this please let me know.
I would appreciate your early response.
Thanking you,
Sincerely,
Ajay.
2012 Jan 08
1
Difference across the Nth dimension of an array
I have a multidimensional array - in this case with 4 dimensions of x,y,z
and time. I'd like to take the time derivative of this matrix, i.e.
perform the diff operator along dimension number 4.
In Matlab, there is a simple option to specify which dimension the
difference is to be taken across., but I can't see this in R.
I realise I can use aperm to rotate my array so that time is in
2010 May 13
2
Adding name to nth row
Hello,
I have a data frame with many rows, and I want to create a column with
a name only at every 12th row, starting from 97 to 278.
Thanks in advance!
2007 Nov 01
1
List of Nth removed associated objects.
Given the following..
Foo has_many :bars
Bar has_many ::widgets
Widget has_many :gadgets
Gadget has_many :parts
All of the following are now possible...
@foo.bars
@bar.widgets
@part.gadget.widget.bar.foo
However, I can''t just do the opposite of that last one...
@foo.bars.widgets.gadgets.parts
and get a full list of every Part associated with @foo.
I know there''s several
2023 Mar 08
1
nth kludge
I see many are not thrilled with the concise but unintuitive way it is
suggested you use with the new R pipe function.
I am wondering if any has created one of a family of functions that might be
more intuitive if less general.
Some existing pipes simply allowed you to specify where in an argument list
to put the results from the earlier pipeline as in:
. %>% func(first, . , last)
In
2005 Jan 07
10
How to balance OUTBOUND traffic by packet if..
how to use iproute/iptables to balance by packet OUTBOUND traffic between
2 PPP (pptp cable modem and pppoe adsl modem) links to the same ISP . also
by using the fact that the ISP dosen''t filter source IP address - meaning
i can use either PPP''s link assigned IP address as the source IP in the ip
header.., it works for both devices.., what i want to achive is : when
uploading a
2007 Oct 03
2
Speeding up simulation of mean nearest neighbor distances
I've written the function below to simulate the mean 1st through nth
nearest neighbor distances for a random spatial pattern using the
functions nndist() and runifpoint() from spatsat. It works, but runs
relatively slowly - would appreciate suggestions on how to speed up
this function. Thanks. --Dale
library(spatstat)
sim.nth.mdist <- function(nth,nsim) {
D <- matrix(ncol=nth,