Re: [R] 2 factor split and lapply

2013-12-23 Thread Onur Uncu
t; > Cheers, > Bert > > > > Bert Gunter > Genentech Nonclinical Biostatistics > (650) 467-7374 > > "Data is not information. Information is not knowledge. And knowledge > is certainly not wisdom." > H. Gilbert Welch > > > > >> On S

[R] 2 factor split and lapply

2013-12-22 Thread Onur Uncu
R Users, I have a data frame which I split using 2 factors using the split function: split(datframe, list(f=factor1, f2=factor2)); I then used lapply to get some summary statistics grouped by factor1 and factor2. I now want to change the appearance of this output. I want to get a 2 dimensional

[R] by class...

2013-12-20 Thread Onur Uncu
I used the by() function on a data.frame to get sums of the data grouped by 2 factors. The function worked however the output is in a class called 'by'. Not familiar with this class. How can I turn the output into a nice table where columns represent values of factor1, row represent values of fa

Re: [R] A function which is a sum of other functions...

2013-12-20 Thread Onur Uncu
Just wrap the above in a function with whatever options you want to > use. If you need the functions to return vectors (of the same length) > then you can still use sapply, but use rowSums, colSums, or apply on > the result instead of sum. > >> On Thu, Dec 19, 2013 at 12:05 PM,

[R] A function which is a sum of other functions...

2013-12-19 Thread Onur Uncu
Dear R Users I have a list of functions. Each function in the list is a function of single variable. I would like to create a function (of one variable) which represents the sum of all the functions in the list. So, if the functions in my list are f1(x),..,f5(x) then I would like a new functio

[R] Could R help with locating coordinates in a serial manner?

2013-02-26 Thread Onur Uncu
Dear R community, My question is not a quick fix one but it would be helpful if you have any advice for me. I have a large data set of many locations in the US and all of these locations are expressed in coordinates (longitudes and latitudes). I need a tool which returns the state that each locat

Re: [R] Constructing a list using a function...

2012-07-01 Thread Onur Uncu
Small typo in dataframe representation. It should have been the below one. Apologies. mylist $first [1] 4 $second [1] 6 On Mon, Jul 2, 2012 at 7:02 AM, Onur Uncu wrote: > Hi All > > I have a dataframe: > > myframe<-data.frame(ID=c("first","second"

[R] Constructing a list using a function...

2012-07-01 Thread Onur Uncu
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 Co

Re: [R] A basic design question for R

2012-06-16 Thread Onur Uncu
bedded Controllers)               .OO#.       .OO#.  rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > > > > > > > Onur Uncu wrote: > >>Thank you.  But isn't a data frame already a list? What is wrong with >>adding a column to the existing

Re: [R] A basic design question for R

2012-06-16 Thread Onur Uncu
e a list. or create new class which is a list > > On Jun 16, 2012 8:52 AM, "Onur Uncu" wrote: >> >> Hello R Community, >> >> I have the following design question. I have a data set that looks >> like this (shortened for the sake of example). >&g

[R] A basic design question for R

2012-06-16 Thread Onur Uncu
Hello R Community, I have the following design question. I have a data set that looks like this (shortened for the sake of example). Gender Age M 70 F 65 M 70 Each row represents a person with an age/gender combination. We could put this data into a data frame. N

Re: [R] Data.frames can not hold objects...What can be done in the following scenario?

2012-06-11 Thread Onur Uncu
tion to return vectors in order to do further > computations, you'll access those vectors by varying the list index, > > > testframe$newcolumn[[1]][[1]]  # first list, it's only vector > testframe$newcolumn[[2]][[1]]  # second list, it's only vector > > > Etc.

Re: [R] Data.frames can not hold objects...What can be done in the following scenario?

2012-06-10 Thread Onur Uncu
the following error: Error in `$<-.data.frame`(`*tmp*`, "vecss", value = c(2, 3, 4, 3, 4, 5 : replacement has 3 rows, data has 2 Thanks for the help. On Sun, Jun 10, 2012 at 12:02 PM, Duncan Murdoch wrote: > On 12-06-10 6:41 AM, Onur Uncu wrote: >> >> R-Help com

[R] Data.frames can not hold objects...What can be done in the following scenario?

2012-06-10 Thread Onur Uncu
R-Help community, I understand that data.frames can hold elements of type double, string etc but NOT objects (such as a matrix etc). This is not convenient for me in the following situation. I have a function that takes 2 inputs and returns a vector: testfun <- function (x,y) seq(x,y,1) I have a

Re: [R] Applying a function to a column of a data frame

2012-06-09 Thread Onur Uncu
or recursive/state-dependent > simulations. > > Best, > Michael > > On Sat, Jun 9, 2012 at 9:12 AM, Onur Uncu wrote: >> Apologees the novice question. Currently climbing up the learning curve of R. >> >> Suppose I have the following function and the data.frame: &g

[R] Applying a function to a column of a data frame

2012-06-09 Thread Onur Uncu
Apologees the novice question. Currently climbing up the learning curve of R. Suppose I have the following function and the data.frame: testfun<-function(x=1,y=2) x+y testframe=data.frame(col1=c(1,2),col2=c(3,4)) When evaluating testfun, I want to use the default value for y (which is 2) and fo