similar to: Splitting a set of vectors in a list

Displaying 20 results from an estimated 4000 matches similar to: "Splitting a set of vectors in a list"

2011 Aug 15
1
ggplot in a function confusion!
Whats going on here? df<-data.frame(x=1:10,y=1:10) ggplot()+geom_point(data=df,aes(x=x,y=y)) ## this is the normal usage right? ggplot()+geom_point(data=df,aes(x=df[,1],y=df[,2])) ## but I can also feed it column indices ggplot()+geom_point(aes(x=df[,'x'],y=df[,'y'])) ## or column names. ## but if i wrap it in a function... plot.func.one<-function(dff,x.var,y.var){
2011 Jun 07
1
variable selection in linear regression
Hello With due respect, have a nice time. I would like to ask some command in R. It is regarding variable selection in linear regression. In R, there is one rebuild function called "step" which selecting variables according to AIC. let say i have data [y, x1,x2,x3,x4] we start with y~b0 i compute the partial F test and choose the variable with maximum partial F to enter the
2004 Feb 11
6
lapply and dynamically linked functions
Hi all, I'm trying to use lapply on a list with the following command: out<-lapply(mylist,myfun,par1=p,par2=d) (1) where myfun<-function(x,par1,par1) {.....} (2) now this function is in fact a wrapper for some Fortran code I have written so I think this might be the problem. When I call lapply() as in (1) I get the following message: Error in get(x,
2012 Jul 02
2
Constructing a list using a function...
Hi All I have a dataframe: myframe<-data.frame(ID=c("first","second"),x=c(1,2),y=c(3,4)) And I have a function myfun: myfun<-function(x,y) x+y I would like to write a function myfun2 that takes myframe and myfun as parameters and returns a list as below: mylist $first [1] 4 $second [2] 6 Could you please help me with this? Doesn't seem like the
2008 Mar 24
1
How to assign multiple return values
Hi, I am moving from MATLAB, where one can easily assign a number of output values from a function like this: [x,y] = myfun(a,b) Then variables x and y can be directly used in the caller workspace. I understand that R functions return a single argument, which could be a list. This in a way makes it possible to return multiple values with a single function call, but accessing the list variables
2005 Nov 12
2
sibling list element reference during list definition
Can the value of a list element be referenced from a sibling list element during list creation without the use of a temporary variable? The following doesn't work but it's the general idea. > list(value = 2, plusplus = $value+1) such that the following would be the output from str() List of 2 $ value : num 2 $ plusplus: num 3
2009 May 13
1
Overlaying two plots
Hi useR's, I want to overlay an image plot over a world map and I can do it, but just not the way I need to do it. Here is the code I am using (with data file attached) to create my baseline map: library(sp) load("TM_WORLD_BORDERS_SIMPL-0.2.RData") par(bty="l") plot(wrld_simpl, axes = TRUE, ylim = c(-90, 90), xlim=c(-180, 180), asp=1.5) lim <- par("usr")
2006 Mar 30
3
access list component names with lapply
I have a question regarding accessing the names of list components when applying a function with lapply. Here is an example that demonstrates what I'd like to do. I have a list like this one: mylist <- list(a=letters[1:10], b=letters[10:1], c=letters[1:3]) Now I would like to append the names of the list components to their corresponding vectors with the c() function. I thought this
2011 Mar 29
3
Reversing order of vector
Dear R helpers Suppose I have a vector as vect1 = as.character(c("ABC", "XYZ", "LMN", "DEF")) > vect1 [1] "ABC" "XYZ" "LMN" "DEF" I want to reverse the order of this vector as vect2 = c("DEF", "LMN", "XYZ", "ABC") Kindly guide Regards Vincy [[alternative HTML
2008 Nov 18
4
How do I generate multiple (similar) objects within R?
Hi, I wonder if anyone knows how to generate a list of objects, e.g. ten vectors with names: vect1, vect2, ... , vect10. My own idea was to use something like: for (i in 1:10) print(paste("vect", i,"<-NULL",sep="")) but the result is: "vect1<-NULL" ... "vect10<-NULL" and not vect1<-NULL ... vect10<-NULL as I would
2006 Jul 04
1
Problems when computing the 1rst derivative of mixtures of densities
Hi everybody, I am currently working on mixtures of two densities ( f(xi,teta)= (1-teta)*f1(xi) + teta*f2(xi) ), particularly on the behavior of the variance for teta=0 (so sample only comes from the first distribution). To determine the maximum likelihood estimator I use the Newton-Rapdon Iteration. But when computing the first derivative I get a none linear function (with several asymptotes)
2009 Nov 24
4
Method
Hello, i would like to ask you another question. Is exist anymethod to vectors that tells me the last element?That is to say,I have a vector, I want to return the position of last element. I hope having explained. A greeting, Ignacio. -- View this message in context: http://old.nabble.com/Method-tp26493442p26493442.html Sent from the R help mailing list archive at Nabble.com.
2011 Jul 28
0
_: how to replace values in x by means in subgroups created in ...(not loops)
Re:_: how to replace values in x by means in subgroups created in ...(not loops) Thanks, below some code and reply: #_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_# #------------------------------------------------------- # my slow function with loops: # replace_x_by_locallyMean_x_4_0s_in_y.f(x,y) #-------------------------------------------------------
2010 Sep 14
4
Problems with "pdf" device using "plot" "glht" function on "multcomp" library.
Hi R users: I have de following data frame (called "Sx") Descripcion Nitratos Cont85g 72.40 Cont85g 100.50 Cont85g 138.30 Cont80g 178.33 Cont80g 79.01 Cont80g 74.16 Cont75g 23.70 Cont75g 15.80 Cont75g 16.20 Patron80g
2009 Nov 25
0
Possible bug in "unsplit" (PR#14084)
Dear R-bug-people I have encountered a problem with "unsplit", which I believe may be caused by a bug in the function. However, unexpericend with bug-reports I apologise if this is barely a user problem rather than a problem within R. The problem occurs if an object is split by several grouping factors with levels not occuring in the data, and using drop = TRUE. This may appear as
2010 May 20
6
writing function
Dear group, I am trying to write functions, but as a beginner, everything is not so obvious. Let's say I want the results in a list of elemts like this : tot1, tot2, etc Here is a function: toto <- function(x,y) { for(i in x:y){ paste(c("tot",i),collapse="")<-(i*2) } } If I type this : >toto(1,5) I get this message error: Error in paste(c("tot",
2008 Apr 01
4
NEW: Sociolects in R
The R translation teams have done a great job in making R usable for people who do not have English as their mother tongue. However, even within English speaking countries, there are groups which have trouble with the language, and it may be valuable to support the Sociolects of these groups too. Thanks to a generous contribution from Lars Polifo, these features will be made available in an
2010 Apr 30
1
read.csv and blank character in object name of my data.frame
Dear group, Here is my data frame: position100415 <- structure(list(DESCRIPTION = structure(1:9, .Label = c(" SUGAR NO.11 Jul/10 ", " SUGAR NO.11 May/10 ", "CORN May/10 ", "COTTON NO.2 Jul/10 ", "CRUDE OIL miNY May/10 ", "ROBUSTA COFFEE (10) Jul/10 ", "SILVER May/10 ", "SOYBEANS Jul/10 ", "WHEAT May/10
2005 Jul 07
2
randomForest
> From: Weiwei Shi > > it works. > thanks, > > but: (just curious) > why i tried previously and i got > > > is.vector(sample.size) > [1] TRUE Because a list is also a vector: > a <- c(list(1), list(2)) > a [[1]] [1] 1 [[2]] [1] 2 > is.vector(a) [1] TRUE > is.numeric(a) [1] FALSE Actually, the way I initialize a list of known length is by
2000 Mar 13
0
listing shares
I don't know what I have changed, NT does not list the shares anymore!! I can access them by directly connecting to \\SERVER\share but cannot browse them!! Win98 does just fine! Which option is the problem?? Here's a snipped of my config: [global] keep alive = 30 log file = /var/log/smbd.log lock directory = /var/lock/samba bind interfaces only = yes interfaces = eth0 interfaces =