[R] Feature selection package for text mining

2013-03-13 Thread Venkata Satish Basva
Hi, I am doing a project on authorship attribution, where my term document matrix has around 10450 features. Can you please suggest me a package where I can find the feature selection function to reduce the dimensions. Regards, Venkata Satish Basva [[alternative HTML version deleted]]

Re: [R] Feature selection package for text mining

2013-03-13 Thread C.H.
FSelector Maybe chi-sq is a good starting point. On Wed, Mar 13, 2013 at 2:02 PM, Venkata Satish Basva venkat.satish2...@gmail.com wrote: Hi, I am doing a project on authorship attribution, where my term document matrix has around 10450 features. Can you please suggest me a package where I

[R] string split at xth position

2013-03-13 Thread Johannes Radinger
Hi, I have a vector of strings like: c(a1b1,a2b2,a1b2) which I want to spilt into two parts like: c(a1,a2,a2) and c(b1,b2,b2). So there is always a first part with a+number and a second part with b+number. Unfortunately there is no separator I could use to directly split the vectors.. Any idea

Re: [R] string split at xth position

2013-03-13 Thread Jorge I Velez
Dear Johannes, May not be the best way, but this looks like what you described: x - c(a1b1,a2b2,a1b2) x [1] a1b1 a2b2 a1b2 substr(x, 1, 2) [1] a1 a2 a1 substr(x, 3, 4) [1] b1 b2 b2 HTH, Jorge.- On Wed, Mar 13, 2013 at 7:37 PM, Johannes Radinger wrote: Hi, I have a vector of strings

Re: [R] different color indicates difference magnitude

2013-03-13 Thread Marc Girondot
On 13/03/13 10:20, meng wrote: Hi all: Is there a plot tool to use different color indicates difference magnitude of data? The plot is in the attachment. Many thanks. No sure what you want exactly as there is no attachment here. Here are an example of what can be done: x - 1:128 y -

Re: [R] Add a continuous color ramp legend to a 3d scatter plot

2013-03-13 Thread Marc Girondot
Le 12/03/13 23:43, Zhuoting Wu a écrit : I have a 3 column dataset x,y,z, and I plotted a 3d scatter plot using: cols - myColorRamp(c(topo.colors(10)),z) plot3d(x=x, y=y, z=z, col=cols) I wanted to add a legend to the 3d plot showing the color ramp. Any help will be greatly appreciated!

Re: [R] Change the Chinese/English fonts in the Lattice graphic package

2013-03-13 Thread Prof Brian Ripley
This is little to do with lattice (and 'font=2' is for base graphics: lattice is based on grid). You may well not have bold or italic Chinese fonts. Font families are set for the device. You have not followed the posting guide: it asked for 'at a minimum' information about your setup. So

Re: [R] string split at xth position

2013-03-13 Thread Johannes Radinger
Thank you Jorge! thats working perfectly... /johannes On Wed, Mar 13, 2013 at 9:45 AM, Jorge I Velez jorgeivanve...@gmail.com wrote: Dear Johannes, May not be the best way, but this looks like what you described: x - c(a1b1,a2b2,a1b2) x [1] a1b1 a2b2 a1b2 substr(x, 1, 2) [1] a1 a2 a1

Re: [R] rugarch: GARCH with Johnson Su innovations

2013-03-13 Thread Patrick Burns
You want to give returns rather than prices to the garch fitting function. Log returns are more appropriate than simple returns. Actually a negative lambda is what I would expect. Higher volatility (across time) is usually associated with lower returns. The risk premium is more likely a

[R] merge datas

2013-03-13 Thread catalin roibu
Hello all! I have a problem with R. I try to merge data like this: structure(c(2.1785, 1.868, 2.1855, 2.5175, 2.025, 2.435, 1.809, 1.628, 1.327, 1.3485, 1.4335, 2.052, 2.2465, 2.151, 1.7945, 1.79, 1.6055, 1.616, 1.633, 1.665, 2.002, 2.152, 1.736, 1.7985, 1.9155, 1.7135, 1.548, 1.568, 1.713, 2.079,

Re: [R] merge datas

2013-03-13 Thread Jorge I Velez
Dear Catalun, If I understood your description, please see ?%in% and try subset(x, names(x) %in% c(1834,1876,1901,1928,2006) ) where x is your data. HTH, Jorge.- On Wed, Mar 13, 2013 at 9:25 PM, catalin roibu wrote: Hello all! I have a problem with R. I try to merge data like this:

Re: [R] Feature selection package for text mining

2013-03-13 Thread mxkuhn
caret has recursive feature and simple feature filters. I've got some genetic algorithm code (using the GA package). CORElearn also has the relief algorithm and a lot of different measures of feature importance. Max On Mar 13, 2013, at 3:57 AM, C.H. chainsawti...@gmail.com wrote:

Re: [R] merge datas

2013-03-13 Thread Berend Hasselman
On 13-03-2013, at 11:31, Jorge I Velez jorgeivanve...@gmail.com wrote: Dear Catalun, If I understood your description, please see ?%in% and try subset(x, names(x) %in% c(1834,1876,1901,1928,2006) ) where x is your data. Or something like this x[names(x) %in% extr] where extr is

Re: [R] loading data frames and rbind them

2013-03-13 Thread A M Lavezzi
Dear Ivan and Greg, thaks a lot! sorry for late reply, both ways work fine! I have to say that maybe Greg's is a little faster (but I am working with a relatively small amount of data, approx 130 xls files) so I do not notice remarkable differences. The only suggestion I have is to add to the

[R] expression exponent labeling

2013-03-13 Thread Berry Boessenkool
Hi all, I want to label an axis with exponents, but can't get it done with expression. Any hints would be very welcome! # simulated data, somewhat similarly distributed to my real data: set.seed(12); d - rbeta(1e6, 0.2,2)*150 ; d - d[d1e-8] hist( d  , breaks=100) # now on a logarithmically

Re: [R] string split at xth position

2013-03-13 Thread arun
Hi, You could use: library(stringr) ?str_sub() lapply(2:3,function(i) if(i==2) str_sub(x,end=i) else str_sub(x,i)) #[[1]] #[1] a1 a2 a1 #[[2]] #[1] b1 b2 b2 A.K. - Original Message - From: Johannes Radinger johannesradin...@gmail.com To: r-help@r-project.org Cc: Sent: Wednesday,

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Robert Baer
R2wd (http://cran.r-project.org/web/packages/R2wd/R2wd.pdf http://cran.r-project.org/web/packages/R2wd/R2wd.pdf) might do what you want. Rob On 3/12/2013 7:02 PM, Santosh wrote: Dear Rxperts, I am aware of Sweave that generates reports into a pdf, but do know of any tools to generate to

[R] merging a dataframe or vectors

2013-03-13 Thread Al Ehan
Hi, I would like to know what is the easiest way to compile two or more set of vectors or data frame, according to their index. They are interrelated to one another by their assigned index. for example: #data set 1 abc #output: X403 X408 X410 X415 X418 X419 X420 X423 X424

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Gergely Daróczi
Just to second Jeff's answer about pandoc[1] with a minimal reproducible example, you might give a try to my pander package [2] too: library(pander) Pandoc.brew(system.file('examples/minimal.brew', package='pander'), output = tempfile(), convert = 'docx') Where the content of the minimal.brew

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Frank Harrell
The best rendering of advanced tables is done by converting from pdf to Word. See http://biostat.mc.vanderbilt.edu/SweaveConvert Frank Robert Baer wrote R2wd (http://cran.r-project.org/web/packages/R2wd/R2wd.pdf lt;http://cran.r-project.org/web/packages/R2wd/R2wd.pdfgt;) might do what you

Re: [R] Accuracy some classifiers

2013-03-13 Thread Frank Harrell
Which accuracy score are you using? If it is proportion correctly classified, that is a misleading improper scoring rule. Frank rkok wrote I am using machine learning for one researching. I am using some classifiers with 5-fold CV . I would like to know how it is possible to extract the

Re: [R] image color analysis

2013-03-13 Thread Robert Baer
On 3/13/2013 12:05 AM, ishi soichi wrote: I am not sure if I should ask this question in this list. But I'll try. Currently I am trying to analyze images using EBImage and biOps. One of the features that I need to extract from various images is the color spectrum, namely, which colors each

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Liviu Andronic
On Wed, Mar 13, 2013 at 1:02 AM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, I am aware of Sweave that generates reports into a pdf, but do know of any tools to generate to export to a MS Word document... Is there a way to use R to generate and export report/publication quality

Re: [R] expression exponent labeling

2013-03-13 Thread Gerrit Eichner
Hi, Berry, I think for(i in -8:-3) axis(1, i, substitute(10^j, list( j = i))) achieves what you want. Regards -- Gerrit On Wed, 13 Mar 2013, Berry Boessenkool wrote: Hi all, I want to label an axis with exponents, but can't get it done with expression. Any hints would be very

[R] Extract letters from a column

2013-03-13 Thread SH
Dear list: I would like to extract three letters from first and second elements in one column and make a new column. For example below, tempdf = read.table(clipboard, header=T, sep='\t') tempdf name var1 var2abb 1 Tom Cruiser16 TomCru 2 Bread Pett2

Re: [R] Extract letters from a column

2013-03-13 Thread SH
Dear Jorge, I gave me this result (below) since it defines starting from the forth letter and ending 6th letter from the first element. substr(tempdf$name, 4, 6) [1] Cr ad old I would like to have letters from first and second elements if possible. Thanks for replying, Steve On Wed, Mar

Re: [R] Extract letters from a column

2013-03-13 Thread Jorge I Velez
Dear SH, Hmmm... what about substr(tempdf$name, 4, 6)) ? HTH, Jorge.- On Thu, Mar 14, 2013 at 1:06 AM, SH empti...@gmail.com wrote: Dear list: I would like to extract three letters from first and second elements in one column and make a new column. For example below, tempdf =

Re: [R] Extract letters from a column

2013-03-13 Thread Jorge I Velez
Try substr(tempdf$abb 4, 6) --JIV On Thu, Mar 14, 2013 at 1:15 AM, SH empti...@gmail.com wrote: Dear Jorge, I gave me this result (below) since it defines starting from the forth letter and ending 6th letter from the first element. substr(tempdf$name, 4, 6) [1] Cr ad old I would

Re: [R] Extract letters from a column

2013-03-13 Thread SH
What I want to do is to extrac three letters from first and last name and to combine them to make another column 'abb'. The column 'abb' is to be a my final product. I can make column 'abb' using 'paste' function once I have two parts from the first column 'name'. Thanks, Steve On Wed, Mar

Re: [R] Extract letters from a column

2013-03-13 Thread arun
HI, tempdf-read.table(text= name,var1,var2,abb Tom Cruiser,1,6,TomCru Bread Pett,2,5,BrePet Arnold Schwiezer,3,7,ArnSch ,sep=,,header=TRUE,stringsAsFactors=FALSE)  substr(tempdf$name, 4, 6) #as some of the firstnames differ in the number of characters #[1] Cr ad old  

Re: [R] Extract letters from a column

2013-03-13 Thread Jorge I Velez
Try x - c(Tom Cruiser, Bread Pett, Arnold Schwiezer) sapply(strsplit(x, ), function(r) paste0(substr(r[1], 1, 3), substr(r[2], 1, 3))) [1] TomCru BrePet ArnSch HTH, Jorge.- On Thu, Mar 14, 2013 at 1:21 AM, SH empti...@gmail.com wrote: What I want to do is to extrac three letters from first

Re: [R] Extract letters from a column

2013-03-13 Thread Marc Schwartz
This could be done in a single step using gsub() with back references in the regex. gsub(^(.{3}).* (.{3}).*$, \\1\\2, Tom Cruise) [1] TomCru Regards, Marc Schwartz On Mar 13, 2013, at 9:21 AM, SH empti...@gmail.com wrote: What I want to do is to extrac three letters from first and last

Re: [R] Extract letters from a column

2013-03-13 Thread SH
Thank you so much, Jorge and arun!!! Both works well. Steve On Wed, Mar 13, 2013 at 10:26 AM, Jorge I Velez jorgeivanve...@gmail.com wrote: Try x - c(Tom Cruiser, Bread Pett, Arnold Schwiezer) sapply(strsplit(x, ), function(r) paste0(substr(r[1], 1, 3), substr(r[2], 1, 3))) [1] TomCru

Re: [R] Extract letters from a column

2013-03-13 Thread SH
mmm... great! Thanks a lot all of you for helps!!! Steve On Wed, Mar 13, 2013 at 10:44 AM, Marc Schwartz marc_schwa...@me.com wrote: This could be done in a single step using gsub() with back references in the regex. gsub(^(.{3}).* (.{3}).*$, \\1\\2, Tom Cruise) [1] TomCru Regards,

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

2013-03-13 Thread Yao He
Thanks for everybody's help! I learn a lot from this discuss! 2013/3/10 jim holtman jholt...@gmail.com: Did you check out the 'colbycol' package. On Fri, Mar 8, 2013 at 5:46 PM, Martin Morgan mtmor...@fhcrc.org wrote: On 03/08/2013 06:01 AM, Jan van der Laan wrote: You could use the

[R] FW: 3/13/2013 3:55:55 PM

2013-03-13 Thread Jin Minming
http://www.physioth.com/mkqrozh/njy 3/13/2013 3:55:55 PM . Jin Minming [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] How to read a *.csv file in R?

2013-03-13 Thread Maximus
Hey guys, I am dealing with this kind of data. To read the file in R I have nulled all empty fields and tried: dateBRENT BRENTchgHWWIHWWIchg Jan. 86 22,5NULL68,1-15,6 Feb.86 17 NULL64,9-21,6 Mar. 86 13,7NULL66,6-19,5 Apr.86 12,3NULL

[R] Accuracy of some classifiers

2013-03-13 Thread Nicolás Sánchez
I am using machine learning for one researching. I am using some classifiers with 5-fold CV . I would like to know how it is possible to extract the accuracy, for example, for KNN,neural networks and J48, for each one of 5-fold because when I apply CV to my classifier, I obtain the mean accuracy

Re: [R] different color indicates difference magnitude

2013-03-13 Thread meng
So strange to find the attachment is disappear. Resent again. At 2013-03-13 13:01:01,Pascal Oettli kri...@ymail.com wrote: Hi, The attachment has been deleted. Please be more specific. Regards, Pascal On 13/03/13 10:20, meng wrote: Hi all: Is there a plot tool to use different color

[R] multi-comparison of means

2013-03-13 Thread meng
Hi all: I have a question about multi-comparison. The data is in the attachment. My purpose: Compare the predicted means of the 3 methods(a,b,c) pairwisely. I have 3 ideas: #idea1 result_aov-aov(y~ method + x1 + x2) TukeyHSD(result_aov) difflwr upr p adj b-a 0.845

[R] how to set the pdflatex path

2013-03-13 Thread annoporci
Dear all, This is my first post to the mailing list. I asked this question a little while ago on stackoverflow but did not get an answer. Please allow me to ask again. I have R set up on both Windows7 and kUbuntu12 machines. On Windows, I happen to have both MikTeX and TeXlive available (and

[R] Empty cluster / segfault using vanilla kmeans with version 2.15.2

2013-03-13 Thread Dr. Detlef Groth
Hello, here is a working reproducible example which crashes R using kmeans or gives empty clusters using the nstart option with R 15.2. library(cluster) kmeans(ruspini,4) kmeans(ruspini,4,nstart=2) kmeans(ruspini,4,nstart=4) kmeans(ruspini,4,nstart=10) ?kmeans either we got empty always

Re: [R] different color indicates difference magnitude

2013-03-13 Thread Sarah Goslee
On Wed, Mar 13, 2013 at 4:13 AM, meng laomen...@163.com wrote: So strange to find the attachment is disappear. Resent again. Not strange at all. This list does not accept binary attachments, as detailed in the posting guide linked at the bottom of this and every list message. Sarah At

Re: [R] How to read a *.csv file in R?

2013-03-13 Thread Daniel Nordlund
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Maximus Sent: Wednesday, March 13, 2013 12:15 AM To: r-help@r-project.org Subject: [R] How to read a *.csv file in R? Hey guys, I am dealing with this kind of data. To read

Re: [R] ADCP data processing in R

2013-03-13 Thread Charles Berry
Janesh Devkota janesh.devkota at gmail.com writes: Hello R Users, I have ADCP (Acoustic Doppler Current Profiler) data measurements for a river and I want to process these data using R. Is there a R package to handle ADCP data ? Any suggestions are highly appreciated. Google

Re: [R] How to read a *.csv file in R?

2013-03-13 Thread peter dalgaard
On Mar 13, 2013, at 16:54 , Daniel Nordlund wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Maximus Sent: Wednesday, March 13, 2013 12:15 AM To: r-help@r-project.org Subject: [R] How to read a *.csv file in R? Hey

Re: [R] different color indicates difference magnitude

2013-03-13 Thread John Kane
The R-help list strips most attachements other than text (and perhaps pngs? ) to deduce the risk of virus or malware being recieved. You could try parking the file on something like medifire and providing a link here. John Kane Kingston ON Canada -Original Message- From:

Re: [R] How to read a *.csv file in R?

2013-03-13 Thread John Kane
If that is a text file I'd guess that the seperator is a tab. I don's see why you used NULL as R should just read in the file with NA's for empty values. You might want to try : heisenberg - read.csv(file=comprice.csv,head=TRUE,sep=\t) John Kane Kingston ON Canada -Original Message-

Re: [R] holding argument(s) fixed within lapply

2013-03-13 Thread Blaser Nello
One way is to use the do.call function. For example: ret2 - lapply(X=mylist2, FUN=do.call, what=function(...) f2(y=Y, ...)) Best, Nello -Original Message- Date: Tue, 12 Mar 2013 22:37:52 -0400 From: Benjamin Tyner bty...@gmail.com To: r-help@r-project.org Subject: Re:

Re: [R] multi-comparison of means

2013-03-13 Thread Richard M. Heiberger
Meng, What seems to be going on is that the covariates are handled very differently in TukeyHSD and in glht. Please see the interaction_average and covariate_average arguments to glht. I ran your example twice, first as you did, with the covariates after the factor. x2 is not significant if the

[R] Numeric Class to Nominal class

2013-03-13 Thread Nicolás Sánchez
Hello everybody! I have a question. I am working with R and I am loading a .txt from my computer. This file contains a set of features from patients with numerical values and the score, that determines the gravity of the disease( from 0 to 3). Due to I want to obtain a classification of my

Re: [R] Numeric Class to Nominal class

2013-03-13 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Nicolás Sánchez Sent: Wednesday, March 13, 2013 9:30 AM To: r-help@r-project.org Subject: [R] Numeric Class to Nominal class Hello everybody! I have a question. I am

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread MacQueen, Don
There's the package rtf Rich Text Format (RTF) Output I've not tried it, but the name is suggestive. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 3/12/13 5:02 PM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, I

Re: [R] different color indicates difference magnitude

2013-03-13 Thread David L Carlson
If you are just looking for a range of colors that communicate low to high values, try package RColorBrewer and look at the sequential palettes. -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread David L Carlson
Package xtable will produce html output. If you save the file and then open it with Word, you will get serviceable results. I've had better luck copying the output from xtable and pasting it into Excel. Make necessary changes and then paste the table into Word. Obviously very tedious if you are

[R] R Advanced Programming Courses by XLSolutions Corp

2013-03-13 Thread Sue Turner
Please check out XLSolutions March-Mary 2013 R Advanced Programming courses schedule Washington DC, Boston, San Francisco, Las Vegas, etc. More on website http://www.xlsolutions-corp.com/courselistlisting.aspx Ask for group discount and reserve your seat Now - Earlybird Rates. Payment due after

Re: [R] merging a dataframe or vectors

2013-03-13 Thread David Winsemius
On Mar 13, 2013, at 6:11 AM, Al Ehan wrote: Hi, I would like to know what is the easiest way to compile two or more set of vectors or data frame, according to their index. They are interrelated to one another by their assigned index. for example: #data set 1 abc #output: X403 X408

Re: [R] different color indicates difference magnitude

2013-03-13 Thread David Winsemius
On Mar 13, 2013, at 9:18 AM, John Kane wrote: The R-help list strips most attachements other than text (and perhaps pngs? ) to deduce the risk of virus or malware being recieved. More accurately the server strips all files of type that are not in the set: MIME-TEXT, pdf, png. Most mail

[R] string split at xth position

2013-03-13 Thread Keith Weintraub
Here is another way require(stringr) aaa-paste0(a, 1:20) bbb-paste0(b, 101:120) ab-paste0(aaa,bbb) ab ptrn-([ab][[:digit:]]*) unlist(str_extract_all(ab, ptrn)) Hi, I have a vector of strings like: c(a1b1,a2b2,a1b2) which I want to spilt into two parts like: c(a1,a2,a2) and

Re: [R] different color indicates difference magnitude

2013-03-13 Thread John Kane
Thanks David. The clarification helps. I had forgotten that pdfs would get through. Howeve the file got to me, I suspect because I am listed in the To line under my actual email address. I suspect that only meng and I recieved it and the rest of the list did not. John Kane Kingston ON

Re: [R] different color indicates difference magnitude

2013-03-13 Thread David Winsemius
On Mar 13, 2013, at 10:45 AM, David Winsemius wrote: On Mar 13, 2013, at 9:18 AM, John Kane wrote: The R-help list strips most attachements other than text (and perhaps pngs? ) to deduce the risk of virus or malware being recieved. More accurately the server strips all files of type

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Santosh
Dear Rxperts.. Awesome responses! Thank you so much for your responses! I think I have a 50-course meal to gobble! If you get more ideas.. Please do continue to share. Santosh On Wed, Mar 13, 2013 at 10:13 AM, David L Carlson dcarl...@tamu.edu wrote: Package xtable will produce html output.

Re: [R] string split at xth position

2013-03-13 Thread arun
Hi, If you have cases like these:  x1- c(a1b11,a10b2,a2b2,a140b31)  lapply(list(c(1,2),c(3,4)),function(i) substr(x1,i[1],i[2])) #it will not work #[[1]] #[1] a1 a1 a2 a1 #[[2]] #[1] b1 0b b2 40 let1-unique(unlist(strsplit(gsub(\\d+,,x1),)))  split(unlist(strsplit(gsub((\\w\\d+)(\\w\\d+),\\1

Re: [R] Export R generated tables and figures to MS Word

2013-03-13 Thread Greg Snow
I don't see any mention of odfWeave yet. It works with OpenOffice files. OpenOffice is a free equivalent to MS Office and can read and write Word documents. So you can create your template file in OpenOffice (or use MS word and convert to OpenOffice format, OO will read word docs, and recent

[R] Assign the number to each group of multiple rows

2013-03-13 Thread Lilia Dmitrieva
Dear R users, My data have repeating beh parameter : 1 or 2 - type of animal behavior in subsequent locations. I need to assign unique number to each sequence of locations. My data is: data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2)) attach(data) data row beh 111 2

Re: [R] Assign the number to each group of multiple rows

2013-03-13 Thread arun
Hi, Try this: data1-data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2)) data1-within(data1, {trip.id- cumsum(c(1,abs(diff(beh; Seq-ave(row,trip.id,FUN=seq)})  data1 #   row beh Seq trip.id #1    1   1   1   1 #2    2   1   2   1 #3    3   1   3   1 #4    4   2   1   2 #5    5 

Re: [R] Empty cluster / segfault using vanilla kmeans with version 2.15.2

2013-03-13 Thread Uwe Ligges
On 13.03.2013 13:45, Dr. Detlef Groth wrote: Hello, here is a working reproducible example which crashes R using kmeans or gives empty clusters using the nstart option with R 15.2. library(cluster) kmeans(ruspini,4) kmeans(ruspini,4,nstart=2) kmeans(ruspini,4,nstart=4)

Re: [R] Assign the number to each group of multiple rows

2013-03-13 Thread jim holtman
try this: data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2)) data$tripid - cumsum(c(TRUE, diff(data$beh) != 0)) data row beh tripid 11 1 1 22 1 1 33 1 1 44 2 2 55 2 2 66 2 2 77 1 3 88 1 3 99

Re: [R] Assign the number to each group of multiple rows

2013-03-13 Thread jim holtman
I forgot the 'seq': data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2)) data$tripid - cumsum(c(TRUE, diff(data$beh) != 0)) data$seq - ave(data$beh, data$tripid, FUN = function(x) seq_along(x)) data row beh tripid seq 11 1 1 1 22 1 1 2 33 1 1 3 4

Re: [R] how to convert a data.frame to tree structure object such as dendrogram

2013-03-13 Thread Bert Gunter
Here is a simpler, less clumsy version of my previous recursive R solution that I sent you privately, which I'll also cc to the list this time. It's now almost a one-liner. To avoid problems with unused factor levels, I still prefer to have character vectors not factors, as the data frame columns

[R] 2 questions about svg output

2013-03-13 Thread Ivan Zaigralin
Hi everybody :) I use R to plot things in svg format. One of the things is text, of course. I noticed that text() in svg() gets saved as path, which is unacceptable for my purposes. (Interestingly, text() in cairo_pdf() gets saved as text.) Is there a way to save text as text in svg? And

Re: [R] Assign the number to each group of multiple rows

2013-03-13 Thread Lilia Dmitrieva
Fantastic! Thank you so much On 13 March 2013 19:48, arun smartpink...@yahoo.com wrote: Hi, Try this: data1-data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2)) data1-within(data1, {trip.id- cumsum(c(1,abs(diff(beh; Seq-ave(row, trip.id,FUN=seq)}) data1 # row beh Seq trip.id

Re: [R] Assign the number to each group of multiple rows

2013-03-13 Thread Lilia Dmitrieva
This works too! Thank you. Such a relief after few days spent on trying to solve it. Lilia On 13 March 2013 19:52, jim holtman jholt...@gmail.com wrote: I forgot the 'seq': data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2)) data$tripid - cumsum(c(TRUE, diff(data$beh) != 0))

Re: [R] 2 questions about svg output

2013-03-13 Thread Paul Murrell
Hi On 14/03/13 09:52, Ivan Zaigralin wrote: Hi everybody :) I use R to plot things in svg format. One of the things is text, of course. I noticed that text() in svg() gets saved as path, which is unacceptable for my purposes. (Interestingly, text() in cairo_pdf() gets saved as text.) Is

Re: [R] expression exponent labeling

2013-03-13 Thread Peter Ehlers
On 2013-03-13 06:37, Gerrit Eichner wrote: Hi, Berry, I think for(i in -8:-3) axis(1, i, substitute(10^j, list( j = i))) achieves what you want. Regards -- Gerrit Here's another (really no different) solution: for(i in -8:-3) axis(1, i, bquote(10^.(i))) For more flexibility, if

[R] calculating column difference in a matrix

2013-03-13 Thread Pedro Mardones
Dear R users; Consider the following toy example: a - matrix(c(2,3,4,NA,NA,5,8,NA,8,NA), 5, 2) b - cbind(a,apply(a, 1, diff, na.rm = TRUE)) What I would like be able to get is: c - matrix(c(2,3,4,NA,NA,5,8,NA,8,NA,3,5,-4,8,NA), 5, 3) i.e., for each row if both values (column 1 and 2) are NA

Re: [R] calculating column difference in a matrix

2013-03-13 Thread arun
Hi, Try this: a1-a a1[rowSums(is.na(a1))==1][ is.na(a1[rowSums(is.na(a1))==1])]-0 library(matrixStats) c1- cbind(a,rowDiffs(a1))  c1 # [,1] [,2] [,3] #[1,]    2    5    3 #[2,]    3    8    5 #[3,]    4   NA   -4 #[4,]   NA    8    8 #[5,]   NA   NA   NA identical(c,c1) #[1] TRUE A.K.

[R] loop in a data.table

2013-03-13 Thread Camilo Mora
Hi everyone, I have a data.table called data with many columns which I want to group by column1 using data.table, given how fast it is. The problem with looping a data.table is that data.table does not like quotations to define the column names (e.g. col2 instead of col2). I found a way

Re: [R] Determining maximum hourly slope per day

2013-03-13 Thread Peter Ehlers
On 2013-03-12 17:10, Nathan Miller wrote: Hello, I have a challenge! I have a large dataset with three columns, date,temp, location. date is in the format %m/%d/%y %H:%M, with a temp recorded every 10 minutes. These temperatures of surface temperatures and so fluctuate during the day, heating

[R] Modifying a data frame based on a vector that contains column numbers

2013-03-13 Thread Dimitri Liakhovitski
Hello! # I have a data frame: mydf-data.frame(c1=rep(NA,5),c2=rep(NA,5),c3=rep(NA,5)) # I have an index whose length is always the same as nrow(mydf): myindex-c(1,2,3,2,1) # I need c1 to have 1s in rows 1 and 5 (based on the information in myindex) # I need c2 to have 1s in rows 2 and 4 (also

Re: [R] image color analysis

2013-03-13 Thread ishi soichi
thanks for the tips! your answer will certainly help me a lot! ishida 2013/3/13 Robert Baer rb...@atsu.edu On 3/13/2013 12:05 AM, ishi soichi wrote: I am not sure if I should ask this question in this list. But I'll try. Currently I am trying to analyze images using EBImage and biOps.

Re: [R] glm and lm can't find weights

2013-03-13 Thread Dimitri Liakhovitski
Thanks a lot, Marc! Dimitri On Mon, Mar 11, 2013 at 4:28 PM, Marc Schwartz marc_schwa...@me.com wrote: On Mar 11, 2013, at 1:46 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello, and apologies for not providing an example. However, my question is more general. I

Re: [R] loop in a data.table

2013-03-13 Thread Steve Lianoglou
Hi, On Wed, Mar 13, 2013 at 7:25 PM, Camilo Mora cm...@dal.ca wrote: Hi everyone, I have a data.table called data with many columns which I want to group by column1 using data.table, given how fast it is. The problem with looping a data.table is that data.table does not like quotations to

Re: [R] Modifying a data frame based on a vector that contains column numbers

2013-03-13 Thread William Dunlap
Try looping over columns, as in fDF - function (x, column) { stopifnot(length(dim(x))==2, all(column 0), all(column = ncol(x)), length(column) == nrow(x)) u - unique(column) tmp - split(seq_along(column), factor(column, levels = u)) for (i in seq_along(tmp)) { x[

Re: [R] Modifying a data frame based on a vector that contains column numbers

2013-03-13 Thread arun
HI, Try this:  mydf1- mydf  mydf1[]-lapply(1:3,function(i) {mydf[which(i== myindex),i]-1; mydf[,i]})  mydf1 #  c1 c2 c3 #1  1 NA NA #2 NA  1 NA #3 NA NA  1 #4 NA  1 NA #5  1 NA NA  identical(mydf1,mygoal) #[1] TRUE A.K. - Original Message - From: Dimitri Liakhovitski

Re: [R] 2 questions about svg output

2013-03-13 Thread Ivan Zaigralin
On 03/13/2013 05:16 PM, Paul Murrell wrote: On 14/03/13 09:52, Ivan Zaigralin wrote: I use R to plot things in svg format. One of the things is text, of course. I noticed that text() in svg() gets saved as path, which is unacceptable for my purposes. (Interestingly, text() in cairo_pdf()

Re: [R] reshape

2013-03-13 Thread arun
Hi Elisa, You need to check your data.  For some 'st', the data is repeated/duplicated (I am assuming, didn't check it) especially for a particular year. dat1-read.csv(elisa.csv,sep=\t) dat1$st- as.character(dat1$st)  str(dat1) #'data.frame':    506953 obs. of  5 variables: # $ st   : chr 

[R] loop in a data.table

2013-03-13 Thread Camilo Mora
I would like to clarify my previous email about using data.table. imagine the following data.frame called data: a b c d e 1 12 15 65 6 1 65 85 36 5 2 69 84 35 8 2 45 78 65 8 I want to aggregate the rows of

Re: [R] Add a continuous color ramp legend to a 3d scatter plot

2013-03-13 Thread Marc Girondot
Hi, Try this. Sincelery, Marc x - rnorm(128, 10, 2) y - rnorm(128, 10, 2) z - x+y nbcol - heat.colors(128) # standardize z to be from 1 to 128 zcol - ((z-min(z))/(max(z)-min(z)))*127+1 library(scatterplot3d) library(fields) scatterplot3d(x,y,z, pch=16,color=nbcol[zcol], grid=FALSE,

Re: [R] loop in a data.table

2013-03-13 Thread arun
Hi, May be this helps: dat1- read.table(text= a    b  c  d    e 1    12    15    65    6 1    65    85    36    5 2    69    84    35    8 2    45    78    65    8 ,sep=,header=TRUE) library(data.table)  dat2- data.table(dat1)  dat2[,head(sapply(.SD,sum)/sapply(.SD,sum)[4],-1),by=a] #