Displaying 20 results from an estimated 10000 matches similar to: "sapply behavior"
2006 Mar 03
1
NA in eigen()
Hi,
I am using eigen to get an eigen decomposition of a square, symmetric
matrix. For some reason, I am getting a column in my eigen vectors (the
52nd column out of 601) that is a column of all NAs. I am using the option,
symmetric=T for eigen. I just discovered that I do not get this behavior
when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is
(up to rounding error) a
2006 Jan 19
2
Downloads -- possible bug?
Hi,
When I go to the CRAN page to download a new version of R, there are not
the same versions available depending on which mirror I pick. When I go to
http://cran.cnr.berkeley.edu/, for example, I get 2.2.1, but if I go
http://cran.stat.ucla.edu/ the option is 2.2.0 (I'm downloading the Windows
base file). Neither refreshing nor clearing my cache changes it. For future
reference, I'd
2011 Oct 09
1
sapply(pred,cor,y=resp)
Hello. I am wondering why I am getting NA for all in cors=sapply(pred,cor,y=resp). I suppose that each column in pred has NAs in them. Is there some way to fix this? Thanks
> str(pred)
'data.frame': 200 obs. of 13 variables:
$ mnO2: num 9.8 8 11.4 4.8 9 13.1 10.3 10.6 3.4 9.9 ...
$ Cl : num 60.8 57.8 40 77.4 55.4 ...
$ NO3 : num 6.24 1.29 5.33 2.3 10.42 ...
$ NH4 : num 578
2006 Jan 30
2
'all' inconsistent?
Hello,
I came across the following behavior, which seems illogical to me. I don't
know if it is a bug or if I'm missing something:
> all(logical(0))
[1] TRUE
> any(logical(0))
[1] FALSE
> isTRUE(logical(0))
[1] FALSE
This actually came up in practice when I did something like
> all( names(x) %in% vec )
as an error-handling, and I was hoping that it would work regardless
2009 Oct 29
3
Removing & generating data by category
Dear R users,
Basically, from the following arbitrary data set:
a <-
data.frame(id=c(c("A1","A2","A3","A4","A5"),c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"),6),rep("Life",4)))
> a
2009 Apr 26
2
Help to select the raw in a data.frame with the max value
Dear User,
thank for the attention. I have a data.frame with 5 columns (ex:ID,
a1,a2,a3,a4) and 1000 rows. I wish to find the absolute max value for all
data.frame and save a new data.frame with the row where is that value. Ex:
ID: 1,2,3,4,5,6,7,8,9,10
a1:1,2,3,4,5,6,7,8,9,10
a2:11,12,13,14,15,16,17,18,19,20
a3:21,22,23,24,25,26,27,28,29,30
a4:31,32,33,34,35,36,37,38,39,40
The
2005 Mar 19
2
simple problem, but not for me
Hello, I'm new in R and I want to do one thing that is very easy in excel, however, I cant do it in R.
Suppose we have the data frame:
data<- data.frame(A=c("a1","a2","a3","a4","a5"))
I need to obtain another column in the same data frame (lets say B=c(b1,b2,b3,b4,b5) in the following way:
b1=a1/(a1+a2+a3+a4+a5)
2017 Oct 09
3
Merge me agrega siempre las columnas
Buenas,
Tengo dos data.frames de la siguiente manera
library(data.table)
id<-c("a1","a2","a3","a4")
id2<-c("a2","a3","a1","a4")
y<-c(1,2,3,4)
z<-c(3,5,6,7)
k<-c(1,3,8,7)
df1<-data.table(id,y,z)
id<-c("a2","a3","a1","a4")
df2<-data.table(id,x,y)
Quiero
2011 Mar 22
2
Problem with mclapply -- losing output/data
Hello,
I am running large simulations, which unfortunately I can't really
replicate here because the code is so extensive. I rely heavily on
mclapply, but I realize that I'm losing data somewhere.
There are two worrisome symptoms:
1) I am getting 'NULL' as a return value for some (but not all) elements
of the output when I use mclapply, but not if I use lapply
> tmp2[1:3]
2010 Apr 13
2
sensitivity analysis, input factors
Hi,
I'm trying to conduct sensitivity analysis in R using the 'sensitivity' package. Although the description of functions seem straightforward, I can?t succeed. The definition of input factors can be the problem.
library(sensitivity)
#A simple model with 4 input factor to test the morris function:
model01=function(a1,a2,a3,a4)
{
Z<-numeric(10)
Z[1]<-runif(1)
2008 Feb 10
2
reshape
Dear colleagues,
I'd like to reshape a datafame in a long format to a wide format, but
I do not quite get what I want. Here is an example of the data I've
have (dat):
sp <- c("a", "a", "a", "a", "b", "b", "b", "c", "d", "d", "d", "d")
tr <- c("A",
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and
2009 Sep 04
1
User defined function's argument as Subset function's input
Dear R users,
I have a data where I desire to subset according to certain conditions.
However, the script is very messy as there are about 30 distinct conditions.
(i.e. same script but with different conditions)
I would like to make a user defined function so that I can input the desired
conditions and just get the results accordingly.
Below is an arbitrary data set & sample statements
2004 Dec 02
3
Wishlist: simple legend options (PR#7400)
Full_Name: Elizabeth Purdom
Version: 1.9.1
OS: Windows XP
Submission from: (NULL) (171.64.102.199)
It would be nice if legend had the option of some default locations you could
choose instead of entering specific coordinates, like "topleft",
"topright","topcenter", etc. based on par("usr") coordinates. I know I've wanted
it so often I've made my
2008 Aug 18
2
matrix row product and cumulative product
I spent a lot of time searching and came up empty handed on the
following query. Is there an equivalent to rowSums that does product or
cumulative product and avoids use of apply or looping? I found a rowProd
in a package but it was a convenience function for apply. As part of a
likelihood calculation called from optim, I?m computing products and
cumulative products of rows of matrices with
2018 May 27
1
if else with 4 conditions problem
Hi everyone,
I have two columns:
? ?A? ? ? ? ? ? ? ?B
? ?1? ? ? ? ? ? ? ?1? ?1? ? ? ? ? ? ? ?0
? ?0? ? ? ? ? ? ? ?1
? ?0? ? ? ? ? ? ? ?0
I have 4 categories which are:
1) if A = 1 and B =1 then A1 = 1, else A2 = 0, A3 = 0, A4 = 0
2) if A = 1 and B =0 then A1 = 0, else A2 =1, A3 = 0, A4 = 0
3) if A = 0 and B = 1 then A1 = 0, else A2 = 0, A3 = 1, A4 = 0
4) if A = 0 and B =0 then A1 = 0, else A2 =
2010 Sep 27
2
subtraction based on two groups in a dataframe
Hello
I have a data set like below:
plate.id well.id Group HYB rlt1
1 P1 A1 Control SKOV3hyb 0.190
2 P1 A2 Control SKOV3hyb 0.210
3 P1 A3 Control SKOV3hyb 0.205
4 P1 A4 Control SKOV3hyb 0.206
5 P1 A5 Control SKOV3hyb 0.184
385 P1 A1 ovca SKOV3hyb 0.184
386 P1 A2 ovca SKOV3hyb 0.229
387
2009 Jan 11
4
How to get solution of following polynomial?
Hi, I want find all roots for the following polynomial :
a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08,
-0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, 0,
-0.06, -0.34), 2)
A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e
fn <- function(z)
{
y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4
2013 Feb 07
1
Merging data in arrays
Dear All,
Here is a hypothetical sample (sorry for the clumsy code):
A1 <- matrix(1:5, nrow=5, ncol=1)
A2 <- matrix(6:10, nrow=5, ncol=1)
A3 <- matrix(11:15, nrow=5, ncol=1)
A4 <- matrix(16:20, nrow=5, ncol=1)
A5 <- matrix(21:25, nrow=5, ncol=1)
A6 <- matrix(26:30, nrow=5, ncol=1)
B1 <- matrix(c(A1, A2, A3), nrow=5, ncol=3)
B2 <- matrix(c(A2, A3, A4), nrow=5, ncol=3)
B3
2009 Jul 29
1
Subtract matrices within arrays along indices
I have the following array: 3 dimensional object, one dimension being year.
Object is 3*3*3
library(plyr, reshape)
a1<-rep(c(2007,2008,2009),9)
a2<-c(rep("a",9),rep("b",9),rep("c",9))
a3<-c(rep(c(rep(1,3),rep(2,3),rep(3,3)),3))
a4 <- rnorm(27)
A<-data.frame(cbind(comp=a2,val=a3, year=a1, a4))
A1<-melt(A, id=c("year", "comp",