Hello. readBin is designed to read a batch of data with the same spec, e.g.
read 1 floats into a vector. In practise I read into data frame, not
vector. For each data frame, I need to read a integer and a float.
for (i in 1:1000) {
dataframe$int[i] <- readBin(con, integer(), size
I guess this has been discussed before, but I don't know the name of this
problem, thus had to ask again.
Consider this scenario:
fun <- function(x) { print(x)}
for (i in Vectorize(fun, "x")(1:3)) print("OK")
[1] 1
[1] 2
[1] 3
[1] "OK"
[1] "OK"
[1] "OK"
The optimal behaviour is:
fun <- f
On Thu, 1 Aug 2013, Jeff Newmiller wrote:
The Vectorize function is essentially a wrapped up for loop, so you are
really executing two successive for loops. Note that the Vectorize
function is not itself vectorised, so there is no particular advantage to
using it in this way. You might as we
The manual seems to suggest, with the SIMPLIFY = TRUE default option,
Vectorize would conjure a vector if possible.
Quote:
SIMPLIFY: logical or character string; attempt to reduce the result to
a vector, matrix or higher dimensional array; see the
‘simplify’ argument of ‘sappl
On Wed, 14 Aug 2013, Hervé Pagès wrote:
Hi Zhang,
First note that a list is a vector (try is.vector(list())).
The documentation for sapply() and Vectorize() should say *atomic*
vector instead of vector in the desccription of the 'simplify' and
'SIMPLIFY' arguments.
So in order for sapply() t
When you select a single row from a matrix, the dimsion is lost:
n <- matrix(nrow = 3, ncol = 5)
dim(n)
[1] 3 5
dim(n[1,])
NULL
dim(n[2,])
NULL
This doesn't happen if you select more than one row:
dim(n[1:2,])
[1] 2 5
This is causing trouble. SCENARIO: when I filter out unqualified sam
Perhaps this is simple and common, but it took me quite a while to admit I
cannot solve it in a simple way.
The data frame `df` has the following columns:
unixtime, value, factor
Now I need a matrix of:
unixtime, value-difference-between-factor1-and-factor2
The naive solution is:
I've got two data frames, as shown below:
(NR means Number of Record)
record.lenths
NR length
1 100
2 130
3 150
4 148
5 100
683
760
valida.records
NR factor
It is a nice surprise to wake up receiving three answers, all producing
correct results. Many thanks to all of you.
Jim Holtman solved it with amazing clarity. Gang Peng using a traditioanl
C-like pointer style and Arun with awesome tight code thanks to diff().
I am embrassed to see my mis-
input:
> values
[1] 0.854400 1.648465 1.829830 1.874704 7.670915 7.673585 7.722619
> thresholds
[1] 1 3 5 7 9
expected output:
[1] 1 4 4 4 7
That is, need a vector of indexes of the maximum value below the threshold.
e.g.
First element is "1", becaus
On Fri, 13 Sep 2013, William Dunlap wrote:
findInterval(thresholds, values)
[1] 1 4 4 4 7
Thanks a lot! But now I have a new problem, a typical R issue perhaps.
First, let's look at a successful case:
> thresholds <- c(1,3,5,7,9)
> values <- c(0.854, 1.648, 1.829, 1.874,
On Fri, 13 Sep 2013, William Dunlap wrote:
You may want to append -Inf (or 0 if you know the data cannot be
negative) to the start of your 'values' vector so you don't
have to write code to catch the cases when a threshold is below
the range of the values.
> findInterval(thresholds, c(0,valu
I own a lot to the folks on r-help list, especially arun who answered every
of my question and was never wrong. I am disinclined to once again ask this
question, since it is more arithmatic than technical. But, having worked 2
days on it, I realized my brain is just not juicy enough
Here
On Sat, 14 Sep 2013, Zhang Weiwu wrote:
I own a lot to the folks on r-help list, especially arun who answered
every of my question and was never wrong. I am disinclined to once again
ask this question, since it is more arithmatic than technical. But, having
worked 2 days on it, I realized
On Sun, 15 Sep 2013, Andrew Crane-Droesch wrote:
The c2d4u PPA is the main search result when googling "upgrade R 3.0.1
ubuntu".
And it should be, because it is more likely that a PPA re-distribution works
better for Ubuntu than a general distribution, even if it is an exceptional
case with
15 matches
Mail list logo