similar to: how to skip NA columns ?

Displaying 20 results from an estimated 2000 matches similar to: "how to skip NA columns ?"

2002 Jun 20
16
problem with predict()
Hi, It is most probably just my R-ignorance, but I have following problem with using predict(). I train the model using 164 cases and then I try to use it on the data set with 35 cases, but I am getting 164 predictions ? R-code below illustrates in more detail what I am doing. Truly yours, R train = read.csv("train.csv", header = TRUE, row.names = "mol",
2002 Jun 26
3
sapply() and Monte Carlo
Dear Helplist Some time ago, Professor Ripley gave me a tip which I thought was very very useful for Monte Carlo simulation; I thought I'd pass it on to the list, and ask whether this or a similar example could be added to the sapply() manpage. Suppose I have ten N(0,1) random variables and I'm interested in the pair that are closest together: R> min(diff(sort(rnorm(10)))) [1]
2012 Jan 10
2
strange Sys.Date() side effect
Any ideas what is the problem with this code? > N <- 2; c(Sys.Date(), sprintf('N = %d', N)) [1] "2012-01-10" NA Warning message: In as.POSIXlt.Date(x) : NAs introduced by coercion Best regards, Ryszard Ryszard Czerminski AstraZeneca Pharmaceuticals LP 35 Gatehouse Drive Waltham, MA 02451 USA 781-839-4304 ryszard.czerminski@astrazeneca.com
2012 Jan 12
3
strsplit() does not split on "."?
Any ideas what is wrong? > strsplit("a.b", ".") # generates empty strings with split="." [[1]] [1] "" "" "" > strsplit("a b", " ") # seems to work fine with split=" ", and other characters... [[1]] [1] "a" "b" > > R.Version() $platform [1]
2011 Nov 23
2
bizarre seq() behavior?
Is there any rational explanation for the bizarre seq() behavior below? > seq(2,8.1, lenght.out=3) [1] 2 3 4 5 6 7 8 > help(seq) > seq(2,8,length.out=3) [1] 2 5 8 > seq(2,8.1,length.out=3) [1] 2.00 5.05 8.10 Except maybe that it is early in the morning :) Best regards, Ryszard Ryszard Czerminski AstraZeneca Pharmaceuticals LP 35 Gatehouse Drive Waltham, MA 02451 USA 781-839-4304
2010 Sep 27
1
smooth contour lines
Is there an easy way to control smoothness of the contour lines? In the plot I am working on due to the undersampling the contour lines I am getting are jugged, but it is clear "by eye" these should be basically straight lines. In maps package I found smooth.map function, but maybe there is a more generic way of accomplishing the same thing. Ideally there would be an option to control
2012 Jan 25
1
Error in predict.randomForest ... subscript out of bounds with NULL name in X
RF trains fine with X, but fails on prediction > library(randomForest) > chirps <- c(20,16.0,19.8,18.4,17.1,15.5,14.7,17.1,15.4,16.2,15,17.2,16,17,14.1) > temp <- c(88.6,71.6,93.3,84.3,80.6,75.2,69.7,82,69.4,83.3,78.6,82.6,80.6,83.5,76 .3) > X <- cbind(1,chirps) > rf <- randomForest(X, temp) > yp <- predict(rf, X) Error in predict.randomForest(rf, X) : subscript
2011 Jan 20
1
randomForest: too many elements specified?
I getting "Error in matrix(0, n, n) : too many elements specified" while building randomForest model, which looks like memory allocation error. Software versions are: randomForest 4.5-25, R version 2.7.1 Dataset is big (~90K rows, ~200 columns), but this is on a big machine ( ~120G RAM) and I call randomForest like this: randomForest(x,y) i.e. in supervised mode and not requesting
2003 Nov 14
6
index of max value ?
Is there a function in R, which would return index of maximum value in a vector ? e.g. > v <- round(10*rnorm(8)) > v [1] 6 -3 -6 15 7 9 0 -19 > max(v) [1] 15 ??? index.max(v) ??? 4
2003 Dec 10
3
e1071:svm - default epsilon = 0.1 (NOT 0.5) (PR#5671)
In e1071 package/svm default epsilon value is set to 0.1 and not 0.5 as documentation says. R
2010 Oct 22
3
how fit linear model with fixed slope?
I want to fit a linear model with fixed slope e.g. y = x + b (instead of general: y = a*x + b) Is it possible to do with lm()? Regards, Ryszard -------------------------------------------------------------------------- Confidentiality Notice: This message is private and may ...{{dropped:11}}
2003 Nov 12
4
column extraction by name ?
I have a data frame (df) with colums x, y and z. e.g. df <- data.frame(x = sample(4), y = sample(4), z = sample(4)) I can extract column z by: df$z or df[3] I can also extract columns x,y by: df[1:2] or by df[-3]. Is it possible to extract x,y columns in a "symbolic" fashion i.e. by equivalent of df[-z] (which is illegal) ??? Or alternativeley, is there an equivalent of
2003 Dec 09
2
problem with pls(x, y, ..., ncomp = 16): Error in inherit s( x, "data.frame") : subscript out of bounds
I don't know the details of pls (in the pls.pcr package, I assume), but if you use validation="CV", that says you want to use CV to select the best number of components. Then why would you specify ncomp as well? Andy > From: ryszard.czerminski at pharma.novartis.com > > When I try to use ncomp parameter in pls procedure I get > following error: > > >
2010 Mar 22
1
sets package: converting a set to data frame?
I just started using nice package "sets" and I wonder if there are utilities to convert (some) sets to data frame (as in the example below) > library(sets) > a <- gset(elements = list(e('A', 0.1), e('B', 0.8))) > lst <- as.list(a) > nr <- length(lst) > rnames <- character() > for (i in 1:nr) rnames[i] <- lst[[i]] > df <-
2010 Oct 04
2
plotmath: how to use greek symbols in expression(integral(f(tau)*dtau, 0, t))?
I would like to use greek "tau" as a symbol of variable to integrate over in plotmath expression(integral(f(tau)*dtau, 0,t)) but nothing seems to work. I tried d{\tau}, d\tau, etc., without any success Is it possible? How can I accomplish this? Best regards, Ryszard -------------------------------------------------------------------------- Confidentiality Notice: This message is
2010 Nov 18
2
how to find near neighbors?
I am looking for an efficient way to find near neighbors... More specifically... I have two sets of points: A & B and I want to find points in set B which are closer to set A than some cutoff (or n-closest) I will appreciate very much any pointers... Ryszard -------------------------------------------------------------------------- Confidentiality Notice: This message is private and may
2003 Oct 24
5
how to remove NaN columns ?
How can I remove columns with NaN entries ? Here is my simple example: > data <- read.csv("test.csv") > xdata <- data[3:length(data)] > xs <- lapply(xdata, function(x){(x - mean(x))/sqrt(var(x))}) > x <- data.frame(xs) > x C D E F 1 -0.7071068 NaN -0.7071068 -0.7071068 2 0.7071068 NaN 0.7071068 0.7071068
2003 Oct 31
3
print(), cat() and simple I/O in R
I am trying to produce rather mundane output of the form e.g. pi, e = 3.14 2.718 The closest result I achieved so far with print() is: > print (c(pi, exp(1)), digits = 3) [1] 3.14 2.72 > print(c("pi, e =", pi, exp(1)), digits = 3) [1] "pi, e =" "3.14159265358979" "2.71828182845905" I understand that c() promotes floats to strings and
2004 Jan 15
2
prcomp scale error (PR#6433)
Full_Name: Ryszard Czerminski Version: 1.8.1 OS: GNU/Linux Submission from: (NULL) (205.181.102.120) prcomp(..., scale = TRUE) does not work correctly: $ uname -a Linux 2.4.20-28.9bigmem #1 SMP Thu Dec 18 13:27:33 EST 2003 i686 i686 i386 GNU/Linux $ gcc --version gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) > a <- matrix(rnorm(6), nrow = 3) > sum((scale(a %*% svd(cov(a))$u, scale
2006 Apr 07
3
strange matrix behaviour: is there a matrix with one row?
Consider this: > y <- matrix(1:8, ncol=2) > is.matrix(y[-c(1,2),]) [1] TRUE > is.matrix(y[-c(1,2,3),]) [1] FALSE > is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again I just stumbled on this behaviour, because I had a problem with my