Displaying 20 results from an estimated 9000 matches similar to: "Substract "previous" element"
2011 Feb 13
2
Removing elements from a vector matching a criteria, BUG in which() function
Dear all,
I found a bug in the which() function.
When trying to remove elements with the which function,
if the criteria is not matched, numeric(0) is returned instead of the
array itself.
This is very weird.
> a = c(1,2,3,4,5)
> a[!a==6]
[1] 1 2 3 4 5
> a[-which(a==6)]
numeric(0)
> a[-which(a==5)]
[1] 1 2 3 4
> a[!a==5]
[1] 1 2 3 4
Is this correct? I believe this is a bug.
I
2012 Jul 31
1
TimeStamps to seconds
Dear all,
I am having a matrix that stores data information in the following format.
> roofPart1$TimeStamps[1:5,]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 2011 7 21 15 25 20.609
[2,] 2011 7 21 15 25 23.265
[3,] 2011 7 21 15 25 26.000
[4,] 2011 7 21 15 25 28.671
[5,] 2011 7 21 15 25 31.343
I would like to be able to report some simple statistics
2011 Mar 21
3
How to substract a valur from dataframe with condition
Hello All,
I need help with my dataframe, it is big but here I am using a small table
as an example.
My dataframe df looks like:
X1 X2 X3
1 2011-02 0.00 96.00
2 2011-02 0.00 2.11
3 2011-02 2.00 3.08
4 2011-02 0.06 2.79
5 2011-02 0.00 96.00
6 2011-02 0.00 97.00
7 2011-02 0.08 2.23
I want values in columns X2 and X3 to be checked if they are greater than
2011 Oct 19
4
Using SQL "IN" with RJDBC or RMySQL
Hello,
The code below works fine up until I try to use the "IN" statement in
the last line. The proper SQL format is:
SELECT * FROM this_table WHERE this_column IN (1,2,3,4,5)
But, I think I may be getting something like:
SELECT * FROM this_table WHERE this_column IN c(1,2,3,4,5)
Which makes no sense in SQL. I think it may be just a matter of string
massaging, but I'm not
2011 Aug 15
3
write.table extra column
In the following data.frame there are 6 columns, but 7 are written to
the CSV file.
install.packages("pmlr")
library(pmlr)
data(enzymes)
write.table(enzymes, sep=",", eol="\n",file="albert.csv")
2013 Jan 29
3
NA and Character(0) in List Element
Hi, This is probably a small query but one I'm struggling with: I have a list in which I had elements which were NA, I removed them, by doing: list2 <- lapply(list, na.omit),
However this leaves the element there with 'character(0)' in place as well as attributes:
e.g.
[[978]]
character(0)
attr(,"na.action")
[1] 1
attr(,"class")
[1] "omit"
I want
2011 Jul 19
3
How to get predicted values of y for different x values?
Here is my model with interaction terms and control variables (I changed
variables names for easy read):
reg1 <- lm(y ~ x1*x2*x3 +control1 + control2 + control3)
x1 ranges from 0 to 6; x2 from 0 to 5; and x3 from 0 to 4. All three are
discrete ordinal variables; but I will treat them as continuous variables.
(a) How can I see the predicted values of y for each of these scenarios (210
2012 Feb 07
2
Vectorizing a loop
Hello Folks,
I'm trying to vectorize a loop that processes rows of a dataframe. It
involves lots of conditionals, such as "If column 10 == 3, and if column
3 is True, and both column 5 and 6 are False, then set column 4 to True".
So, for example, any ideas about vectorizing the following?
df = data.frame( list(a=c(1,2,3,4),
2018 Mar 27
5
unable to move temporary installation of package
Thanks,
Here's the error, for example:
> install.packages("mgcv")
Installing package into 'C:/Users/pl39/Documents/R/win-library/3.4'
(as 'lib' is unspecified)
trying URL 'https://mirrors.nics.utk.edu/cran/bin/windows/contrib/3.4/mgcv_1.8-23.zip'
Content type 'application/zip' length 2775362 bytes (2.6 MB)
downloaded 2.6 MB
package 'mgcv'
2012 Apr 23
2
.rda vs. .RData
Are they the same with .RData being the newer format?? Thanks,
...Tao
2013 Oct 10
1
Rcpp and mclapply
Dear all,
I have an R script that uses Rcpp, and I have been trying to parallelize
it using mclapply (I tried with the multicore and the parallel library)
Sometimes (not always, interestingly), the CPU use for each core drops,
usually so that the total over all cores reaches 100%, i.e., as fast as if
using just one single core fully. I tried my code directly from within
emacs, and also using a
2018 Mar 27
0
unable to move temporary installation of package
Do you have other instances of R open at the time you are doing this? Did
you already have mgcv installed in your personal library when you tried
installing it again?
There is clearly something preventing you from writing to your library, or
at least to specific packages in your library.
On Tue, 27 Mar 2018, Paul Lantos wrote:
> Thanks,
>
> Here's the error, for example:
>
2013 Oct 12
1
lmerTest
Hi,
I'm trying to user lmer function from lmerTest package because, if I
understood correectly, it allows to make better inference than lmer method
from lme4 package. However, whatever I do I keep getting this error:
Error in lme4::lFormula(formula = mark ~ ssCount + sTime+ : rank of X =
1660 < ncol(X) = 1895
any ideas what could be a problem?
thanks,
Srecko
[[alternative HTML
2011 Aug 02
1
My R code is not efficient
Dear R users,
I have two n*1 integer vectors, y1 and y2, where n is very very large.
I'd like to compute
elbp = 4^(y1) * 5^(y2) * sum_{i=0}^{max(y1, y2)} [{ (y1-i)! * (i)! *
(y2-i)! }^(-1)];
that is, I need to compute "elbp" for each (y1, y2) pair.
So I made R code like below, but I don't think it's efficient
Would you plz tell me how to avoid this "for"
2012 Nov 11
2
Cropping a matrix by rows
Hello r-help,
I've been banging my head against the computer in an attempt to learn how
to divide my matrix into segments by rows. I want to be able to return each
segment as a newly named object. I've tried looking at the apply functions
and creating a for loop but brain no work. Here's the basic starting
objects that I believe would be needed to separate the matrix.
mat <-
2018 Mar 27
2
unable to move temporary installation of package
I deleted my library, reinstalled R, and had the same issue -- couldn't install anything into its newly created library.
-----Original Message-----
From: Jeff Newmiller [mailto:jdnewmil at dcn.davis.ca.us]
Sent: Tuesday, March 27, 2018 2:26 PM
To: Paul Lantos <paul.lantos at duke.edu>
Cc: r-help at r-project.org
Subject: RE: [R] unable to move temporary installation of package
Do you
2011 Jul 04
1
R CMD SHLIB with ifort
Hi,
I am running Linux (64 bit) R, compiled under gnu compilers. I am looking
to compile a Fortran program with the ifort (the intel compiler) and then be
able to import that as a library into my version of R. I am using the
flags FC=ifort and SHLIB_FCLD=ifort, however ifort does not seem to
recognize the libR.so file.
Does any one have experience with this/know of a a way to load an ifort
2011 Nov 25
3
counting values with some conditions in a simulation
Dear R users,
I am running simulations (1000), and in my simulation I am looking at
specific sums. For example, if the sum is >=4 then count this, if say <3,
then don't count, if the sum=3, then generate a random number from uniform
distribution, if this number is say less than 0.5, then count this sum, if
greater than 0.5, then don't count. I am having trouble with introducing
this
2012 Jan 11
3
64bit R under 32bit winxp
Hi all:
My OS is 32bit winxp,but I wanna install 64bit R2.14.1.
>From the following website,it says "You can also go back and add 64-bit components to a 32-bit install, or vice versa"
http://cran.r-project.org/bin/windows/rw-FAQ.html#Can-both-32_002d-and-64_002dbit-R-be-installed-on-the-same-machine_003f
Does it mean that I can install and run 64bit R2.14.1 under 32bit
2012 Mar 12
3
Idea/package to "linearize a curve" along the diagonal?
Hi,
I am trying to normalize some data. First I fitted a principal curve
(using the LCPM package), but now I would like to apply a
transformation so that the curve becomes a "straight diagonal line" on
the plot. The data used to fit the curve would then be normalized by
applying the same transformation to it.
A simple solution could be to apply translations only (e.g., as done
after a