Re: [R] Counting occurences of variables in a dataframe

2012-02-11 Thread Petr Savicky
On Sat, Feb 11, 2012 at 04:05:25PM -0500, David Winsemius wrote: > > On Feb 11, 2012, at 1:17 PM, Kai Mx wrote: > > >Hi everybody, > >I have a large dataframe similar to this one: > >knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af') > >kdate <- as.Date( c('20111001', '2002

Re: [R] multiple histograms from a dataframe

2012-02-11 Thread David Winsemius
On Feb 11, 2012, at 6:25 PM, Adel ESSAFI wrote: Le 11 février 2012 02:33, David Winsemius a écrit : On Feb 10, 2012, at 7:05 PM, Adel ESSAFI wrote: Hi list I need some help for drawing some histograms I have a dataframe , say, X Y Z T I want to draw a histogram Z-T for each value o

Re: [R] how to plot a nice legend?

2012-02-11 Thread Jonas Stein
> Wrong? Nothing. You told R to put the legend at c(1,3) > so it did. If you want it elsewhere you need to specify that. > legend(-1,3, legend=c("one", "two"), inset=-1, xpd=NA) > maybe, or some other location? ok that works fine. Now i understand how to use it. If i create several plots it would

Re: [R] how to plot a nice legend?

2012-02-11 Thread Sarah Goslee
Hi, On Sat, Feb 11, 2012 at 8:07 PM, Jonas Stein wrote: >> There are various alternatives available; you can also write your own, >> by modifying the standard one. > >> Generally there are lots of possibilities for customizing within the >> standard one; e.g. y.intersp will affect the line spacin

Re: [R] how to plot a nice legend?

2012-02-11 Thread Jonas Stein
> There are various alternatives available; you can also write your own, > by modifying the standard one. > Generally there are lots of possibilities for customizing within the > standard one; e.g. y.intersp will affect the line spacing, using a > negative value for inset (together with xpd=NA)

Re: [R] Lattice 3d coordinate transformation

2012-02-11 Thread ilai
Thank you Deepayan, your answer put me on the path to SOLVED !!! Actually passing projected corners to panel.rect was the first thing I tried, but couldn't get it to work. However, panel.3dpolygon in latticeExtra did the trick. I'm posting it here for completion. require(lattice) ; require(lattic

[R] Reading data from a worksheet on the Internet

2012-02-11 Thread Nilza BARROS
Dear R-users, I have to read data from a worksheet that is available on the Internet. I have been doing this by copying the worksheet from the browser. But I would like to be able to copy the data automatically using the url command. But when using "url" command the result is the source code, I

[R] New Sex Video.#########

2012-02-11 Thread fgre
New Sex Video.. Video share http://money586.blogspot.com [[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 http://www.R-project.org/posting-gui

[R] R Parallel question

2012-02-11 Thread slbfelix
Hi All, I have a question about R parallel computing by using snowfall. How can I set the seeds on parallel workers to get the same result as sequential mode? For example: > sfSapply(c(1,1),rnorm) [1] 1.823082 -2.222052 > rnorm(2) [1] -0.5179967 -1.0807196 How to get the identical result? Th

[R] Get identical results for parallel and sequential?

2012-02-11 Thread slbfelix
Hi All, I have a question about R parallel computing by using snowfall. How can I set the seeds on parallel workers to get the same result as sequential mode? For example: > sfSapply(c(1,1),rnorm) [1] 1.823082 -2.222052 > rnorm(2) [1] -0.5179967 -1.0807196 How to get the identical res

Re: [R] Install the rugarch-package

2012-02-11 Thread liweichen0817
I have problem installing rugarch, too. I use R 2.14.1 on Mac OS X 10.7.3. When I tried to load rugauch, I got the bellowing error message: Loading required package: Rcpp Loading required package: RcppArmadillo Loading required package: numDeriv Loading required package: chron Loading required p

[R] New Sex Video.#########

2012-02-11 Thread fgre
New Sex Video.. Video share http://money586.blogspot.com [[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 http://www.R-project.org/posting-gui

[R] Using igraph: community membership of components built by decompose.graph()

2012-02-11 Thread Natalia Pobedina
Hi everyone! I would appreciate help with using decompose.graph(), community detection functions from igraph and lapply(). I have an igraph object G with vertex attribute "label" and edge attribute "weight". I want to calculate community memberships using different functions from igraph, for simp

Re: [R] Detect numerical series

2012-02-11 Thread Carl Witthoft
This was actually answered a couple times in StackOverflow. Someone and I indpendently wrote up the following function, stolen directly from the source for rle(). # extended version of rle to find all sorts of sequences # if incr=0, this is rle seqle<- function (x,incr=1) { if (!is.vecto

Re: [R] multiple histograms from a dataframe

2012-02-11 Thread Adel ESSAFI
Le 11 février 2012 02:33, David Winsemius a écrit : > > On Feb 10, 2012, at 7:05 PM, Adel ESSAFI wrote: > > Hi list >> >> >> I need some help for drawing some histograms >> >> I have a dataframe , say, >> X Y Z T >> >> I want to draw a histogram Z-T for each value of the couple (X-Y). >> When I

Re: [R] How to see a R function's code

2012-02-11 Thread Joshua Wiley
Hi, Section 2 of the R Internals manual gives you some information. Assuming you have the source code, path_to_R/src/main/names.c holds the look up table. I am pretty sure that dt is one of the do_math* group (maybe math2??) so arithmetic.c may be useful. These are all text files so you can se

Re: [R] Getting codebook data into R

2012-02-11 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of barny > Sent: Saturday, February 11, 2012 10:04 AM > To: r-help@r-project.org > Subject: Re: [R] Getting codebook data into R > > Hi Eric - after seeing the difficulty of inputtin

[R] How to see a R function's code

2012-02-11 Thread Colstat
I was wondering how do I actually see what's inside a function, say, density of t distribution, dt()? I know for some, I can type the function name inside R and the code will be displayed. But for dt(), I get > dt function (x, df, ncp, log = FALSE) { if (missing(ncp)) .Internal(dt(x,

Re: [R] colnames documentation

2012-02-11 Thread R. Michael Weylandt
Thanks Uwe. Michael 2012/2/11 Uwe Ligges : > > > On 10.02.2012 04:53, R. Michael Weylandt wrote: >> >> Consider the following in R 2.14.1 (seems to still be the case in Rdevel): >> >> x<- matrix(1:9, 3) >> colnames(x) # NULL as expected >> colnames(x, do.NULL = TRUE) # NULL -- since we didn't cha

Re: [R] obtaining a true/false vector with combination of strsplit, length, unlist,

2012-02-11 Thread Phil Spector
It sounds like the problem boils down to counting the number of "_"s in the WELLID variable, and seeing if there are two: nchar(gsub('[^_]','',edm$WELLID)) == 2 [1] FALSE FALSE TRUE TRUE TRUE TRUE FALSE - Phil Spector

Re: [R] obtaining a true/false vector with combination of strsplit, length, unlist,

2012-02-11 Thread Sarah Goslee
You are so very close: > sapply(edm[,1], function(x)length(strsplit(as.character(x), "_")[[1]]) == 3) [1] FALSE FALSE TRUE TRUE TRUE TRUE FALSE Thanks for providing a small reproducible example. dput() tends to work better for than than textConnection(), because many email clients add arbitrar

[R] obtaining a true/false vector with combination of strsplit, length, unlist,

2012-02-11 Thread emorway
Hi, A pared down version of the dataset I'm working with: edm<-read.table(textConnection("WELLIDX_GRID Y_GRID LAYER ROW COLUMN SPECIES CALCULATED OBSERVED w301_3 4428. 1389 2 6 18 1 3558 6490. w304_12 4836. 6627 2 27 20

Re: [R] Counting occurences of variables in a dataframe

2012-02-11 Thread David Winsemius
On Feb 11, 2012, at 1:17 PM, Kai Mx wrote: Hi everybody, I have a large dataframe similar to this one: knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af') kdate <- as.Date( c('20111001', '2002', '20101001', '20100315', '20101201', '20110105', '20101001', '20110504', '20110

[R] AMOVA error: 'bin' must be numeric or a factor

2012-02-11 Thread Hanne Ballestad
Hi! I am trying to analyse my data using amova (http://www.oga-lab.net/RGM2/func.php?rd_id=pegas:amova): My input to R is a DNA sequence file, format=fasta dna<- read.dna("XX.fasta", format="fasta") #left other options as default d<- dist.dna(dna, model="raw") g<- read.table

Re: [R] Getting codebook data into R

2012-02-11 Thread barny
Hi Eric - after seeing the difficulty of inputting this kind of data into R I decided to use your method. It was rather painless using PSPP to do what I wanted - however, how do I now create an SPSS file and then use the memisc package to read it in? -- View this message in context: http://r.7896

Re: [R] Package ICSNP

2012-02-11 Thread Uwe Ligges
On 10.02.2012 04:44, David Winsemius wrote: On Feb 9, 2012, at 9:44 PM, David Winsemius wrote: On Feb 9, 2012, at 5:37 PM, Miho Morimoto wrote: install.packages("ICSNP") --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://www

Re: [R] colnames documentation

2012-02-11 Thread Uwe Ligges
On 10.02.2012 04:53, R. Michael Weylandt wrote: Consider the following in R 2.14.1 (seems to still be the case in Rdevel): x<- matrix(1:9, 3) colnames(x) # NULL as expected colnames(x, do.NULL = TRUE) # NULL -- since we didn't change the default colnames(x, do.NULL = FALSE) # "col1" "col2" "co

Re: [R] Counting occurences of variables in a dataframe

2012-02-11 Thread Petr Savicky
On Sat, Feb 11, 2012 at 07:17:54PM +0100, Kai Mx wrote: > Hi everybody, > I have a large dataframe similar to this one: > knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af') > kdate <- as.Date( c('20111001', '2002', '20101001', '20100315', > '20101201', '20110105', '20101001',

Re: [R] debug in a loop

2012-02-11 Thread Duncan Murdoch
On 12-02-10 12:48 PM, Justin Haynes wrote: You can add if(is.na(tab[i])) browser() or if(is.na(tab[i])) break see inline You can also do this temporarily. Supposing that you used source("foo.R") to enter a function with that code in it, and you want the check on line 10, you'd enter se

Re: [R] Counting occurences of variables in a dataframe

2012-02-11 Thread Tal Galili
Hello Kai This looks like a fun question. Here is my solution, I'd be curious to see solutions by other people here. It can also be tweaked in various ways, and easily put into a function (actually, if you do it - please put it back online :) ) The only thing that might require some work is the r

Re: [R] Bug with memory allocation when loading Rdata files iteratively?

2012-02-11 Thread Uwe Ligges
On 10.02.2012 01:56, Janko Thyson wrote: Dear list, when iterating over a set of Rdata files that are loaded, analyzed and then removed from memory again, I experience a *significant* increase in an R process' memory consumption (killing the process eventually). It just seems like removing th

Re: [R] How to properly build model matrices

2012-02-11 Thread Uwe Ligges
On 09.02.2012 22:39, Yang Zhang wrote: I always bump into a few (very minor) problems when building model matrices with e.g.: train = model.matrix(label~., read.csv('train.csv')) target = model.matrix(label~., read.csv('target.csv')) (1) The two may have different factor levels, yielding diff

Re: [R] updating one's own package

2012-02-11 Thread Uwe Ligges
On 11.02.2012 13:49, Wet Bell Diver wrote: Win7 x64, R2.14.1 Dear list, I would like to get into the habbit of creating a package for each project. That way I can package my project-specific functions and data together and load or unload that at will. Also, it will allow easy navigation throu

Re: [R] Rpart and splitting criteria

2012-02-11 Thread Uwe Ligges
On 10.02.2012 10:37, MYRIAM TABASSO wrote: Dear All, I have questions about the function "rpart" to construct a regression tree in R code. My problem is how to change the splitting criteria. In the "rpart" we have : parms=list(split="..") , I ask you if in this command is it possible to u

[R] Counting occurences of variables in a dataframe

2012-02-11 Thread Kai Mx
Hi everybody, I have a large dataframe similar to this one: knames <-c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af') kdate <- as.Date( c('20111001', '2002', '20101001', '20100315', '20101201', '20110105', '20101001', '20110504', '20110603', '20110201'), format="%Y%m%d") kdata <- da

[R] Embed R code in online database

2012-02-11 Thread Jokel Meyer
Dear R-List! I would like to embed R code in an online database such as i.e. a google spreadsheet in way that users can add data to the database and that R's calculations are updated automatically and i.e. given out in the spreadsheet. Maybe even graphs could be updated online? Is there a way to i

Re: [R] Derive pattern from vector

2012-02-11 Thread syrvn
fantastic. Thanks for that chunk of code. Works great! :) -- View this message in context: http://r.789695.n4.nabble.com/Derive-pattern-from-vector-tp4379312p4379402.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

Re: [R] Derive pattern from vector

2012-02-11 Thread Petr Savicky
On Sat, Feb 11, 2012 at 09:11:12AM -0800, syrvn wrote: > Hello, > > consider the following vector 'chars': > > > chars <- c(A, B, C, C, D, E, E, E, F, F, F) > > > I need to convert 'chars' into the following pattern: > > > 1, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8 > > As soon as there are duplicates

[R] Derive pattern from vector

2012-02-11 Thread syrvn
Hello, consider the following vector 'chars': chars <- c(A, B, C, C, D, E, E, E, F, F, F) I need to convert 'chars' into the following pattern: 1, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8 As soon as there are duplicates they get the same number otherwise it's increasing numbers. However, for the char

Re: [R] passing an extra argument to an S3 generic

2012-02-11 Thread ilai
You are setting a new class ("inflmlm") at the end of mlm.influence. Remove that second to last line and enjoy your new S3 method. I'm not sure, but I think it is just the new class "inflmlm" applied to inf in the formals of hatvalues.mlm confused the dispatch mechanism. You would think the error

[R] object not found - Can not figure out why I get this error: Error in NROW(yCoordinatesOfLines) : object 'low' not found

2012-02-11 Thread Samo Pahor
Hi, I have been using R for over a year now. I am a very happy user. Thank you for making this happen. This is my first question to this list. I trying to add some functions to quantmod that would enable me to draw arbitrary lines and text and make sure they are redrawn. I have created following

Re: [R] Need to aggregate large dataset by week...

2012-02-11 Thread John Kane
If I understand what you want here are two possible ways to approach the problem. One uses aggregate and one uses the reshape package to melt and cast the data into the form you want. To use reshape you need to install the reshape package. Assuming your dataset is named xx aggregate(xx, by=li

Re: [R] naiveBayes: slow predict, weird results

2012-02-11 Thread Uwe Ligges
We don't have the data, but my guess is that you want to have some factors in your data that were integers when you tried the code below. Uwe Ligges On 10.02.2012 03:43, Sam Steingold wrote: I did this: nb<- naiveBayes(users, platform) pl<- predict(nb,users) nrow(users) ==> 314781 ncol(users

Re: [R] Detect numerical series

2012-02-11 Thread syrvn
That's great code. Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Detect-numerical-series-tp4379088p4379133.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.et

Re: [R] Detect numerical series

2012-02-11 Thread David Winsemius
On Feb 11, 2012, at 10:01 AM, syrvn wrote: Hello, I am struggling with detecting successive digits in a numerical series vector. Here is an example: vec <- c(1, 15, 26, 29, 30, 31, 37, 40, 41) I want to be able to detect 29, 30, 31 and 40, 41. Then, I would like to delete the successive di

[R] Detect numerical series

2012-02-11 Thread syrvn
Hello, I am struggling with detecting successive digits in a numerical series vector. Here is an example: vec <- c(1, 15, 26, 29, 30, 31, 37, 40, 41) I want to be able to detect 29, 30, 31 and 40, 41. Then, I would like to delete the successive digits from the vector. 1, 15, 26, 29, 37, 40

[R] How to solve long tick labels (axis.text.x)

2012-02-11 Thread vd3000
Hi, all, I am a newbie for [r]. I am currently trying to learn this example. /http://learnr.wordpress.com/2009/03/17/ggplot2-barplots// /http://learnr.wordpress.com/2009/03/17/ggplot2-barplots/ / After I made a drawing /c <- b + facet_grid(Region ~ .) + opts(legend.position = "none") / If

Re: [R] Lattice 3d coordinate transformation

2012-02-11 Thread Deepayan Sarkar
On Fri, Feb 10, 2012 at 12:43 AM, ilai wrote: > Hello List! > I asked this before (with no solution), but maybe this time... I'm > trying to project a surface to the XY under a 3d cloud using lattice. > I can project contour lines following the code for fig 13.7 in > Deepayan Sarkar's "Lattice, Mu

Re: [R] best option for big 3D arrays?

2012-02-11 Thread Duncan Murdoch
On 12-02-10 9:12 AM, Djordje Bajic wrote: Hi all, I am trying to fill a 904x904x904 array, but at some point of the loop R states that the 5.5Gb sized vector is too big to allocate. I have looked at packages such as "bigmemory", but I need help to decide which is the best way to store such an ob

[R] updating one's own package

2012-02-11 Thread Wet Bell Diver
Win7 x64, R2.14.1 Dear list, I would like to get into the habbit of creating a package for each project. That way I can package my project-specific functions and data together and load or unload that at will. Also, it will allow easy navigation through all the functions I will have available

Re: [R] how to plot a nice legend?

2012-02-11 Thread Duncan Murdoch
On 12-02-10 3:45 PM, Jonas Stein wrote: i'd like to plot a legend in my diagram. The diagram will be included in a TikZ LaTeX document later. I tried the legend() function, but - it can not find a good place it self where the legend fits and playing around with coordinates and scaling consume

Re: [R] fixed effects with clustered standard errors

2012-02-11 Thread Francesco
Dear Giovanni, I recalled the procedure and here is the output : Erreur : impossible d'allouer un vecteur de taille 39.2 Mo De plus : Messages d'avis : 1: In structure(list(message = as.character(message), call = call), : Reached total allocation of 12279Mb: see help(memory.size) 2: In structu

[R] how to plot a nice legend?

2012-02-11 Thread Jonas Stein
i'd like to plot a legend in my diagram. The diagram will be included in a TikZ LaTeX document later. I tried the legend() function, but - it can not find a good place it self where the legend fits and playing around with coordinates and scaling consumes a lot time - standard settings for the

Re: [R] Constraint on one of parameters.

2012-02-11 Thread Petr Savicky
On Fri, Feb 10, 2012 at 11:40:57PM -0600, FU-WEN LIANG wrote: > Thanks for your suggestion. > I did read the manual but it seems those examples set boundaries for every > parameter. I have no idea how to set bound for only one parameter(in my > case, only for theta[21]). I tried adding > "method='L

Re: [R] Find interval between numbers in list or vector

2012-02-11 Thread alend
Thanks, it is exactly the function that I needed. -- View this message in context: http://r.789695.n4.nabble.com/Find-interval-between-numbers-in-list-or-vector-tp4376115p4378473.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r

Re: [R] Schwefel Function Optimization

2012-02-11 Thread Hans W Borchers
Vartanian, Ara indiana.edu> writes: > All, > > I am looking for an optimization library that does well on something as > chaotic as the Schwefel function: > > schwefel <- function(x) sum(-x * sin(sqrt(abs(x > > With these guys, not much luck: > > > optim(c(1,1), schwefel)$value > [1] -7.

Re: [R] Constraint on one of parameters.

2012-02-11 Thread FU-WEN LIANG
Thanks for your suggestion. I did read the manual but it seems those examples set boundaries for every parameter. I have no idea how to set bound for only one parameter(in my case, only for theta[21]). I tried adding "method='L-BFGS-B',lower=c(rep(inf,20),-1),upper=c(rep(inf,20),1)", but got this e

[R] Combining two or more KML files in R

2012-02-11 Thread z2.0
Wanted to post an exchange with Roger Bivand on combining KML files. I had hoped to combine multiple KML files into a single SpatialPolygonsDataFrame. I used readOGR to bring files into R; had I worked with .shp files, I might've used readShapePoly and a unique IDvar. SPRbind construction would h