Displaying 20 results from an estimated 10000 matches similar to: "Subscript out of Bounds Lapply"
2013 Jan 25
3
Removal of columns from matrix where all values of the column are identical.
Hi all,
I'd like to write a piece of code which will remove columns from a matrix, if the column contains only one value, say every value in the column is a "3":
Matrix <- matrix(NA, nrow=5, ncol=4)
Matrix[,1] <- c(1,2,3,4,5)
Matrix[,2] <- c(3,3,3,3,3)
Matrix[,3] <- c(5,4,3,2,1)
Matrix[,4] <- c(5,1,4,3,2)
[,1] [,2] [,3] [,4]
[1,] 1 3 5 5
[2,] 2
2013 Jan 24
1
Pairwise Comparrisons
Dear all,
I''m trying to write a function, that will take as an argument, some aligned genome sequences, and using a sliding window, do pairwise comparisons of sequence similarity. Coding the sliding window I think I can manage but what I''m trying to get to grips with is getting it so as every pairwise comparison is made, no matter how many genomes are added, from 3 to N.
So if
2012 Nov 08
1
Extract cell of many values from dataframe cells and sample from them.
Hi,
First my apologies for a non-working piece of code in a previous submission, I have corrected this error.
I'm doing is individual based modelling of a pathogen and it's host. The way I've thought of doing this is with two dataframes, one of the pathogen and it's genes and effector genes, and one of the host and it's resistance genes. During the simulation, these things
2012 Oct 28
6
Having some Trouble Data Structures
Hi All,
I'm trying to run a simulation of host-pathogen evolution based around individuals.
What I need to have is a dataframe or table of some description - describing all the individuals of a pathogen population (so far I've implemented this as a matrix):
ID No_of_Effectors Effectors (Sequences)
[1,] 0001 3 ## 3
2012 Nov 27
2
Stuck trying to modify a function
Hi,
I have the following data:
Path_Number <- 5
ID.Path <- c(1:Path_Number) # Make vector of ID's.
No_of_X <- sample(50:550, length(ID.Path), replace=TRUE) #
X <- split(sample(1:10000, sum(No_of_X), replace=TRUE), rep(ID.Path, No_of_X))
Y <- lapply(X,function(x) sample(x, round(runif(1, min=10, max=50))))
X and Y are both lists, and I've made the following function to
2013 Feb 14
0
Building a Package & using gWidgets
Hi,
For the past few months I've been building a simulation in R I hope to package. It consists of two usable functions, and many internal ones which one of the two usable functions call while looping, to perform the stages of simulation.
A simple conceptual example is:
# Abstract representation 1st Usable function, generates object containing settings for simulation.
settings <-
2012 Nov 16
1
Code works, but not as function.
Hi,
I have some values in a list format generated by the following:
Path_Number <- 0010
ID.Path <- formatC(0001:Path_Number, width=4, flag=0) # Make vector of ID's.
No_of_Effectors <- sample(1:550, length(ID.Path), replace=TRUE) # Define Number of Effectors each individual gets.
Effectors <- split(sample(1:10000, sum(No_of_Effectors), replace=TRUE), rep(ID.Path, No_of_Effectors))
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
2004 Jul 20
1
Error: subscript out of bounds
Hi
I am running a simulation that involves a loop calling three 2 functions that I have written. Everything works fine when the inside of the loop is performed up to 1000 times (for (i in 1:750)).
However, I sometimes get : ''Error: subscript out of bounds'' if I try to increase the loop 'size' to 1000. I am thinking it has to to with memory but I am not sure. I have
2012 Apr 06
2
Sincere inquiry about “subscript out of bounds” error in R
Hello£¬experts
I am working on a simulation of effect of artificial selection on certain population in Animal Breeding.I am new beginner in coding. I have already build a matrix A(500*500) based on this code
A<-matrix(,500,500)
for(i in 1:500){
for(j in 1:500){
ifelse(i==j,A[i,j]<-1,A[i,j]<-0)
}
}
and I need to caculate A2
base on A and X1(4500*4500).Here are the codes
2024 Feb 07
1
[EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments
I put the idea below into a function that gives nicer looking results.
Here's the new code:
dupnames <- function(path = ".") {
Rfiles <- pkgload:::find_code(path)
allnames <- data.frame(names=character(), filename=character(), line
= numeric())
result <- NULL
for (f in Rfiles) {
exprs <- parse(f, keep.source = TRUE)
locs <-
2010 Jun 15
2
yum force
I'm trying to do an update to some servers... and they have both i386 and
x86_64 perl. The latter won't update, because the idiotic *man pages* are
dups. Is there *any* way, short of using rpm directly with a --force, to
get yum to ignore the dups and do the update?
And why does *anyone* make it so that a dup manpage is a reason to fail
(and don't tell me they do it generically for
2010 Mar 14
1
Error in object$tables[[v]] : subscript out of bounds
Hi,
Could you please tell me how I correct the following error message?
“Error in object$tables[[v]] : subscript out of bounds”
This is the code:
library(e1071)
data(iris)
attach(iris)
class_label <- names(iris)[1]
myformula <- formula(paste(class_label,"~ ."))
mymodel<-naiveBayes(myformula, iris,cross=3)
predict(mymodel,iris) ##Error in object$tables[[v]] :
2011 Jan 05
0
Fwd: Re: Simulation - Natrual Selection
-------- Original Message --------
Subject: Re: [R] Simulation - Natrual Selection
Date: Wed, 05 Jan 2011 17:24:05 +0000
From: Ben Ward <benjamin.ward@bathspa.org>
To: Bert Gunter <gunter.berton@gene.com>
CC: Mike Marchywka <marchywka@hotmail.com>
On 05/01/2011 17:08, Bert Gunter wrote:
> Couple of brief comments inline below. -- Bert
>
> On Wed, Jan 5, 2011 at
2006 Oct 18
2
Error: subscript out of bounds (PR#9305)
Full_Name: Steven King
Version: 1.16
OS: OSX vesion 10.4.8
Submission from: (NULL) (71.126.161.149)
Setting a matrix is a function - the failure occurs only on 2 X 2 matrices.
x<-matrix(1:4,nrow=2)
> x
[,1] [,2]
[1,] 1 3
[2,] 2 4
> x[x]<-2
Error: subscript out of bounds
2009 Nov 24
1
Subscript out of bounds
Hi!
Trying to make a forecast, and get the following error message:
Error in NextMethod("[<-") : subscript out of bounds
The script is as follows:
> Forecast.A <- ts(matrix(NA, nrow=25, ncol = 1,
+ dimnames = list(c(), c("Outcome"))),
+ start = c(2006, 10), frequency = 12)
> for (i in 1:25) {
+ j <- i + 321
+ Data <- window(omxr, end = time(omxr)[j])
+
2011 Mar 05
2
subscript out of bounds
Dear ALL
I cannot run this line
stat.obs <- apply (GS, 2, function(z) Hott2(t(DATA[which(z==1),]), cl))
Error in Hott2 (t(DATA[which(z == 1), ]), cl) : subscript out of bounds
I will be glade if you guide me.
*******************************************************************************
*GS is a matrix 1857*200
*DATA is a matrix 1857*79
*cl <- as.factor(y)
2012 Mar 13
1
Error " subscript out of bounds"
Hello, R-users,
I have a datafile with 37313 records and each record has 5 different measurements on the same variables. The format looks like this: treeID, VIG0, VIG1, VIG2, VIG3, VIG4
I was trying to convert the one row record to 5 rows record with format like this (treeID, MEASUREMENT, VIGOR). My code like this:
treeMeas<-matrix(data=0,nrow=(length(tree1$indivTree)*5), ncol=3)
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
2010 Dec 08
1
Error in eval.with.vis(expr, envir, enclos) : subscript out of bounds
I have a for-loop in my code that calls another .R file:
source("estimation.R")
This file runs through without any problems, so the program completes the loop one time. However, when the loop starts a second time and it comes time to call the file "estimation.R" again, program stops and prints the following error message:
"Error in eval.with.vis(expr, envir, enclos) :