search for: list4

Displaying 9 results from an estimated 9 matches for "list4".

Did you mean: list
2012 Aug 01
4
apply function over same column of all objects in a list
Hello. Please forgive me if this problem has already been posted (and solved) by someone else ... I can't find it anywhere though it seems so very basic. Here it is: I have a list comprised of several matrices, each of which has two columns. > list [[1]] [,1] [,2] [1,] 1 3 [2,] 2 4 [[2]] [,1] [,2] [1,] 5 7 [2,] 6 8 [[3]] [,1] [,2]
2009 Jun 22
2
question about using _apply and/or aggregate functions
...or _apply, aggregate, arrays and data types, and have also consulted with several texts (Maindonald and Braun; Spector; Venebles and Ripley for S-plus). Somehow I still don't get it. My attempts usually result in a message like the following: > agg.result = aggregate(simarray.part[,3], by=list4, FUN = mean) Error in FUN(X[[1L]], ...) : arguments must have same length But when I check the length of the arguments, they appear to match. (??) > length(simarray.part[,3]) [1] 5000 > length(simarray.part[,4]) [1] 5000 > length(list4) [1] 5000 I would have rather passed along a subse...
2009 Oct 12
1
Creating object referant from argument name
Hi all. I'd like to define an object within a function based on an argument to that function. Specifically, I've got: do.something<-function(input){ id<-substring(input,3,3) j<-list1 if(id==2)j<-list2 if(id==3)j<-list3 if(id==4)j<-list4 ...} Instead of all these if() arguments, I was hoping to use something like: j<-paste("list",substring(input,3,3),sep="") but this just assigns j the value of "listx" of _character_ mode, instead of the actual object 'listx'. Is there any way to get around...
2012 Dec 14
2
Manipulation of longitudinal data by row
I have a dataset of the form below, consisting of one unique ID per row, followed by a series of visit dates. At each visit there are values for 3 dichotomous variables. Of the 8 different possible combinations of the three variables, 4 are "abnormal" and the remaining 4 are "normal". Everyone starts out abnormal, and then either continues to be abnormal at subsequent visits,
2005 Jul 21
1
again, a question between R and C++
Dear R Users, I want to make a call from R into C++. My inputs are List1, List2, List3, IntegerID. The amount of elements of the lists and their type depend on IntegerID. Typical elements of a given list can be vectors, doubles, and even other lists. I want to return also a list (whose nature will depend also, possibly, on IntegerID). What I want to do is to call these 4 inputs from C++ and then
2012 Jul 02
4
Assigning a vector to every element of a list.
I have a vector d of unknown length, and a list b of unknown length. I would like to replace every element of b with d. Simply writing b<-d does not work as R tries to fit every element of d to a different element of d, and b<-rep(d,length(b)) does not work either as it makes a list of length length(d)*length(b) not a list of length(b). I know how to do this with a for loop, but I feel that
2004 Jun 23
5
assigning from multiple return values
I know that if I have a function that returns multiple values, I should do return(list(foo, bar)). But what do I do on the recieving end? fn <- function(x) { return(list(foo, bar)) } I know that at this point I could say values.list <- fn(x) and then access values.list[1] values.list[2] But that's hideous. I'd rather be able to say something like list(local_foo, local_bar)
2013 Feb 19
1
data format
Hi, Try this: el<- read.csv("el.csv",header=TRUE,sep="\t",stringsAsFactors=FALSE) ?elsplit<- split(el,el$st) ? datetrial<-data.frame(date1=seq.Date(as.Date("1930.1.1",format="%Y.%m.%d"),as.Date("2010.12.31",format="%Y.%m.%d"),by="day")) elsplit1<- lapply(elsplit,function(x)
2007 May 16
2
substitute "x" for "pattern" in a list, while preservign list "structure". lapply, gsub, list...?
I am experimenting with some of the common r functions. I had a question re:using "gsub" (or some similar functions) on the contents of a list. I want to design a function that looks at "everything" contained din a list, and anytime it finds the text string "pattern" replace it with "x". I also wish to preserve the "structure" of the original