similar to: call object from character?

Displaying 20 results from an estimated 11000 matches similar to: "call object from character?"

2007 Oct 20
1
Getting at what a named object represents in a function...
Hi, I'm pretty new to R. I have an object (say a list) and I I have a function that I call on various columns in that list (excuse terminology if it's wrong/ambiguous). Imagine its like this (actual values are unimportant) and called mylist: >mylist A B 1 5 2 5 3 6 4 8 5 0 I have a function: foo = function(param){ #modify list A or B values depending on
2010 Feb 06
4
Sorting
Hi, I have a list of vectors (of varying lengths). I'd like to sort this list by applying a function to each pair of vectors in the list and returning information to sorting routine that let's it know which one is larger. To solve problems like this in Common Lisp, the sort function accepts a function as an argument. The arguments to this function are two elements of the list which is
2008 Feb 01
3
Converting a character string into an object variable
R-helpers: Assume that I want to create a series of sequentially named R objects. For example, I might want to call these objects V1, V2, V3 ... V50. To do this, I thought of some sort of looping function like: input.value <- seq(1:50) * 3 for(i in 1:50){ paste("V", i, sep="") <- input.value[i] } Of course this loop will not work since the paste function
2010 May 17
3
applying quantile to a list using values of another object as probs
Hi r-users, I have a matrix B and a list of 3x3 matrices (mylist). I want to calculate the quantiles in the list using each of the value of B as probabilities. The codes I wrote are: B <- matrix (runif(12, 0, 1), 3, 4) mylist <- lapply(mylist, function(x) {matrix (rnorm(9), 3, 3)}) for (i in 1:length(B)) { quant <- lapply (mylist, quantile, probs=B[i]) } But quant
2008 Oct 22
1
getting the "name" of an object
Hello, I'm looking for a way to get the "name" of an object when it is used within an "sapply". More precisely, with a simple example : I have a named list of objects : myList = list(a=rnorm(10),b=rnorm(10),c=rnorm(10)) I would like to create a new object from each of the components of myList using the "sapply" function, for example to get the mean of all
2010 Dec 22
2
Rails - JSON object with an array?
Hello, I''m able to create and send a JSON object like so: @mylist << { :id => item.id, :name => name.id } render :json => { :result => ''success'', :mylist => @mylist } That works great. Problem I''m having now is that I need to include users which can be 1 or users per item. @mylist << {
2012 Mar 04
1
Store vectors as values in xts time-series object
Hi R programmers, I have stumbled across what seems a very simple problem. My goal is to create a xts time series object which contains vectors as values. In other words, I try to create something like this: 2009-01-01 => c('aa', 'bb', 'dd') ... 2010-02-01 => c('mm') I have figured out parts of separately. Here's what works (new xts time-series with
2006 Jan 20
2
assign object to list
Dear all I want to generate a list like this: a <- data.frame(1:10) attr(a,'myattribute') <- 'something' b <- data.frame(11:20) attr(b,'myattribute') <- 'anything' mylist <- list(a,b) Is there a way to place the dataframes into the list giving them the attribute at the same time? I don't want to create all the dataframes in my workspace first.
2004 Nov 29
2
[BASIC] Solution of creating a sequence of object names
Dear R-users, I state that this is for beginners, so you may ignore this in order not to be irritated. By the way, "patience" is another important thing, together with "kindness", we should keep in mind when we teach students and our own children as Jim Lemon pointed out well in the context of the Socratic method. You may know that being kind does not mean giving
2015 May 04
2
Define replacement functions
Hello I tried to define replacement functions for the class "mylist". When I test them in an active R session, they work -- however, when I put them into a package, they don't. Why and how to fix? make_my_list <- function( x, y ) { return(structure(list(x, y, class="mylist"))) } mylist <- make_my_list(1:4, letters[3:7]) mylist mylist[['x']] <- 4:6
2017 Jun 15
4
is.null(mylist[1]) and is.null(mylist$a) returns different values
Hi I have a list : mylist <- list( a = NULL, b = 1, c = 2 ) > mylist[1] $a NULL > is.null(mylist[1]) [1] FALSE > is.null(mylist$a) [1] TRUE why? I need to use mylist[1]
2009 Oct 25
3
NULL elements in lists ... a nightmare
I can define a list containing NULL elements: > myList <- list("aaa",NULL,TRUE) > names(myList) <- c("first","second","third") > myList $first [1] "aaa" $second NULL $third [1] TRUE > length(myList) [1] 3 However, if I assign NULL to any of the list element then such element is deleted from the list: > myList$second <-
2005 Mar 16
8
Summing up matrices in a list
Dear all, I think that my question is very simple but I failed to solve it. I have a list which elements are matrices like this: >mylist [[1]] [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 [[2]] [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12 I'd like to create a matrix M<-mylist[[1]]+mylist[[2]] [,1] [,2] [,3] [1,] 8 12 16 [2,] 10 14 18
2001 Oct 18
2
Parsing for list components
How do I parse an identifier of a list component, e.g. mylist$mycomponent or mylist[[1]] ? Parse does not do the job, e.g. parse(text="mylist$mycomponent") returns an expression with just one term, instead of "mylist", "$", "mycomponent". What I need is a way to extract the list name (e.g. "mylist"), given an identifier of a component.
2010 Sep 04
4
Please explain "do.call" in this context, or critique to "stack this list faster"
I've been doing some consulting with students who seem to come to R from SAS. They are usually pre-occupied with do loops and it is tough to persuade them to trust R lists rather than keeping 100s of named matrices floating around. Often it happens that there is a list with lots of matrices or data frames in it and we need to "stack those together". I thought it would be a simple
2004 May 10
2
Lists and outer() like functionality?
Hi, I'm have a list of integer vectors and I want to perform an outer() like operation on the list. As an example, take the following list: mylist <- list(1:5,3:9,8:12) A simple example of the kind of thing I want to do is to find the sum of the shared numbers between each vector to give a result like: result <- array(c(15,12,0,12,42,17,0,17,50), dim=c(3,3)) Two for() loops is the
2012 Oct 26
2
deconstructing curve into rising and falling limbs
hello, I have some data that looks similar to this (only not as nice as this): Y <- c(abs(rnorm(100, 0.10, .1)), seq(.10, 1.0, .3)+rnorm(1, 0, .5) , seq(0.8, 4.0, .31)+rnorm(1, 0, .5) , seq(3.9, .20, -.2)+rnorm(1, 0, .5) , abs(rnorm(100, 0.13, .1)) , seq(.10, 1.2, .35)+rnorm(1, 0, .5) , seq(0.7, 6.0, .31)+rnorm(1, 0, .5) , seq(5.9, .23, -.18)+rnorm(1, 0, .5) , abs(rnorm(50, 0.18, .1)) )
2012 Aug 28
3
Get variable data Reading from the list
Here i have a variable MyVar <- data.frame(read.csv("D:\\Doc.csv")) And now i am storing this variable name into a list. MyList <- list() MyList [length(MyList )+1]<- "MyVar" Now what is the requirement is, i need to call the variable name "MyVar" from the list "MyList " and get the data.
2007 Jun 29
2
regexpr
Hi, I 'd like to match each member of a list to a target string, e.g. ------------------------------ mylist=c("MN","NY","FL") g=regexpr(mylist[1], "Those from MN:") if (g>0) { "On list" } ------------------------------ My question is: How to add an end-of-string symbol '$' to the to-match string? so that 'M' won't
2011 May 25
3
Accessing elements of a list
I have a list that is made of lists of varying length. I wish to create a new vector that contains the last element of each list. So far I have used sapply to determine the length of each list, but I'm stymied at the part where I index the list to make a new vector containing only the last item of each list mylist =