similar to: Equivalent of Mathematica's Apply

Displaying 20 results from an estimated 10000 matches similar to: "Equivalent of Mathematica's Apply"

2010 Aug 06
1
apply family functions
Hi all, I would like to flag each record in the data according to certain conditions as specified below. For example, If "Close_date" in *dat* is between ("Open" & "Close") or ("Open1" & "Close1") or ("Open2" & "Close2") in *oc, *flag the records as "Valid", otherwise "Invalid" I would like to
2010 May 14
1
Replacing double loop by apply
Dear R-users, after trying and searching a long time i have the following question. is it possible to replace to following double loop by some apply calls? ####################################################################### m1 <- data.frame(v1=factor(letters[1:5]), v2=factor(letters[2:6]), v3=factor(letters[3:7])) m2 <-
2005 May 13
1
Converting a S-plus file.
Hello all. I've got a little file which is from S-Plus. The problem is I don't own a copy of said program, and R won't read it. I wonder if there's a caritative soul here who could export the file to some other format (csv, or even excel!) and send it back to me. Thanks in advance. Juan Pablo
2008 Jun 28
2
Parallel R
Hello, The problem I'm working now requires to operate on big matrices. I've noticed that there are some packages that allows to run some commands in parallel. I've tried snow and NetWorkSpaces, without much success (they are far more slower that the normal functions) My problem is very simple, it doesn't require any communication between parallel tasks; only that it divides
2003 Apr 20
3
how to use apply with a function created by ourselfs...?
Hi. I'm a real newbie in R, so I don't know how to apply, a function created by myself... prediction<-function(a,b) { .. } to a vector... It doesn't seem to understand lapply(vector, prediction())... Anyone can help me? Thanks in advance, ana
2007 Jun 28
3
applying max elementwise to two vectors
All, Is there one liner way to obtain the max per observation for two vectors? I looked at apply and lapply but it seems that groundwork would have to be done before applying either of those. The code below does it but seems like overkill. Thanks! Dave x = rnorm(10) y = rnorm(10) ind = which(x < y) z = x z[ind] <- y[ind] ## z now contains the max's
2012 Aug 17
3
Apply a function according to factor levels.
Dear all, I have a question on applying a function to the data according to factor levels. For example, for the data below, what is the best way to apply a function to "values" according to different levels of "samples" (1,2,3,4,5)? values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180
2011 Sep 04
1
generating multiple dataset and applying function and output multiple output dataset......
Dear R experts: Here is my problem, just hard for me... I want to generate multiple datasets, then apply a function to these datasets and output corresponding output in single or multiple dataset (whatever possible)... # my example, although I need to generate a large number of variables and datasets seed <- round(runif(10)*1000000) datagen <- function(x){ set.seed(x) var <- rep(1:3,
2008 Mar 28
1
Beginner help with retrieving frequency and transforming a matrix
Hi All, Just hoping some one can give me a hand with a problem... I have a dataframe (DF) with about 5 million entries that looks something like the following: >DF ID Cl Co Brd Ind A AB AB 1 S-3 IND A BR_F BR_F01 1 0 0 2 S-3 IND A BR_F BR_F01 1 0 0 3 S-3 IND A BR_F BR_F01 1 0 0 4 S-3 IND A BR_F BR_F01 1 0 0 5 S-3 IND A BR_F BR_F01 1 0 0 6 S-3 IND A BR_F
2012 Nov 17
2
problem with "any" function
Dear R users, I have the "any" function of R  any(ind.c, ind.r, ind.sgn) all are logical factors  it works fine when any of three is true but when they are combined it doesnt work. i tried this any(ind.c, ind.r, ind.sgn,((ind.c==TRUE) & (ind.r==TRUE)), ((ind.c==TRUE) & (ind.sgn==TRUE)),((ind.r==TRUE) & (ind.sgn==TRUE)),  ((ind.c==TRUE) & (ind.r==TRUE) &
2001 Nov 28
1
Reading output from "debugfs -R stat <8>"
Hi, I'm trying to understand if my journal is fragmented. Here's some output from `debugfs -R "stat <8>" /dev/sda3`: Inode: 8 Type: regular Mode: 0600 Flags: 0x0 Generation: 0 User: 0 Group: 0 Size: 104857600 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 205016 Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x3c0442fd -- Tue Nov 27
2004 Jun 18
2
Barplots and error indicators: Some R-Code
I' ve seen that several people are looking for a function that creates a barplot with an error indicators (I was one of them myself). Maybe you will find the following code helpful (There are some examples how to use it at the end): # Creates a barplot. #bar.plot() needs a datavector for the height of bars and a error #indicator for the interval #many of the usual R parameters can be set:
2010 Feb 02
1
ggplot/time series with indicators question
Hello, I am trying to plot time-series data with certain weeks highlighted using symbols. require(ggplot2) #plotting time series data timescale <- seq(as.Date("01/01/09","%m/%d/%y"), length.out=12, by=7) data.all <- data.frame( id = c(rep('111',12),rep('222',12),rep('333',12)), week=c(timescale,timescale,timescale),
2011 Apr 29
3
why doesn't ifelse work ?
I have the following lines of code: ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)] <- 0 I never get a value of -1 for signal even though I know diff(ind , 5) is less than zero frequently. It looks like when diff(ind , 5) is less than zero, signal gets set to 0 instead of - 1. Any ideas why ? Here's some information on ind and
2018 Feb 28
1
Missed opportunity in the midend, unsigned comparison
Hi everybody, I see a missed optimization opportunity in LLVM that GCC catches and I'd love to hear community's input. Here's the original C code: 1 char arr[2]; 2 char *get(unsigned ind) { 3 if (ind >= 1) { 4 return 0; 5 } 6 return &(arr[ind]); 7 } The variable `ind` is unsigned so, based on the comparison, if it is not greater or equals to one, than it is
2009 Jun 23
1
How to exclude insignificant intercepts using "step" function
I posted this question way down at teh end of another thread realted to an error in step, but that was stupid since it really is another matter altogether. I should have posted it separately, as I have now done. The code below creates a data.frame comprising three marginally noisy surfaces. The code below (including a fix courtesy of David Winsemius that avoids a step function error through use
2008 Feb 23
1
Error in ma.svd(X, 0, 0) : 0 extent dimensions
Hi, I run a maanova analysis and found this message error: Error in ma.svd(X, 0, 0) : 0 extent dimensions I did a google search and found this: \item ma.svd: function to compute the sigular-value decomposition of a rectangular matrix by using LAPACK routines DEGSVD AND ZGESVD. \item fdr: function to calculate the adjusted P values for FDR control. I did a search for LAPACK and
2009 Jun 17
2
Re gression by groups questions
I have a large dataset grouped by a factor and I want to perform a regression on each data subset based on this factor. There are many ways to do this, posted here and elsewhere. I have tried several. However I found one method posted on the R wiki which works exactly as I want, and I like the elegance and simplicity of the solution, but I don't understand how it works. Its all in the formula
2015 Oct 22
1
(no subject)
------------------ >>>>> Henric Winell <[hidden email]> >>>>> on Wed, 21 Oct 2015 13:43:02 +0200 writes: > Den 2015-10-21 kl. 07:24, skrev Suharto Anggono Suharto Anggono via R-devel: >> Marius Hofert-4------------------------------ >>> Den 2015-10-09 kl. 12:14, skrev Martin Maechler: >>> I think so: the code above
2003 Jun 05
1
Logical vectors
Hi everybody, just a quick question that drives me crazy: Is it possible to "join" 2 logical vectors ? i.e. x<-4 ind <- 1:19200 pin <- c(0, rep(400, 48) * (1:48)) ind1<-((pin[j] + 1) <= ind) & (ind <= pin[j + 2]) ind2<-((pin[j+x] + 1) <= ind) & (ind <= pin[j+x + 2]) ind2 and ind1 give the right TRUE index #but I would like something like that