Re: [R] data.frame with variable-length list

2013-03-08 Thread William Dunlap
Note that c(list(1,2,3), list(4, 5,6), list(7,8,9, 10)) is identical to list(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) You want either list(list(1,2,3), list(4,5,6), list(7,8,9,10)) # list of 3 lists of numeric scalars or list(c(1,2,3), c(4,5,6), c(7,8,9,10)) # list of 3 numeric vectors In any ca

Re: [R] data.frame with variable-length list

2013-03-08 Thread arun
Hi, You could also try:   df1<-data.frame(name=c("a","b","c"),type=c(1,2,3),rtn=as.array(list(1:3,4:6,7:10))) A.K. - Original Message - From: Kevin Zembower To: r-help@r-project.org Cc: Sent: Friday, March 8, 2013 7:49 PM Subject: [R] data.frame with variable-length list Hello, I'm

Re: [R] data.frame with variable-length list

2013-03-08 Thread arun
HI, Try this:   df<-data.frame(name=c("a","b","c"),type=c(1,2,3),rtn=do.call(cbind,list(list(1:3,4:6,7:10  str(df) #'data.frame':    3 obs. of  3 variables: # $ name: Factor w/ 3 levels "a","b","c": 1 2 3 # $ type: num  1 2 3 # $ rtn :List of 3  # ..$ : int  1 2 3   #..$ : int  4 5 6   .#.$ : i

[R] data.frame with variable-length list

2013-03-08 Thread Kevin Zembower
Hello, I'm trying to create a data frame with three columns, one of which is a variable-length list. I tried: df <- data.frame(name = c("a", "b", "c"), type=c(1, 2, 3), rtn = c(list(1,2,3), list(4, 5,6), list(7,8,9, 10) ) ) This would be useful,

Re: [R] get current plot dimensions?

2013-03-08 Thread William Dunlap
Try using the combination plot.new() ; par(new=TRUE) to advance to the next position in the layout before querying par("pin"). Be sure to actually plot something after the par(new=TRUE). E.g., > layout(matrix(c(1,2,3,4), nrow=2), width=c(1,3), height=c(1,3)) > plot.new() ; par(new=TRUE) > par("

[R] get current plot dimensions?

2013-03-08 Thread Not To Miss
Hi R users, I find par("pin") is kind of confusing (or maybe just me?). The manual said it will give " The current plot dimensions, ‘(width,height)’, in inches." The word "current" is the key here. I thought it would give the dimensions of the to-be plot, but it actually gives the dimension of the

Re: [R] R GUI frond has stopped working

2013-03-08 Thread lefelit
Hi I found the source of the problem. The R would not let me update the "survival" and "KernSmooth" package at the R/library folder. I manually delete them and then download the latest version of them to proceed with the xcms installation. I work on a window 7 computer and R 2.15.3/2/1 (all versi

Re: [R] Word Frequency for each row

2013-03-08 Thread Rui Barradas
Hello, I had thought of something like that, but I'm not sure if the match must be exact. If not, grep seems better. More complicated and slower but more flexible. Rui Barradas Em 08-03-2013 21:32, arun escreveu: Hi, You can also try: res2<-rowSums(x==word) res1<-sapply(where,length)

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread Martin Morgan
On 03/08/2013 06:01 AM, Jan van der Laan wrote: You could use the fact that scan reads the data rowwise, and the fact that arrays are stored columnwise: # generate a small example dataset exampl <- array(letters[1:25], dim=c(5,5)) write.table(exampl, file="example.dat", row.names=FALSE. col.nam

Re: [R] Word Frequency for each row

2013-03-08 Thread arun
Hi, You can also try:    res2<-rowSums(x==word) res1<-sapply(where,length) res1[]<- sapply(res1,as.numeric)  identical(res1,res2) #[1] TRUE A.K. - Original Message - From: Rui Barradas To: Sudip Chatterjee Cc: r-help@r-project.org Sent: Friday, March 8, 2013 4:26 PM Subject: Re: [R]

Re: [R] Word Frequency for each row

2013-03-08 Thread Richard M. Heiberger
This is even simpler > aaa <- matrix(c("aa", "bb", "aa", "aa", "cc", "ee"), 2, 3, dimnames=list(LETTERS[1:2], letters[3:5])) > apply(aaa == "aa", 1, sum) A B 2 1 On Fri, Mar 8, 2013 at 4:16 PM, Richard M. Heiberger wrote: > > aaa <- matrix(c("aa", "bb", "aa", "aa", "cc", "ee"), 2, 3, > dimnames

Re: [R] Word Frequency for each row

2013-03-08 Thread Rui Barradas
Hello, I'm not sure I understand, but see if the following is an example of counting occurences of a word in each row. set.seed(1855) x <- matrix(sample(LETTERS[1:5], 400, replace = TRUE), ncol = 4) word <- "A" where <- apply(x, 1, function(.x) grep(word, .x)) sapply(where, length) # count t

Re: [R] Word Frequency for each row

2013-03-08 Thread Richard M. Heiberger
> aaa <- matrix(c("aa", "bb", "aa", "aa", "cc", "ee"), 2, 3, dimnames=list(LETTERS[1:2], letters[3:5])) > aaa cde A "aa" "aa" "cc" B "bb" "aa" "ee" > apply(aaa, 1, function(x, word) sum(x==word), word="aa") A B 2 1 > On Fri, Mar 8, 2013 at 11:04 AM, Sudip Chatterjee wrote: > Hi All, > >

Re: [R] 2D filled.contour plot with 1D histograms by axes

2013-03-08 Thread David Winsemius
On Mar 8, 2013, at 9:05 AM, Jing Lu wrote: > Hi everyone, > > I hope this question is beyond "read the manual". My task is simple, just > to plot the following, but the plot in the middle should be a > filled.contour plot: > http://gallery.r-enthusiasts.com/graph/Scatterplot_with_marginal_histog

Re: [R] Zoo Data

2013-03-08 Thread arun
Hi, Try this:  z1[seq(which(time(z1)==as.POSIXct("01.01.2012 02:00:00",format="%d.%m.%Y %H:%M:%S")),which(time(z1)==as.POSIXct("01.01.2013 03:00:00",format="%d.%m.%Y %H:%M:%S"))),] #    Value1 Value2 #2012-01-01 02:00:00    4.8    5.3 #2012-02-01 02:30:00    4.9    5.2 #2012-08

[R] Passing command line arguments using parallel package

2013-03-08 Thread Bokk, Gene
Hello, I was wondering if there is a way to pass a custom command line argument to slave processes using the parallel package. I need to do this because I have some logic in my .Rprofile that checks what arguments it was called with using commandArgs() and performs certain actions only if it wa

Re: [R] Re move row.names column in dataframe

2013-03-08 Thread jeharmse
... the row.names will not interfere with any merging operation ... Row names do not interfere with merge, but they cause other problems. In the example, I want to test whether rows have the same entries (in some or all columns). identical fails because of the row names, and all( == ) can fail if

[R] 2D filled.contour plot with 1D histograms by axes

2013-03-08 Thread Jing Lu
Hi everyone, I hope this question is beyond "read the manual". My task is simple, just to plot the following, but the plot in the middle should be a filled.contour plot: http://gallery.r-enthusiasts.com/graph/Scatterplot_with_marginal_histograms_78 Background: I prefer filled.contour rather than

[R] Word Frequency for each row

2013-03-08 Thread Sudip Chatterjee
Hi All, I am wondering if there is any examples where you can count your interested "word" in each row. For an example if you have data with *'ID*' and '*write-up*' for 100 rows, how would I calculate the word frequency for each row ? Thank you for all your time. [[alternative HTML v

Re: [R] why package ZIGP is not there anymore?

2013-03-08 Thread krusty the klown
Funnily, the bivpois package is no longer available too... -- View this message in context: http://r.789695.n4.nabble.com/why-package-ZIGP-is-not-there-anymore-tp4660663p4660726.html Sent from the R help mailing list archive at Nabble.com. __ R-help@

Re: [R] Substitute value

2013-03-08 Thread arun
Hi, Using your code: sub("[.]$",".1",sim.code) #[1] "1.1234.1a.1" "1.1234.1a.2" "1.3245.2c.5" "4.6743.3c.1" "4.3254.6b.4" #[6] "3.5463.2a.1" A.K. - Original Message - From: chris201 To: r-help@r-project.org Cc: Sent: Friday, March 8, 2013 5:23 AM Subject: [R] Substitute value Hi, I h

Re: [R] horizontal yaxis label

2013-03-08 Thread krusty the klown
Yes, it works, but I wonder if I can make the y title horizontal just setting any "hidden" parameter... -- View this message in context: http://r.789695.n4.nabble.com/horizontal-yaxis-label-tp802761p4660725.html Sent from the R help mailing list archive at Nabble.com. _

[R] label the mean in bwplot and divide a panel in two plots

2013-03-08 Thread pablo.castano
Hi, I have the following bwplots, and want to add a label with the mean value at each dote. Can you give me suggestions? Also, if I wanted to add another bwplot below the first, can I use the par(mfrow=c(2,1)) function? This is my code: Code #Data x<-c('Small','Large','Large','Medium','Medium

[R] using dlmModPoly in library dlm

2013-03-08 Thread Hua Ai
Hi Group, I'm trying to build a model to predict a product's sale price. I'm researching the dlm package. Looks like I should use dlmModPoly, dlmMLE, dlmFilter, dlmSmooth, and finally dlmForecast. I'm looking at the Nile River example and I have a few questions: 1. If I only want to predic

Re: [R] Substitute value

2013-03-08 Thread arun
Hi, try this: sim.df<-data.frame(sim.code,sim.val,stringsAsFactors=FALSE) sim.df[,1][-grep("\\d+$",sim.df[,1])]<- paste(sim.df[,1][-grep("\\d+$",sim.df[,1])] , 1,sep="") sim.df #     sim.code sim.val #1 1.1234.1a.1       4 #2 1.1234.1a.2       5 #3 1.3245.2c.5       3 #4 4.6743.3c.1      

Re: [R] Zoo Data

2013-03-08 Thread arun
Hi Jakob, dat1<-read.table(text=" TIME, Value1, Value2 01.08.2011 02:30:00, 4.4, 4.7 01.09.2011 03:00:00, 4.2, 4.3 01.11.2011 01:00:00, 3.5, 4.3 01.12.2011 01:40:00, 3.4, 4.5 01.01.2012 02:00:00, 4.8, 5.3 01.02.2012 02:30:00, 4.9, 5.2 01.08.2012 02:30:00, 4.1, 4.7 01.12.2012 03:00:00, 4.

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread David Winsemius
On Mar 8, 2013, at 10:59 AM, David Winsemius wrote: > > On Mar 8, 2013, at 9:31 AM, David Winsemius wrote: > >> >> On Mar 8, 2013, at 6:01 AM, Jan van der Laan wrote: >> >>> >>> You could use the fact that scan reads the data rowwise, and the fact that >>> arrays are stored columnwise: >>>

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread David Winsemius
On Mar 8, 2013, at 9:31 AM, David Winsemius wrote: > > On Mar 8, 2013, at 6:01 AM, Jan van der Laan wrote: > >> >> You could use the fact that scan reads the data rowwise, and the fact that >> arrays are stored columnwise: >> >> # generate a small example dataset >> exampl <- array(letters[1

Re: [R] ggplot2: modifying line width and background fill color for stat_smooth()

2013-03-08 Thread Michael Friendly
On 3/8/2013 12:09 PM, John Kane wrote: donner<-read.csv("http://www.ling.upenn.edu/~joseff/data/donner.csv";) ggplot(donner, aes(AGE, NFATE, colour = GENDER))+ geom_point(position = position_jitter(height = 0.02, width = 0)) + stat_smooth(method = "glm", family = binomial, for

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread David Winsemius
On Mar 8, 2013, at 6:01 AM, Jan van der Laan wrote: > > You could use the fact that scan reads the data rowwise, and the fact that > arrays are stored columnwise: > > # generate a small example dataset > exampl <- array(letters[1:25], dim=c(5,5)) > write.table(exampl, file="example.dat", row.n

Re: [R] ggplot2: modifying line width and background fill color for stat_smooth()

2013-03-08 Thread John Kane
Is this roughly what you want? Shamelessly stolen , I mean , adapted from http://docs.ggplot2.org/0.9.3/stat_smooth.html donner<-read.csv("http://www.ling.upenn.edu/~joseff/data/donner.csv";) ggplot(donner, aes(AGE, NFATE, colour = GENDER))+ geom_point(position = position_jitter(height

[R] ggplot2: modifying line width and background fill color for stat_smooth()

2013-03-08 Thread Michael Friendly
In the example below, from http://www.ling.upenn.edu/~joseff/rstudy/summer2010_ggplot2_intro.html I'd like to make (a) the fitted line thicker and (b) change the background fill color for the confidence envelope around each fitted line to a low-alpha transparent version of the same color used fo

Re: [R] create bar chart with different totals in a bar

2013-03-08 Thread John Kane
Okay, I think I see what you want. I had though of that earlier and then decided that I was wrong. The png got through nicely. Data set dd slightly revised as we don't need that dummy x variable. dd <- structure(list(abnr2 = c(11425, 11425, 11555, 11888), time = c(2, 1, 1, 2), cat =

Re: [R] create bar chart with different totals in a bar

2013-03-08 Thread Matthias Weber
Hello together There is another try as a png file. Hope you can see it now, what i want to do with my bar chart. Your example with ggplot2 works, but it wont help to convert my data like this one: 1 2 3 4 abnr2

Re: [R] Coversion from yearly to weekly data

2013-03-08 Thread PIKAL Petr
Hi some brute force aggregate(test$Value, list(rep(1:61, each=7)[1:422]), mean) or aggregate(test$Value, list(findInterval(1:nrow(test), seq(1,422,by=7)), test$Data), mean) gives you aggregated values for each week. or lll <- split(test, test$Data) lapply(lll, function(x) aggregate(x, list(fin

Re: [R] Unexpected behaviour of apply()

2013-03-08 Thread Pierrick Bruneau
Thanks for your replies ! The lapply hack does the job in my context, so I'll stick to it (and actually in any case where I expect variable length results). About your quote from ?apply : I read it some time ago actually - but with my recent use in "variable length returning FUN", I got fooled...

Re: [R] Coversion from yearly to weekly data

2013-03-08 Thread Rui Barradas
Hello, Something like this? sp <- split(test, test$Data) res <- do.call(rbind, lapply(sp, function(x){ Week <- (seq_len(nrow(x)) %/% 7) + 1 aggregate(Value ~ Data + Week, data = x, FUN = mean)})) rownames(res) <- seq_len(nrow(res)) res Hope this helps, Rui Barradas Em 08-03-

Re: [R] multiple plots and looping assistance requested (revised codes)

2013-03-08 Thread arun
HI Irucka, The situation is slightly different here.  I was under the assumption that the list elements sometimes had one two columns or three columns.  Here, all the columns are present, but some with entire rows of missing values.  Also, there was a mistake in the code when I updated the code

Re: [R] R GUI frond has stopped working

2013-03-08 Thread PIKAL Petr
Hi Some issues: 1 do not use HTML mail 2 what OS 3 which R version 4 when and how it stopped working - exact error message (if any) 5 did you ask xcms maintainer for help? (it is not in standard CRAN packages) 6 try to send reproducible example for others to enable them to test the problem Regar

[R] Coversion from yearly to weekly data

2013-03-08 Thread Nico Met
Dear all, I have a big data matrix and I want to convert those data into weekly basis which means 7 days needs to be avaraged and aggregate a single value > dput(test) structure(list(locid = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,

Re: [R] Substitute value

2013-03-08 Thread Gabor Grothendieck
On Fri, Mar 8, 2013 at 5:23 AM, chris201 wrote: > Hi, > I have a large data frame and within this there is one column which contains > individual codes (eg. 1.1234.2a.2). I am splitting these codes into their 4 > components using strsplit (eg. "1", "1234", "2a", "2"). However there are > some in

Re: [R] Substitute value

2013-03-08 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of chris201 > Sent: Friday, March 08, 2013 11:23 AM > To: r-help@r-project.org > Subject: [R] Substitute value > > Hi, > I have a large data frame and within this there is one c

Re: [R] create bar chart with different totals in a bar

2013-03-08 Thread John Kane
https://github.com/hadley/devtools/wiki/Reproducibility Is this what your matrix looks like? mat1 <- structure(c(11425, 11425, 11555, 11888, 2, 1, 1, 2, 1, 2, 1, 2), .Dim = c(4L, 3L), .Dimnames = list(NULL, c("abnr2", "time", "cat"))) It is good practice to use dput() to supply sample data. I

[R] Creating cluster with dbscan from bigmemory

2013-03-08 Thread Tiago Cunha
I am trying to create a very big matrix with big.matrix from package big.memory in order to apply dbscan afterwards. I have two problems: I need to create 4 matrices with 12 rows X 12 columns. I have tested various R packages for big data (particularly bigmemory and ff). Since ff cannot c

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread Khan, Sohail
Perhaps you could process this with a unix/Linux utility "Awk", before reading the file into R. -Sohail From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of peter dalgaard [pda...@gmail.com] Sent: Friday, March 08, 2013 5:08 AM T

[R] Substitute value

2013-03-08 Thread chris201
Hi, I have a large data frame and within this there is one column which contains individual codes (eg. 1.1234.2a.2). I am splitting these codes into their 4 components using strsplit (eg. "1", "1234", "2a", "2"). However there are some individual codes which do not have a last component (eg. 2.43

[R] R GUI frond has stopped working

2013-03-08 Thread lefelit
Hi I have sent couple of days ago an email describing an issue in regards to R software when I use the xcms package. I haven't got any response whether my post has been made public to receive any help for other users. Is my email again treated as spam or considered as inappropriate to be publis

Re: [R] create bar chart with different totals in a bar

2013-03-08 Thread Mat
if i can sort my list as follows, i can create the bar chart. But how can i sort my list from: [,1] [,2] [,3] [,4] abnr2 11425 11425 11555 11888 TIME 21 1

[R] create bar chart with different totals in a bar

2013-03-08 Thread Mat
Hello together, perhabs anyone of you, has an ideal, how i can do this: I have a matrix, like this one: [,1] [,2] [,3] [,4] abnr2 11425 11425 11555 11888 TIME 21

[R] Generating QFs from Same Sample

2013-03-08 Thread MR Ahmad
Dear All I am kind of stuck up with a code a part of which seems to be causing a problem, or at least I think so. May be the community can help me. It’s simple but I suppose I am missing something. I generate a data matrix X, say of order n*p, where n represents independent row-vectors and p corr

Re: [R] Read Content from URL to XML format

2013-03-08 Thread John Kane
It works for me. Or at least I got something to download. What is another matter. I am just trying to learn how to do this and really don't have any good advice. Perhaps the site was down or overloaded? Any firewalls to worry about at your end? John Kane Kingston ON Canada > -Original M

Re: [R] Comparing Cox model with Competing Risk model

2013-03-08 Thread Terry Therneau
-- begin included message -- I have a competing risk data where a patient may die from either AIDS or Cancer. I want to compare the cox model for each of the event of interest with a competing risk model. In the competing risk model the cumulative incidence function is used directly. -end inclusi

Re: [R] Multivariate Power Test?

2013-03-08 Thread Michael Friendly
On 3/6/2013 11:50 PM, Charles Determan Jr wrote: Generic question... I am familiar with generic power calculations in R, however a lot of the data I primarily work with is multivariate. Is there any package/function that you would recommend to conduct such power analysis? Any recommendations wo

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread Jan van der Laan
You could use the fact that scan reads the data rowwise, and the fact that arrays are stored columnwise: # generate a small example dataset exampl <- array(letters[1:25], dim=c(5,5)) write.table(exampl, file="example.dat", row.names=FALSE. col.names=FALSE, sep="\t", quote=FALSE) # and re

Re: [R] transpose lists

2013-03-08 Thread arun
Hi, You can try: mat1<- do.call(rbind,x) lapply(seq_len(ncol(mat1)),function(i) mat1[,i]) #[[1]] #[1] 12.10  3.44 #[[2]] #[1] 0.1 3.0 #[[3]] #[1] 12.0 33.1 #[[4]] #[1]  1.1 23.0 A.K. - Original Message - From: ishi soichi To: PIKAL Petr Cc: r-help Sent: Friday, March 8, 2013 5:06 A

Re: [R] package ‘contingency.tables’ is not available (for R version 2.15.2)

2013-03-08 Thread Milan Bouchet-Valat
Le lundi 04 mars 2013 à 14:43 -0600, Joanna Papakonstantinou a écrit : > > Thank you. > I actually ended up using: > > CrossTable(mdt) > > >Cell Contents > |-| > | N | > | Chi-square contribution | > | N / Row Total | > | N

Re: [R] Ports

2013-03-08 Thread Prof Brian Ripley
On 08/03/2013 11:37, Thomas wrote: I realise this isn't exactly an R query, but does anyone know what ports I need to open in order to get the install package function working? It's blocked by our University firewall. You mean install.packages() ? It depends what you are connecting to. Most C

[R] Ports

2013-03-08 Thread Thomas
I realise this isn't exactly an R query, but does anyone know what ports I need to open in order to get the install package function working? It's blocked by our University firewall. I have been asked for the following info and I don't know where to find it or how to get it. I guess my comp

Re: [R] transpose lists

2013-03-08 Thread Jorge I Velez
One option would be x <- list(c(12.1, 0.1, 12, 1.1), c(3.44, 3, 33.1, 23)) do.call(c, apply(do.call(rbind, x), 2, list)) HTH, Jorge.- On Fri, Mar 8, 2013 at 9:06 PM, ishi soichi wrote: > Thanks. The result should be a list of lists like... > > > x > [[1]] > [1] 12.10 3.44 > > [[2]] > [1] 0.

Re: [R] transpose lists

2013-03-08 Thread ishi soichi
Thanks! Certainly they do help! ishida 2013/3/8 D. Rizopoulos > two possibilities are: > > lis <- list(c(12.1,0.1,12.0,1.1), c(3.44,3.00,33.10,23.00)) > > # 1st > m <- do.call(rbind, lis) > split(m, col(m)) > > # 2nd > lapply(seq_along(lis[[1]]), > function (i) sapply(lis, "[", i)) > > >

Re: [R] transpose lists

2013-03-08 Thread D. Rizopoulos
two possibilities are: lis <- list(c(12.1,0.1,12.0,1.1), c(3.44,3.00,33.10,23.00)) # 1st m <- do.call(rbind, lis) split(m, col(m)) # 2nd lapply(seq_along(lis[[1]]), function (i) sapply(lis, "[", i)) I hope it helps. Best, Dimitris On 3/8/2013 11:06 AM, ishi soichi wrote: > Thanks. The

Re: [R] How to transpose it in a fast way?

2013-03-08 Thread peter dalgaard
On Mar 7, 2013, at 01:18 , Yao He wrote: > Dear all: > > I have a big data file of 6 columns and 6 rows like that: > > AA AC AA AA ...AT > CC CC CT CT...TC > .. > . > > I want to transpose it and the output is a new like that > AA

Re: [R] transpose lists

2013-03-08 Thread ishi soichi
Thanks. The result should be a list of lists like... > x [[1]] [1] 12.10 3.44 [[2]] [1] 0.1 3.0 [[3]] [1] 12.0 33.1 [[4]] [1] 1.1 23.0 lapply(x, t) doesn't do the job, I think. ishida 2013/3/8 PIKAL Petr > Hi > > > -Original Message- > > From: r-help-boun...@r-project.org [mailt

Re: [R] transpose lists

2013-03-08 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of ishi soichi > Sent: Friday, March 08, 2013 10:50 AM > To: r-help > Subject: [R] transpose lists > > Can you think of a function that transposes a list like What shall be the

[R] transpose lists

2013-03-08 Thread ishi soichi
Can you think of a function that transposes a list like > x [[1]] [1] 12.1 0.1 12.0 1.1 [[2]] [1] 3.44 3.00 33.10 23.00 ? ishida [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

Re: [R] Unexpected behaviour of apply()

2013-03-08 Thread Patrick Burns
This is nice fodder for 'The R Inferno' -- thanks. As Milan said, 'which' will suffice as the function. Here is a specialized function that only returns a list and is only implemented to work with matrices. It should solve your current dilemma. applyL <- function (X, MARGIN, FUN, ...) {

Re: [R] Unexpected behaviour of apply()

2013-03-08 Thread Milan Bouchet-Valat
Le vendredi 08 mars 2013 à 09:29 +0100, Pierrick Bruneau a écrit : > Hello everyone, > > Considering the following code sample : > > > indexes <- function(vec) { > vec <- which(vec==TRUE) > return(vec) > } This is essentially which(), what did you write such a convoluted function to

[R] Unexpected behaviour of apply()

2013-03-08 Thread Pierrick Bruneau
Hello everyone, Considering the following code sample : indexes <- function(vec) { vec <- which(vec==TRUE) return(vec) } mat <- matrix(FALSE, nrow=10, ncol=10) mat[1,3] <- mat[3,1] <- TRUE Issuing apply(mat, 1, indexes) returns a 10-cell list, as expected. Now if I do: ma