Re: [R] splitting a long dataframe

2012-12-26 Thread arun
Hi, You can do this either by: with(data1,aggregate(y,by=list(x),function(x) x)) #2nd column is a list here #or  res1-split(seq(nrow(data1)),data1$x) #or res1-tapply(data1$y,list(data1$x),function(x) x) res2- t(sapply(res1,`[`,1:max(sapply(res1,length

[R] 3D Gaussian with different colors

2012-12-26 Thread Roberto
I wrote, finding pieces of code in the web, a simple script to draw a 3D gaussian plot. For the next step, I need that the 2 gaussian distributions have different colors. Can someone help me to do this? fn - function(x, y, scale, scale2) dnorm(x,mean=1,sd=scale)*dnorm(y,mean=-1,sd=scale) +

Re: [R] splitting a long dataframe

2012-12-26 Thread Swagath
Dear Arun, Thanks a lot for the time and help. Cheers, Swagath On 12/26/12 6:24 AM, arun wrote: Hi, You can do this either by: with(data1,aggregate(y,by=list(x),function(x) x)) #2nd column is a list here #or res1-split(seq(nrow(data1)),data1$x) #or

[R] Change class of elements in list

2012-12-26 Thread Robin Corrià
Dear R users, I have a list of objects of type im mylist$sp1 $sp2 $sp3 and I want to convert them to a list of objects of class SpatialGridDataFrame This works for a single object of class im: a - mylist$sp1 b - as(a, SpatialGridDataFrame) Then I want to write each element in the new list as

Re: [R] data comparison

2012-12-26 Thread Rui Barradas
Hello, Try the following. # 1. idx - seq(50, 100, by = 10) mat - matrix(difMH[idx]$DIFitems, ncol = length(idx)) # 2. comp - c(1, 9, 21, 22, 25, 30, 34, 38) hit - lapply(difMH[idx], function(x) length(intersect(x$DIFitems, comp))) falarm - lapply(difMH[idx], function(x)

Re: [R] data comparison

2012-12-26 Thread Rui Barradas
Hello, Sorry, my previous post is wrong, to make of it a matrix use do.call(cbind, lapply(idx, function(i) difMH[[i]]$DIFitems)) Hope this helps, Rui Barradas Em 26-12-2012 14:44, Rui Barradas escreveu: Hello, Try the following. # 1. idx - seq(50, 100, by = 10) mat -

[R] R graphs from database

2012-12-26 Thread David Osborne
Browsing the web recently, I came across what I think is a new utility for generating an interactive, web-based R graph of data from a database. The generated graph can be manipulated by a user to choose different data, limits, etc. I would like to investigate using this with data from our

Re: [R] R graphs from database

2012-12-26 Thread Marc Schwartz
On Dec 26, 2012, at 6:34 AM, David Osborne daosbo...@gmail.com wrote: Browsing the web recently, I came across what I think is a new utility for generating an interactive, web-based R graph of data from a database. The generated graph can be manipulated by a user to choose different data,

Re: [R] R graphs from database

2012-12-26 Thread Suzen, Mehmet
Hi David, I suggest you to have a look at packages that can extract data from sql or nosql databases and graphics. CRAN task views would help: http://cran.r-project.org/web/views/Graphics.html The point is there are lots of alternatives. If you would like to use web-based visualisation d3 is

Re: [R] R graphs from database

2012-12-26 Thread Ben Bolker
David Osborne daosborne at gmail.com writes: Browsing the web recently, I came across what I think is a new utility for generating an interactive, web-based R graph of data from a database. The generated graph can be manipulated by a user to choose different data, limits, etc. I would like

Re: [R] data comparison

2012-12-26 Thread arun
Hi, Assuming the data structure is similar to this example:  

[R] Working with date

2012-12-26 Thread Ron Michael
Hi, Let say I have a date variable:  asd - as.Date(2012-01-03) asd [1] 2012-01-03 Now, I want to express this date like 3/1/2012. can somebody help me how to achieve that? Thanks, __ R-help@r-project.org mailing list

Re: [R] Working with date

2012-12-26 Thread jim holtman
try this: asd - as.Date(2012-01-03) asd [1] 2012-01-03 format(asd, format = '%m/%d/%Y') [1] 01/03/2012 On Wed, Dec 26, 2012 at 1:31 PM, Ron Michael ron_michae...@yahoo.com wrote: asd - as.Date(2012-01-03) -- Jim Holtman Data Munger Guru What is the problem that you are trying to

Re: [R] Working with date

2012-12-26 Thread jim holtman
forgot you were asking for mdy format # interchange day and month format(asd, format = '%d/%m/%Y') [1] 03/01/2012 On Wed, Dec 26, 2012 at 2:14 PM, jim holtman jholt...@gmail.com wrote: try this: asd - as.Date(2012-01-03) asd [1] 2012-01-03 format(asd, format = '%m/%d/%Y') [1]

Re: [R] Working with date

2012-12-26 Thread Jeff Newmiller
If you don't have to be finicky about leading zeros, the easy way is: as.character(asd,format=%d/%m/%Y) ?strptime If you are going to be finicky, then asdlt - as.POSIXlt(asd) with(asdlt,sprintf(%d/%d/%d,mday,mon+1,year+1900)) ?as.POSIXlt ?sprintf

Re: [R] 3D Gaussian with different colors

2012-12-26 Thread David Winsemius
On Dec 25, 2012, at 11:58 PM, Roberto wrote: I wrote, finding pieces of code in the web, a simple script to draw a 3D gaussian plot. For the next step, I need that the 2 gaussian distributions have different colors. Can someone help me to do this? fn - function(x, y, scale, scale2)

Re: [R] Working with date

2012-12-26 Thread jim holtman
you can remove the leading zeros wirh the following regular expression; gsub((^0|(/)0), \\2, format(asd, format = '%d/%m/%Y')) [1] 3/1/2012 On Wed, Dec 26, 2012 at 2:25 PM, Ron Michael ron_michae...@yahoo.com wrote: Thanks Jim for your reply. However I want 3/1/2012 not 03/01/2012 Any

Re: [R] Change class of elements in list

2012-12-26 Thread David Winsemius
On Dec 26, 2012, at 4:44 AM, Robin Corrià wrote: Dear R users, I have a list of objects of type im mylist$sp1 $sp2 $sp3 and I want to convert them to a list of objects of class SpatialGridDataFrame This works for a single object of class im: a - mylist$sp1 b - as(a,

Re: [R] Working with date

2012-12-26 Thread Ron Michael
Thanks Jim for your reply. However I want 3/1/2012 not 03/01/2012 Any idea ? Thanks - Original Message - From: jim holtman jholt...@gmail.com To: Ron Michael ron_michae...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, 27 December 2012 1:01 AM Subject: Re: [R]

Re: [R] Working with date

2012-12-26 Thread arun
HI, format(asd,%d/%m/%Y) #[1] 03/01/2012 A.K. - Original Message - From: Ron Michael ron_michae...@yahoo.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Wednesday, December 26, 2012 1:31 PM Subject: [R] Working with date Hi, Let say I have a date variable:  asd -

[R] Problem with large/small numbers in knitr

2012-12-26 Thread xiaodao
I have problems with very large numbers using knitr. In the following, my a and b are extremely small and ssrr and ssru are extremely large. Knitr delivers error messages. Scaling ssrr and ssru by 1000 resolved the problem: ssrr -ssrr/1000 ; ssru-ssru/1000 Any clue as to how I might resolve the

[R] Is there a package to output midi files for sonification of data

2012-12-26 Thread Greg Hooper
Hi, I have been using Matlab to produce midi files for sonfication and algorithmic composition projects. I would like to transfer that work into R (in which I am a total newbie) and have been looking for a package that can read and write midi files. No success so far so does anyone know of one? I

Re: [R] Is there a package to output midi files for sonification of data

2012-12-26 Thread Suzen, Mehmet
Hi Greg, you can try tuneR : http://cran.r-project.org/web/packages/tuneR/ Best, -m On 26 December 2012 22:04, Greg Hooper gregstuarthoo...@gmail.com wrote: Hi, I have been using Matlab to produce midi files for sonfication and algorithmic composition projects. I would like to transfer that

[R] sqldf merging with subset in specific range

2012-12-26 Thread Matthew Liebers
Hi all: I have two data sets. Set A includes a long list of hits in a single column, say: m$V1 10 15 36 37 38 44 45 57 61 62 69 ...and so on Set B includes just a few key ranges set up by way of a minimum in column X and a maximum in column Y. Say, n$X n$Y 30 38 # range from 30 to 38 52

Re: [R] sqldf merging with subset in specific range

2012-12-26 Thread jim holtman
Is this what you want: m - read.table(text = 10 + 15 + 36 + 37 + 38 + 44 + 45 + 57 + 61 + 62 + 69 ) n - read.table(text = 30 38 + 52 62 ) require(sqldf) sqldf(select m.V1 + from m, n + where m.V1 between n.V1 and n.V2 + ) V1 1 36 2 37 3 38 4 57 5 61 6 62 On Wed,

Re: [R] how to apply two or more functions to each columns in a time?

2012-12-26 Thread David L Carlson
Combine the functions with rbind(). If there are more than two, it will probably be easier to define the function outside sapply. dta - sapply(iris[,-5],function(x) rbind(mean(x,na.rm=T), sd(x,na.rm=T))) rownames(dta) - c(mean, SD) dta Sepal.Length Sepal.Width Petal.Length Petal.Width

Re: [R] Is there a package to output midi files for sonification of data

2012-12-26 Thread Ben Bolker
Suzen, Mehmet msuzen at gmail.com writes: Hi Greg, you can try tuneR : http://cran.r-project.org/web/packages/tuneR/ Best, -m tuneR writes Wave (.WAV?) files as output; it can also write output suitable for lilypond input -- and lilypond can write MIDI output. Bottom line, I

Re: [R] how to apply two or more functions to each columns in a time?

2012-12-26 Thread Pete Brecknock
Yao He wrote Dear All: I want to calculate the mean and sd for each column in a data.frame. Taking data(iris) for example: I tried sapply(iris[,-5],mean,na.rm=T) or sapply(iris[,-5],sd,na.rm=T) to calculate the mean and sd .But sapply() transfer a function per time. How to transfer two

Re: [R] Is there a package to output midi files for sonification of data

2012-12-26 Thread Greg Hooper
thanks Mehmet - but I can't see how to read or write midifiles from the tuneR docs. Looks primarily for wav file analysis. Am I missing something? Greg On 27 December 2012 09:49, Suzen, Mehmet msu...@gmail.com wrote: Hi Greg, you can try tuneR : http://cran.r-project.org/web/packages/tuneR/

Re: [R] R graphs from database

2012-12-26 Thread David Osborne
Thanks, Marc — yes, it was Shiny that I'd seen. Thanks a lot! regards David On 26 December 2012 16:31, Marc Schwartz marc_schwa...@me.com wrote: On Dec 26, 2012, at 6:34 AM, David Osborne daosbo...@gmail.com wrote: Browsing the web recently, I came across what I think is a new utility

[R] Converting R script to Matlab

2012-12-26 Thread Uma Shahani
Hello, I am very new to R. I have used Matlab in the past but not extensively. I would like to be able to convert an R script to Matlab. I should be grateful if you would point me towards ahelpful link to do so. Uma [[alternative HTML version deleted]]

Re: [R] how to apply two or more functions to each columns in a time?

2012-12-26 Thread arun
Hi, Try this:  sapply(iris[,-5],function(x) rbind(mean(x,na.rm=T),sd(x,na.rm=T))) # Sepal.Length Sepal.Width Petal.Length Petal.Width #[1,]    5.843   3.057 3.758000   1.199 #[2,]    0.8280661   0.4358663 1.765298   0.7622377 A.K. - Original Message - From: Yao

Re: [R] Working with date

2012-12-26 Thread arun
Hi, gsub(^\\d(.*/)\\d(.*/.*),\\1\\2,format(asd,%d/%m/%Y)) #[1] 3/1/2012 A.K. - Original Message - From: Ron Michael ron_michae...@yahoo.com To: jim holtman jholt...@gmail.com Cc: r-help@r-project.org r-help@r-project.org Sent: Wednesday, December 26, 2012 2:25 PM Subject: Re: [R]

Re: [R] Working with date

2012-12-26 Thread Jim Holtman
what happens with 25/12/2012? Sent from my iPad On Dec 26, 2012, at 20:22, arun smartpink...@yahoo.com wrote: Hi, gsub(^\\d(.*/)\\d(.*/.*),\\1\\2,format(asd,%d/%m/%Y)) #[1] 3/1/2012 A.K. - Original Message - From: Ron Michael ron_michae...@yahoo.com To: jim holtman

Re: [R] Converting R script to Matlab

2012-12-26 Thread arun
HI, Check this link http://stackoverflow.com/questions/6695105/call-r-scripts-in-matlab A.K. - Original Message - From: Uma Shahani uma.shah...@gmail.com To: R-help@r-project.org Cc: Sent: Wednesday, December 26, 2012 6:38 PM Subject: [R] Converting R script to Matlab Hello, I am

Re: [R] Renaming column names according to another dataframe

2012-12-26 Thread Heramb Gadgil
try this: colnames(df)-df_names[1:ncol(df),name] On Sun, Dec 23, 2012 at 8:41 PM, radhi radhikum...@yahoo.in wrote: Hi, I've got a dataframe having a code as column name. Addtionally I have another dataframe with a two columns (and lots of rows), the first containing the code and the second

Re: [R] how to read different files into different objects in one time?

2012-12-26 Thread Heramb Gadgil
You can try this one too. #Set the directory to a path where all the files to be read are stored TabletoRead=list.files(pattern=.txt) I_Step=unlist(lapply(TabletoRead,function(tab){ srno-ifelse(exists(srno),(1+srno),1)

Re: [R] how to get a value from a list (using paste function)?

2012-12-26 Thread Heramb Gadgil
eval(parse(text=paste0(cvtest$,lambda.rule))) I hope this works. On Wed, Dec 19, 2012 at 12:57 AM, Thomas Stewart tgs.public.m...@gmail.comwrote: Soyeon- A possible solution: get(lambda.rule,envir=list2env(cvtest)) On Tue, Dec 18, 2012 at 12:34 PM, Soyeon Kim yunni0...@gmail.com wrote:

Re: [R] Is there a package to output midi files for sonification of data

2012-12-26 Thread Greg Hooper
thanks Ben - hmm I think I will use a midi/csv utility http://www.fourmilab.ch/webtools/midicsv/ and see how that goes. Another option is http://playitbyr.org/index.html and output to Csound and from there to midi. PlayitbyR and into Csound might be something that suits your work, Csound being