similar to: Private: Problem with tapply/lapply and sample (PR#3286)

Displaying 20 results from an estimated 2000 matches similar to: "Private: Problem with tapply/lapply and sample (PR#3286)"

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
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: > > >
2003 Oct 27
2
how to select random rows ?
How can I select random subsets (rows!) from a data set ? If I generate simple data set > a <- data.frame(x=1:2, y = NaN, z = 2:1) > a x y z 1 1 NaN 2 2 2 NaN 1 I can select random subsets (colums) very easily using sample function: > sample(a, 2) z y 1 2 NaN 2 1 NaN I expected that using transpose of a would do the same for rows, but I am getting rather unexpected
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 Aug 19
4
sorting character vectors
The following is not what I expected in sorting characters (single letters and the same letters with preceding spaces). Can someone enlighten me as to why the following might be a correct result for sorting? ; x <- c(LETTERS[1:3], paste(" ", LETTERS[1:3], sep="")) ; x [1] "A" "B" "C" " A" " B" " C" ; sort(x)
2007 May 09
4
Unit Testing Frameworks: summary and brief discussion
Greetings - I'm finally finished review, here's what I heard: ============ from Tobias Verbeke: anthony.rossini@novartis.com wrote: > Greetings! > > After a quick look at current programming tools, especially with regards > to unit-testing frameworks, I've started looking at both "butler" and > "RUnit". I would be grateful to receieve real
2004 Mar 02
2
row.names are dropped when extracting one column ?
Apparently row names are dropped when I extract single column from a data frame. Why this behaviour ? > y <- as.matrix(df[,1:2]); length(row.names(y)) [1] 324 > y <- as.matrix(df[,1:1]); length(row.names(y)) [1] 0 Best regards, Ryszard
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
2004 Feb 03
2
problem with read.table
Any ideas why read.table complains about not correct number of elements in line while readLine/strsplit indicate that all lines have the same number of elements ? R > tbl <- read.table('tmp', header = T, sep = '\t') Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 32 did not have 27 elements > lines <-
2010 Mar 26
1
BaselR
BaselR - The new R meeting We are pleased to announce the new R meeting to be held in Basel, Switzerland. BaselR will be held from 6:30-9:30pm on Tues, Apr 27 at TransBARent: http://transbarent.business.sv-group.ch Doors open at 6:30,pm with the presentations starting at 7:00pm Introduction: What is Basel R? Andreas Krause:... Graphing Pharma Data Yann Abraham: Graphics Charles Roosen: Web
2004 Jun 09
4
how to initialize random seed properly ?
I want to start R processes on multiple processors from single shell script and I want all of them to have different random seeds. One way of doing this is sleep 2 # (with 'sleep 1' I am often getting the same number) ... set.seed(unclass(Sys.time())) Is there a simpler way without a need to sleep between invoking different R processes ? Ryszard
2017 Aug 19
4
My very first loop!! I failed. May I have some start-up aid?
Dear all, I have a data similar to this: myframe<- data.frame (ID=c("Ernie", "Ernie","Ernie","Ernie"), Timestamp=c("24.09.2012 08:00", "24.09.2012 09:00", "24.09.2012 10:00", "25.09.2012 10:00"), Longitude=c("8.481","8.482","8.483","8.481"),
2012 Mar 07
5
Sampling problems
Hi, I need to sample randomly my dataset for 1000 times. The sample need to be the 80%. I know how to do that, my problem is that not only I need the 80%, but I also need the corresponding 20% each time. Is there any way to do that? Alternatively, I was thinking to something like setdiff () function to compare my 80% sample to the original dataset and obtain the corresponding 20%, unfortunately
2011 Aug 12
1
Which Durbin-Watson is correct? (weights involved) - using durbinWatsonTest and dwtest (packages car and lmtest)
Hello! I have a data frame mysample (sorry for a long way of creating it below - but I need it in this form, and it works). I regress Y onto X1 through X11 - first without weights, then with weights: regtest1<-lm(Y~., data=mysample[-13])) regtest2<-lm(Y~., data=mysample[-13]),weights=mysample$weight) summary(regtest1) summary(regtest2) Then I calculate Durbin-Watson for both regressions
2008 Jan 03
2
confidence interval too small in nlme?
Hello, I am interested in using nlme to model repeated measurements, but I don't seem to get good CIs. With the code below I tried to generate data sets according to the model given by equations (1.4) and (1.5) on pages 7 and 8 of Pinheiro and Bates 2000 (having chosen values for beta, sigma.b and sigma similar to those estimated in the text). For each data set I used lme() to fit a model,
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
Thank you for providing the example code... for the request of running it multiple times it would have helped if you could have confirmed that the example ran through without errors... there were a lot of mistakes in it. Look into using the reprex package to check your example next time. I don't do this kind of analysis... I really don't know what to expect from the functions. The
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
[answers inline] On 18 August 2017 at 20:08, Dagmar <Ramgad82 at gmx.net> wrote: > > myframe<- data.frame (ID=c("Ernie", "Ernie","Ernie","Ernie"), > Timestamp=c("24.09.2012 08:00", "24.09.2012 09:00", "24.09.2012 10:00", > "25.09.2012 10:00"),