[R] Parallel Scan of Large File

2010-12-07 Thread Ryan Garner
Is it possible to parallel scan a large file into a character vector in 1M chunks using scan() with the "doMC" package? Furthermore, can I specify the tasks for each child? i.e. I'm working on a Linux box with 8 cores and would like to scan in 8M records at time (all 8 cores scan 1M records at a

Re: [R] Summing up Non-numeric column

2010-12-07 Thread zhiji19
Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Summing-up-Non-numeric-column-tp3077710p3077733.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] Summing up Non-numeric column

2010-12-07 Thread Bill.Venables
?unique -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of zhiji19 Sent: Wednesday, 8 December 2010 2:57 PM To: r-help@r-project.org Subject: [R] Summing up Non-numeric column Dear All If I have the following dataset V1 V2 x y y

Re: [R] Summing up Non-numeric column

2010-12-07 Thread Jorge Ivan Velez
Hi, One way would be > example <- read.table(textConnection("V1 V2 + x y + y x + z b + a c + b j + d l + c o"), header = TRUE) > closeAllConnections() > example V1 V2 1 x y 2 y x 3 z b 4 a c 5 b j 6 d l 7 c o > with(example, length(unique(V1))) [1] 7 > with(example,

Re: [R] Statistical Analysis with R Beginner's Guide Book

2010-12-07 Thread John M. Quick
Hi Mike, The book makes use of .csv files, which are provided, along with all R code and .RData files. You have an interesting thought about people pulling data from diverse sources and making everyday use of R. For this, I would suggest using Excel or Google Docs Spreadsheets to compile and o

Re: [R] Newbie - want to view code for a function

2010-12-07 Thread Bill.Venables
For a substantial calculation like this the algorithms will likely be in C or Fortran. You will need to download the source for the stats package from CRAN (as a tar.gz file), expand it, and look at the source code in the appropriate sub-directories. You can get a bit of a road map in R by >

[R] Summing up Non-numeric column

2010-12-07 Thread zhiji19
Dear All If I have the following dataset V1 V2 x y y x z b a c b j d l c o How do I use R command to get the total number of different letter in column "V1" column "V1" has 7 different letters. Thank you -- View this message in context: http://r.789695.n4.nabble.com/Summing-up-

[R] Newbie - want to view code for a function

2010-12-07 Thread Dick Knox
Brand new to R Want to understand the algorithm used in yule-walker time series autoregression model I assume there is a way to see the source for ar.yw I also assume that everybody except me knows how Could someone suggest to me how to find out I've looked thru some of the documenttion - th

Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed

2010-12-07 Thread Bill.Venables
A new fortune is born? "Sharing LaTeX documents with people using word processors only is no more difficult than giving driving directions to someone who is blindfolded and has all 4 limbs tied behind their back. Collaboration with people who insist on using programs that process their words m

Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed

2010-12-07 Thread Erik Iverson
On 12/07/2010 05:29 PM, Paul Miller wrote: Hello Everyone, Been learning R over the past several months. Read several books and have learned a great deal about data manipulation, statistical analysis, and graphics. Now I want to learn how to make nice looking documents and about "literate progr

Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed

2010-12-07 Thread Greg Snow
See inline below > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Paul Miller > Sent: Tuesday, December 07, 2010 4:29 PM > To: r-help@r-project.org > Subject: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed > > Hello Everyo

Re: [R] getting R to download data

2010-12-07 Thread Greg Snow
If you don't want to use the OS (windows does have a scheduling service) then I would suggest using the tools in tcltk and possibly tcltk2 (tclTaskSchedule). They can have a delayed thing in the background so you can still use the R console, but the download will happen automatically. -- Greg

Re: [R] no graphics windows

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 9:07 PM, Carolyn Fitzsimmons wrote: I've downloaded R and started going through Appendix A in the R- intro manual. When I use the plox command I expect to see a graphics window, but there is none. I've searched the help archives and found that it might go to a ps file? C

Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed

2010-12-07 Thread Yihui Xie
For the GUI-addicted people (partly including me), I think LyX + Sweave is an excellent choice. LyX is based on LaTeX; it can do almost anything that LaTeX can do, and it takes care of a lot of details when compiling a LaTeX document. The solution for embedding Sweave in LyX has been there for a lo

Re: [R] latex() hangs R console

2010-12-07 Thread Yihui Xie
I guess I know the answer but I am not completely clear about the reason; print.latex() calls show.dvi() to open the DVI file using system(), and under Windows it is usually better using shell() instead of system(). The help page says shell() is a "friendly" wrapper of system() under Windows, and t

[R] no graphics windows

2010-12-07 Thread Carolyn Fitzsimmons
I've downloaded R and started going through Appendix A in the R-intro manual. When I use the plox command I expect to see a graphics window, but there is none. I've searched the help archives and found that it might go to a ps file? Can someone help me get the graphics window working? Kind Rega

Re: [R] latex() hangs R console

2010-12-07 Thread Dennis Murphy
Hi: I've experienced the same behavior as Dr. Friendly when trying to use latex() in an Sweave code chunk (with results = tex in the chunk header) on a Win7 system with 64-bit R (everything up to date). Is the answer the same in that case? TIA for your assistance, Dennis On Tue, Dec 7, 2010 at 9

Re: [R] Help on loops

2010-12-07 Thread jim holtman
use split and lapply to make it easier. Substitute in your own calculations since this is just an example: > x id t X1 X2 1 1 1 4 3 2 1 2 9 2 3 1 3 7 3 4 1 4 6 6 5 2 1 6 4 6 2 2 5 3 7 2 3 1 1 8 3 1 9 6 9 3 2 5 5 > # first split the data by 'id' > x.s <- split(x, x$id)

Re: [R] Downloading a .csv through a .jsp url with variable parameters - R code or package?

2010-12-07 Thread Arsenio Staer
Jim, Thanks a lot! works perfectly! now i just use a for loop and rbind to create one dataset with all daily observations. Arsenio -- View this message in context: http://r.789695.n4.nabble.com/Downloading-a-csv-through-a-jsp-url-with-variable-parameters-R-code-or-package-tp3070541p3077565.htm

[R] Error in eval.with.vis(expr, envir, enclos) : subscript out of bounds

2010-12-07 Thread Joonas - as_trix85
I have a for-loop in my code that calls another .R file: source("estimation.R") This file runs through without any problems, so the program completes the loop one time. However, when the loop starts a second time and it comes time to call the file "estimation.R" again, program stops and prints

Re: [R] longer object length is not a multiple of shorter object length

2010-12-07 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of madr > Sent: Tuesday, December 07, 2010 3:02 PM > To: r-help@r-project.org > Subject: [R] longer object length is not a multiple of shorter object > length > > > In datamatrix[,

Re: [R] getting R to download data

2010-12-07 Thread Ben Bolker
allianz.com.au> writes: > Is it possible to write a program such that it downloads a csv from a given > web address? Would be great if this could be done at a particular time > during the day as well. Say 9AM monday-friday. downloading a csv file is easy: x <- read.csv(url("http://whatever.

[R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed

2010-12-07 Thread Paul Miller
Hello Everyone,   Been learning R over the past several months. Read several books and have learned a great deal about data manipulation, statistical analysis, and graphics.   Now I want to learn how to make nice looking documents and about "literate programming." My understanding is that R use

Re: [R] longer object length is not a multiple of shorter object length

2010-12-07 Thread Joshua Wiley
Hi, On Tue, Dec 7, 2010 at 3:01 PM, madr wrote: > > In datamatrix[, "y"] == datamatrix[, "y"][-1] : suppose datamatrix has 10 rows, you select column "y", and then for the equality remove the first 'row' (technically element at this point since you selected just column "y"). So R is being asked

[R] longer object length is not a multiple of shorter object length

2010-12-07 Thread madr
In datamatrix[, "y"] == datamatrix[, "y"][-1] : longer object length is not a multiple of shorter object length out = c(FALSE,datamatrix[,'y'] == datamatrix[,'y'][-1]) and I do not know why I get that error, the resulting out matrix is somehow one row larger than datamatrix... all I try to do

[R] Help on loops

2010-12-07 Thread Anup Nandialath
Dear R-helpers, I have a basic question on using loops. I have a panel data set with different variables measured for "n" firms over "t" time periods. A snapshot of the data is given below id    t    X1    X2 1    1     4    3 1    2    9    2 1    3    7    3 1    4    6    6 2    1    6    4

[R] getting R to download data

2010-12-07 Thread sachinthaka . abeywardana
Hi All, Is it possible to write a program such that it downloads a csv from a given web address? Would be great if this could be done at a particular time during the day as well. Say 9AM monday-friday. Incase you are curious Im just trying to analyse some stocks data. Thanks, Sachin p.s. sorry

Re: [R] colorful venn diagram

2010-12-07 Thread Duke
Hi Laurent, On 12/7/10 5:01 PM, Laurent Gatto wrote: Dear Duke, I'm not sure if limma can generate colourful Venn diagrams. As an alternative, I can however recommend Vennerable [1]. Thanks. I also found out that there are so many packages drawing venn diagram now. I am playing with Venneule

Re: [R] colorful venn diagram

2010-12-07 Thread Laurent Gatto
Dear Duke, I'm not sure if limma can generate colourful Venn diagrams. As an alternative, I can however recommend Vennerable [1]. Hope this helps, Laurent [1] https://r-forge.r-project.org/projects/vennerable/ On 7 December 2010 21:18, Duke wrote: > Hi all, > > I am trying to plot a venn diag

[R] colorful venn diagram

2010-12-07 Thread Duke
Hi all, I am trying to plot a venn diagram using vennDiagram in limma package, but I have no idea how to have it colorful such as the color one created by the following website: http://www.pangloss.com/seidel/Protocols/venn.cgi. Any one has any advice? Thanks, D. __

[R] R programing help-newton iterations for the square root

2010-12-07 Thread 유진 정
From: jypupp...@hotmail.com To: r-help-boun...@r-project.org Subject: R programing help-newton iterations for the square root Date: Tue, 7 Dec 2010 12:00:01 -0800 NEWTON ITERATIONS FOR THE SQUARE ROOT Newton iterations to find the root of a real valued function f , i.e. a number x for

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Ivan Calandra
x+1 is not that complicated... Am I missing something here? Le 12/7/2010 16:55, Gabor Grothendieck a écrit : On Tue, Dec 7, 2010 at 8:43 AM, madr wrote: many languages have shorthands for that operation like: variable += 1 or ++variable is there something like that in R ? You can do this:

Re: [R] R problem

2010-12-07 Thread Mike Marchywka
> From: bruce...@usc.edu > To: r-help@r-project.org > Date: Tue, 7 Dec 2010 09:27:21 -0800 > Subject: [R] R problem > > I'm using R version 2.12.0 > > I'm trying to open a stata file (.dta); but I keep getting the message: > > Error in read.dta("c:/p4s

Re: [R] randomForest: How to append ID column along with predictions

2010-12-07 Thread Dennis Duro
Thanks for the confirmation Andy. It would be great if one could specify a specific column as the unique ID to be returned and/or display the input row, along with the predictions. Thanks for the quick reply and looking forward to the patch! Cheers, Dennis On Tue, Dec 7, 2010 at 12:00 PM, Liaw,

Re: [R] randomForest: How to append ID column along with predictions

2010-12-07 Thread Liaw, Andy
The order in the output correspond to the order of the input. I will patch the code so that it grabs the row names of the input (if exist). If you specify type="prob", it already labels the rows by the input row names. > -Original Message- > From: r-help-boun...@r-project.org > [mailto:

Re: [R] Creating binary variable depending on strings of two dataframes

2010-12-07 Thread Santosh Srinivas
your question is not clear to me .. but your solution is a variation of > data1$x.1 <- data1$x1 %in% data2$y1 you can play with your conditions to get the result you want On Tue, Dec 7, 2010 at 10:00 PM, Pete Pete wrote: > > Hi, > consider the following two dataframes: > x1=c("232","3454","3455

[R] robustbase problem [bug?] in adjbox function.

2010-12-07 Thread kv
hello list, i'm a bit puzzled by the error message i get when i copy past this in R: data<-c(16,13,17,4,15,24,59,18,33,8,42,19,20,4,11,9,3,7,10,3,3,67,4,4,13,16,6,3,3,6,3,4,35,10,16,11,24,7,47,8,8,2,12,3,8,4,3,6,6,10,2,9,3,15,21,13,8,16,2,5,14,9,21,4,9,11,36,4,8,4,6,4,10,13,11,5,4,16,14,3,22,20,5

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Alexander Senger
Hi Bert, thank you for your suggestion. I'm sure it's a good one. But my intention in first place was to learn about getting subsets of list nested in lists the fast way (and preferably also the easy way, but that is only my laziness). It seems this thread is getting a bit long and also lead

Re: [R] More elegant magnitude method

2010-12-07 Thread Phil Spector
Jonathan - If I understand correctly, max(0,floor(log(x,10))) will return the value you want. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] More elegant magnitude method

2010-12-07 Thread Ravi Varadhan
I would prefer: round(log10(x)) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu -Original Message

Re: [R] More elegant magnitude method

2010-12-07 Thread Jonathan P Daily
What a brain fart... Thanks! -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the wor

Re: [R] More elegant magnitude method

2010-12-07 Thread David L Lorenz
Jonathan, I'd just return the integer part of the common log: floor(log10(x)) Dave From: Jonathan P Daily To: r-help@r-project.org Date: 12/07/2010 01:44 PM Subject: [R] More elegant magnitude method Sent by: r-help-boun...@r-project.org I have a need to find the order of number to get a

Re: [R] More elegant magnitude method

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 2:43 PM, Jonathan P Daily wrote: I have a need to find the order of number to get a scaling parameter as a power of 10. I have a function that works *so far*, but it is ugly and probably buggy. In the interest of avoiding code-based outliers in my data, I thought I would as

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Duncan Murdoch
On 07/12/2010 12:42 PM, Gabor Grothendieck wrote: On Tue, Dec 7, 2010 at 12:25 PM, Bert Gunter wrote: Ted: Inline below... On Tue, Dec 7, 2010 at 8:42 AM, Ted Harding wrote: Indeed! x<- x + 1 (and being generous with unnecessary spaces) uses 10 characters. `+`(x)<-1 (being mean with

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Bert Gunter
Alexander: I'm not sure exactly what you want, so the following may be irrelevant... BUT, noting that data frames ARE lists and IF what you have can then be abstracted as lists of lists of lists of ... to various depths AND IF what you want is just to pick out and combined all named vectors (whic

[R] More elegant magnitude method

2010-12-07 Thread Jonathan P Daily
I have a need to find the order of number to get a scaling parameter as a power of 10. I have a function that works *so far*, but it is ugly and probably buggy. In the interest of avoiding code-based outliers in my data, I thought I would ask if anyone here has a better way. > scl <- function(x

Re: [R] Changing names of a string variable

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 2:31 PM, Erik Iverson wrote: Hello, To do what you want, see ?toupper : levels(dat$target) <- toupper(levels(dat$target)) However, for clarity, dat$target is not a "string variable", it is a factor, which you can verify with > str(dat) And to further clarify, it is a f

Re: [R] Changing names of a string variable

2010-12-07 Thread Erik Iverson
Phil Spector wrote: Jahan - Try dat$target = toupper(dat$target) Note that in this case, the above *will* coerce dat$target to a character vector, which may or may not be what is intended. __ R-help@r-project.org mailing list https://stat.ethz

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Bert Gunter
Ted: Inline below... On Tue, Dec 7, 2010 at 8:42 AM, Ted Harding wrote: > Indeed! > >  x <- x + 1 > > (and being generous with unnecessary spaces) uses 10 characters. > >  `+`(x)<-1 > > (being mean with them) uses 9. The "mean" version of the first > uses only 6: x<-x+1 > > However, I suppose th

Re: [R] Changing names of a string variable

2010-12-07 Thread Phil Spector
Jahan - Try dat$target = toupper(dat$target) I would not recommend a loop for something like this. (You might also want to brush up on your python, because what you're trying doesn't work in python either.) - Phil Spector

Re: [R] Changing names of a string variable

2010-12-07 Thread Erik Iverson
Hello, To do what you want, see ?toupper : levels(dat$target) <- toupper(levels(dat$target)) However, for clarity, dat$target is not a "string variable", it is a factor, which you can verify with > str(dat) Factors are enumerated types, and have a discrete set of 'levels' associated with the

Re: [R] how to get vector of data from line ?

2010-12-07 Thread madr
well, I found id the simplest answer is: d<- approx(density(x),xout=...) where xout is a vector of the points where the data should be sampled -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-vector-of-data-from-line-tp3076943p3077058.html Sent from the R help mailing l

Re: [R] Dataframe from list of similar lists: not _a_ way, but _the best_ way

2010-12-07 Thread Brian Diggs
On 12/7/2010 1:03 AM, Nick Sabbe wrote: Hi All. I often find myself in this situation: . Based on some vector (or list) of values, I need to calculate a few new values for each of them, where some of the new values are numbers, but some are more of descriptive nature (so: character stri

[R] Changing names of a string variable

2010-12-07 Thread Jahan
Hello, Here is the data set I am working with: dat=read.csv('http://dl.dropbox.com/u/1852742/relexpressions.csv') names(dat) #Under the 'target' column, I want to change all of the values into all capital letters (e.g. fgf2 becomes FGF2). I have taken a loop approach but I think my Python backgro

[R] help on timeseries

2010-12-07 Thread cameron
i have time series of momentum signal. I want to get the date of each of the "-1" signal period. for example , the first period of -1 signal begins on 2005-9-21 and ends on 2005-9-28. 2nd period of -1 signal begins on 2005-09-30 and ends on 2005-10-28. Thx Cameron datePx

Re: [R] Creating binary variable depending on strings of two dataframes

2010-12-07 Thread Gabor Grothendieck
On Tue, Dec 7, 2010 at 11:30 AM, Pete Pete wrote: > > Hi, > consider the following two dataframes: > x1=c("232","3454","3455","342","13") > x2=c("1","1","1","0","0") > data1=data.frame(x1,x2) > > y1=c("232","232","3454","3454","3455","342","13","13","13","13") > y2=c("E1","F3","F5","E1","E2","H4",

[R] R problem

2010-12-07 Thread Bruce John
I'm using R version 2.12.0 I'm trying to open a stata file (.dta); but I keep getting the message: Error in read.dta("c:/p4subset_biology.dta") : Calloc could not allocate (-603966867 of 4) memory What does this mean? The file should contain lots of physiological data. Thank you for your help

Re: [R] please show me simple example how to plot "Distance-Weighted Least Squares" fitting

2010-12-07 Thread Sarah Goslee
It's impossible to give you really good advice without an example of your data, the R code you used and the error message. But here's a simple scatterplot example: fakedata <- data.frame(x=runif(15), y=runif(15)) plot(fakedata$x, fakedata$y) or since you mentioned a line: fakedata <- fakedata[o

Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 1:49 PM, Greg Snow wrote: tmpdf <- data.frame( x = c(1,2,3), y=c(2,3,1), a=c(10,20,30) ) mymat <- matrix(0, ncol=3, nrow=3) mymat[ as.matrix(tmpdf[,c('x','y')]) ] <- tmpdf$a cbind is also useful for assembly of arguments to the matrix-`[<-` function: tmpdf <- data.fram

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Alexander Senger
Hello Gerrit, Gabor, thank you for your suggestion. Unfortunately unlist seems to be rather expensive. A short test with one of my datasets gives 0.01s for an extraction based on my approach and 5.6s for unlist alone. The reason seems to be that unlist relies on lapply internally and does so rec

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Alexander Senger
Hello, Matthew's hint is interesting: Am 07.12.2010 19:16, schrieb Matthew Dowle: > Hello Alex, > > Assuming it was just an inadequate example (since a data.frame would suffice > in that case), did you know that a data.frames' columns do not have to be > vectors but can be lists? I don't know

Re: [R] tableGrob and properties of a cell

2010-12-07 Thread Alex Bird
Hi Baptiste! Grand-grand merci!!! It works! Thanks! Alex 2010/12/7 baptiste auguie : > baptiste __ 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-guide.

[R] Statistical Analysis with R Beginner's Guide Book

2010-12-07 Thread johnmquick
Hi Everyone, I'm writing to announce my new R beginner's guide book and answer questions related to it. The primary focus of Statistical Analysis with R is helping new users become accustomed to R and empowering them to apply R to suit their own needs. It is a beginner's guide written for a broa

Re: [R] how to get vector of data from line ?

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 1:27 PM, madr wrote: I have created a density line d<- density(X) now I need to read values from that line for example what is the value of this line at x = 1, 2, 3 etc... Learn to search: http://finzi.psych.upenn.edu/Rhelp10/2010-September/253910.html -- David Winse

[R] randomForest: How to append ID column along with predictions

2010-12-07 Thread Dennis Duro
Hi all, When running a prediction using RF on another data, I get two columns returned: row number(?) and predicted class. Is there a way of appending the unique row value from an ID column in the dataframe to the predictions instead of the row number? I'm assuming that the returned results follow

Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread Greg Snow
tmpdf <- data.frame( x = c(1,2,3), y=c(2,3,1), a=c(10,20,30) ) mymat <- matrix(0, ncol=3, nrow=3) mymat[ as.matrix(tmpdf[,c('x','y')]) ] <- tmpdf$a -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > F

Re: [R] how to get vector of data from line ?

2010-12-07 Thread Greg Snow
There are a few different options depending on what you are trying to do. If you just need some data pairs (for plotting for example), then the return from density has a vector of x's and a vector of y's, just use those. If you have specific x values that you need the height at and they follow a

Re: [R] How to switch label font from Chinese to English

2010-12-07 Thread Jianhong Wang
Thanks! Brian, As you said, if locale changes, it is fine now. What I add is Sys.setlocale("LC_TIME", "American") On Tue, Dec 7, 2010 at 12:14 PM, Prof Brian Ripley wrote: > On Tue, 7 Dec 2010, Jianhong Wang wrote: > > Hi >> >> I tried to plot something simple >> >> x=c('2010-08-20', '2010-08-

Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread Whit Armstrong
index m as a vector and do the assignment in one step i <- df$row + (df$col-1)*nrow(m) m[i] <- df$a or something along those lines. -Whit On Tue, Dec 7, 2010 at 1:31 PM, Cutler, Gene wrote: > I have a data frame with three columns, x, y, and a.  I want to create a > matrix from these values

Re: [R] How to switch label font from Chinese to English

2010-12-07 Thread Prof Brian Ripley
On Tue, 7 Dec 2010, Jianhong Wang wrote: Hi I tried to plot something simple x=c('2010-08-20', '2010-08-30') y = c(1,2) t = strptime(x, "%Y-%m-%d") plot(t,y) At the xlab, the fonts are Chinese. How can I switch it to English? I am working under Windows 7 64 bits Home Edition and R is Win32

[R] tweedie in gam

2010-12-07 Thread Payal Bal
Hello, I have count data with a large number of zeros. To model this data using gams I want to try the Tweedie distribution instead. (The zero-inflated poisson willbe my next step) How do i decide on the value of the power 'p' parameter in the formula: family=Tweedie(p, link) ? For a glm, this ca

Re: [R] please show me simple example how to plot

2010-12-07 Thread Greg Snow
Like Peter says, this sounds like loess, there are examples on the help page for scatter.smooth, you could also do this with lattice graphics using type=c('p','smooth'), or ggplot2 graphics (probably something like geom_smooth or geom_loess, I don't know ggplot2 that well yet). If you want to l

[R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread Cutler, Gene
I have a data frame with three columns, x, y, and a. I want to create a matrix from these values such that for matrix m: m[x,y] == a Obviously, I can go row by row through the data frame and insert the value a at the correct x,y location in the matrix. I can make that slightly more efficient

Re: [R] tableGrob and properties of a cell

2010-12-07 Thread baptiste auguie
Hi, Embarrassingly enough, it was quite straight-forward in the first versions of grid.table(). You might want to try with version r11 for example, source("http://gridextra.googlecode.com/svn-history/r11/trunk/R/tableGrob.r";) library(grid) tc = textConnection(" carat VeryLongWordIndee

[R] how to get vector of data from line ?

2010-12-07 Thread madr
I have created a density line d<- density(X) now I need to read values from that line for example what is the value of this line at x = 1, 2, 3 etc... -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-vector-of-data-from-line-tp3076943p3076943.html Sent from the R help m

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Ted Harding
Indeed! x <- x + 1 (and being generous with unnecessary spaces) uses 10 characters. `+`(x)<-1 (being mean with them) uses 9. The "mean" version of the first uses only 6: x<-x+1 However, I suppose there is merit in the spiritual exercise of contemplating how `+`(x)<-1 gets worked out! Ted.

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Gabor Grothendieck
On Tue, Dec 7, 2010 at 1:12 PM, David Winsemius wrote: > > On Dec 7, 2010, at 12:42 PM, Gabor Grothendieck wrote: > >> On Tue, Dec 7, 2010 at 12:25 PM, Bert Gunter >> wrote: >>> >>> Ted: >>> >>> Inline below... >>> >>> On Tue, Dec 7, 2010 at 8:42 AM, Ted Harding >>> wrote: Indeed!

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Matthew Dowle
Hello Alex, Assuming it was just an inadequate example (since a data.frame would suffice in that case), did you know that a data.frames' columns do not have to be vectors but can be lists? I don't know if that helps. > DF = data.frame(a=1:3) > DF$b = list(pi, 2:3, letters[1:5]) > DF a

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Henrik Bengtsson
First, subset 'test' once, e.g. testT <- test[1:3]; and then use sapply() on that, e.g. val <- sapply(testT, FUN=function (x) { x$a }) Then you can avoid one level of function calls, by val <- sapply(testT, FUN="[[", "a") Second, there is some overhead in "[[", "$" etc. You can use .subset2(

[R] randomForest: How to append ID column along with predictions

2010-12-07 Thread Dennis
Hi all, When running a prediction using RF on another data, I get two columns returned: row number(?) and predicted class. Is there a way of appending the unique row value from an ID column in the dataframe to the predictions instead of the row number? I'm assuming that the returned results follow

Re: [R] increase or decrease variable by 1

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 12:42 PM, Gabor Grothendieck wrote: On Tue, Dec 7, 2010 at 12:25 PM, Bert Gunter wrote: Ted: Inline below... On Tue, Dec 7, 2010 at 8:42 AM, Ted Harding wrote: Indeed! x <- x + 1 (and being generous with unnecessary spaces) uses 10 characters. `+`(x)<-1 (being

Re: [R] How to formulate constraint like abs(x) = y in constrOptim (or other)

2010-12-07 Thread Benjamin B.
Thanks a lot for your responses. Alabama and Rsolnp packages look promising. My first tests worked well. For others searching for alike problems I now use something like: #equality constraint function eqFkt<-function(x){ #for sum(x)=sum_x sm<-sum(x)-sum_x return(c(sm)) } ineqFk

Re: [R] please show me simple example how to plot

2010-12-07 Thread Peter Ehlers
On 2010-12-07 09:37, madr wrote: Well, maybe I didn't write it clear. I know how to create scatterplot, and how to import data from csv file. But I do not know how to add this fitting that mentioned in sumbject to a plot. I do not know for what function name to look for in R. I played some time

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Gabor Grothendieck
On Tue, Dec 7, 2010 at 12:12 PM, Alexander Senger wrote: > Hello Gerrit, Gabor, > > > thank you for your suggestion. > > Unfortunately unlist seems to be rather expensive. A short test with one > of my datasets gives 0.01s for an extraction based on my approach and > 5.6s for unlist alone. The rea

[R] Creating binary variable depending on strings of two dataframes

2010-12-07 Thread Pete Pete
Hi, consider the following two dataframes: x1=c("232","3454","3455","342","13") x2=c("1","1","1","0","0") data1=data.frame(x1,x2) y1=c("232","232","3454","3454","3455","342","13","13","13","13") y2=c("E1","F3","F5","E1","E2","H4","F8","G3","E1","H2") data2=data.frame(y1,y2) I need a new column i

Re: [R] latex() hangs R console

2010-12-07 Thread RICHARD M. HEIBERGER
Michael, The easiest workaround is to assign the result of the latex() command. myfilename <- latex(x) print.default(myfilename) It looks to me like the insides of the dvi.latex function aren't quite right for Windows. Rich [[alternative HTML version deleted]] ___

Re: [R] coxph failure

2010-12-07 Thread Therneau, Terry M., Ph.D.
Larry, You found a data set that kills coxph. I'll have to think about what to do since on the one hand it's your own fault for trying to fit a very bad model, and on the other I'd like the routine to give a nice error message before it dies. In the data set you sent me the predictor varia

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Alexander Senger
I tried to hide the gory details as the structure of my datasets is rather complicated. Basically its a long list of lists which in turn contain character vectors, dates, numerics and dataframes, all named. While the hierarchy is fixed neither the number of elements nor their ordering is. But if I

[R] please show me simple example how to plot "Distance-Weighted Least Squares" fitting

2010-12-07 Thread madr
I got simple x,y pairs of data and simple scatterplot and just cannot figure how to do it , there are many examples but always there is error popping out please show me an example stripped with additional data just core of what I need to do to get this damn line -- View this message in context:

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Gabor Grothendieck
On Tue, Dec 7, 2010 at 12:25 PM, Bert Gunter wrote: > Ted: > > Inline below... > > On Tue, Dec 7, 2010 at 8:42 AM, Ted Harding wrote: >> Indeed! >> >>  x <- x + 1 >> >> (and being generous with unnecessary spaces) uses 10 characters. >> >>  `+`(x)<-1 >> >> (being mean with them) uses 9. The "mean

Re: [R] please show me simple example how to plot

2010-12-07 Thread madr
Well, maybe I didn't write it clear. I know how to create scatterplot, and how to import data from csv file. But I do not know how to add this fitting that mentioned in sumbject to a plot. I do not know for what function name to look for in R. I played some time with ls, and it didn't create a lin

Re: [R] Creating binary variable depending on strings of two dataframes

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 11:30 AM, Pete Pete wrote: Hi, consider the following two dataframes: x1=c("232","3454","3455","342","13") x2=c("1","1","1","0","0") data1=data.frame(x1,x2) y1=c("232","232","3454","3454","3455","342","13","13","13","13") y2=c("E1","F3","F5","E1","E2","H4","F8","G3","E1","H

[R] How to switch label font from Chinese to English

2010-12-07 Thread Jianhong Wang
Hi I tried to plot something simple x=c('2010-08-20', '2010-08-30') y = c(1,2) t = strptime(x, "%Y-%m-%d") plot(t,y) At the xlab, the fonts are Chinese. How can I switch it to English? I am working under Windows 7 64 bits Home Edition and R is Win32 version 2.11.1 Thanks! [[alternati

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Gabor Grothendieck
On Tue, Dec 7, 2010 at 8:43 AM, madr wrote: > > many languages have shorthands for that operation like: > > variable += 1 > or > ++variable > > is there something like that in R ? You can do this: > x <- 3 > `+`(x) <- 1 > x [1] 4 -- Statistics & Software Consulting GKX Group, GKX Associates

[R] tableGrob and properties of a cell

2010-12-07 Thread Alex Bird
Hello there, could you please help to modify gpar() properties of a cell inside tableGrob() output. In the following example I want to have different color for one out of 4 cells require(gridExtra) z<-matrix(1:4,2,2) grid.draw(tableGrob(z)) The only way I found for now how to do it is to d

Re: [R] string

2010-12-07 Thread Ivan Calandra
It took me quite some time to understand the difference between sep and collapse. The examples in Phil Spector's book (2008) helped me to get it: paste(c('X','Y'), 1:5, sep='_') "X_1" "Y_2" "X_3" "Y_4" "X_5" paste(c('X','Y'), 1:5, collapse='|') ## sep=" " by default [1] "X 1|Y 2|X 3|Y 4|X 5" p

Re: [R] string

2010-12-07 Thread Ted Harding
Ivan's advice is good, but understanding clearly what "character string to separate the results" might mean is a bit tricky! Example: cvec <- c("J","e"," ","m","'","a","p","p","e","l","l","e", " ","B","e","n","o","i","t") cstring <- paste(cvec,collapse="") cstring # [1] "Je m'

Re: [R] increase or decrease variable by 1

2010-12-07 Thread Uwe Ligges
On 07.12.2010 14:43, madr wrote: many languages have shorthands for that operation like: variable += 1 or ++variable is there something like that in R ? No. Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] string

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 10:11 AM, Benoit Wastine wrote: Hi, I'm running R 2.11 Does anyone know if it possible to transform one character vector to one character string ? ?gsub Also look at the even more powerful gsubfn package. There is also the stringr package. -- David Winsemius, MD Wes

Re: [R] string

2010-12-07 Thread Ivan Calandra
Hi, If I understand what you mean (no example...), see ?paste and the collpase argument Ivan Le 12/7/2010 16:11, Benoit Wastine a écrit : Hi, I'm running R 2.11 Does anyone know if it possible to transform one character vector to one character string ? Many thanks Benoit -- Ivan CALANDR

  1   2   >