Re: [R] Unexpected behaviour of write.csv - read.csv

2011-01-14 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 07:06 PM, Prof Brian Ripley wrote: On Thu, 13 Jan 2011, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2

[R] Crossed random factors in lme

2011-01-14 Thread Björn Klatt
Dear all, I am quite new at R and have a question about using lme with crossed random factors. I followed the instructions of Pinheiro Bates, but that did not work because of the non grouping of my data. Reading prior threads ( http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg10849.html),

[R] quasi complete separation in mixed logistic

2011-01-14 Thread Massimo Fenati
Dear R workers, I have a question about a mixed logistic regression for repeated data. After fitting a traditional logistic regression a quasi-complete separation with too large SE for a covariate (sex) was shown. In these days I read a lot of pubblication about the possible solutions of

Re: [R] CSV value not being read as it appears

2011-01-14 Thread David Scott
As a further note, this is a reminder that whenever you get data via a spreadsheet the first thing to do is examine it and clean up any problems. A basic requirement is to tabulate any categorical variable. Spreadsheets allow any sort of data to be entered, with no controls. My experience is

Re: [R] CSV value not being read as it appears

2011-01-14 Thread Prof Brian Ripley
On Fri, 14 Jan 2011, David Scott wrote: As a further note, this is a reminder that whenever you get data via a spreadsheet the first thing to do is examine it and clean up any problems. A basic requirement is to tabulate any categorical variable. Spreadsheets allow any sort of data to be

Re: [R] CSV value not being read as it appears

2011-01-14 Thread bgreen
Hello David, Thanks for your e-mail. The data was a report derived from a statewide database, saved in EXCEL format, so the usual issue of the vagaries of human data entry variation wasn't the issue as the data was an automated report, which is run every three months. I would not have even

Re: [R] CSV value not being read as it appears

2011-01-14 Thread bgreen
Brian, Thanks. My response to David follows. I should add that this problem has never occurred previously as far as I know (I have now checked the previous report I was sent): Hello David, Thanks for your e-mail. The data was a report derived from a statewide database, saved in EXCEL format, so

[R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread surreyj
Hello everyone, I am currently working with some data where I need to select the first occurrence of a value after the occurrence of another value. The data has two columns, one with a time and one with occurence of certain events. The column of data I want to select from looks like this

Re: [R] bug in qplot (library ggplot2)

2011-01-14 Thread Pierre-Olivier Chasset
David, I haven't found any FAQs for ggplot. Do you mean the http://cran.r-project.org/faqs.html? In this one, no subject seems to be linked with my problem about qplot in a loop. Best regards, Pierre-Olivier Le 14/01/2011 05:43, David Winsemius a écrit : On Jan 13, 2011, at 8:17 PM,

[R] test

2011-01-14 Thread romzero
Hi, i have that table Thesis Day A B C 1 0 83.43 90.15 22.97 1 0 85.50 94.97 16.62 1 0 83.36 95.38 20.70 1 0 84.47 92.16 23.58 1 0 83.98 95.33 19.39 1 0 82.86 93.78 24.55 1 0

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread Taras Zakharko
Hi, I'll do something like this (there is probably a nicer way, but this code is what first comes up to my mind) provided your data is in x pos1 - which(x %in% val1)[1] pos2 - which(x %in% val2)[which(x %in% val2) pos1][1] -- View this message in context:

Re: [R] bug in qplot (library ggplot2)

2011-01-14 Thread ONKELINX, Thierry
Pierre, You did not look hard enough. You need FAQ 7.22 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur-

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread Henrique Dallazuanna
Try this: which(x %in% c(MagDwn, Resp))[2] On Fri, Jan 14, 2011 at 7:22 AM, surreyj surreyjack...@gmail.com wrote: Hello everyone, I am currently working with some data where I need to select the first occurrence of a value after the occurrence of another value. The data has two

Re: [R] question about deparse(substitute(...))

2011-01-14 Thread Gabor Grothendieck
On Thu, Jan 13, 2011 at 7:36 PM, Sean Zhang seane...@gmail.com wrote: Dear R helpers: I like to apply deparse(substitute()) on multiple arguments to collect the names of the arguments into a character vector. I used function test.fun as below. it works when there is only one input argument.

[R] selecting elements in vector

2011-01-14 Thread A M Lavezzi
Hi everybody, I have the following problem. I have a vector containing character elements, such as: list = c(aa,bb,cc,dd,ee) I want to create an index which identifies the elements that are different from, e.g. aa and bb. When I do the following: jj = list!=aa list!=bb jj [1] FALSE FALSE

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread Henrique Dallazuanna
Other option: which(!diff(as.numeric(factor(x, levels = c(MagDwn, Resp)[1] On Fri, Jan 14, 2011 at 10:12 AM, Henrique Dallazuanna www...@gmail.comwrote: Try this: which(x %in% c(MagDwn, Resp))[2] On Fri, Jan 14, 2011 at 7:22 AM, surreyj surreyjack...@gmail.com wrote: Hello

Re: [R] selecting elements in vector

2011-01-14 Thread Henrique Dallazuanna
Try this: !list %in% c(aa, bb) On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi lave...@unipa.it wrote: Hi everybody, I have the following problem. I have a vector containing character elements, such as: list = c(aa,bb,cc,dd,ee) I want to create an index which identifies the elements that

Re: [R] selecting elements in vector

2011-01-14 Thread A M Lavezzi
it works! thank you so much Mario On Fri, Jan 14, 2011 at 1:29 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: !list %in% c(aa, bb) On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi lave...@unipa.it wrote: Hi everybody, I have the following problem. I have a vector containing

Re: [R] selecting elements in vector

2011-01-14 Thread Henrique Dallazuanna
Try this: !list %in% c(aa, bb) On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi lave...@unipa.it wrote: Hi everybody, I have the following problem. I have a vector containing character elements, such as: list = c(aa,bb,cc,dd,ee) I want to create an index which identifies the elements that

Re: [R] test

2011-01-14 Thread Dennis Murphy
Hi: If I understood you correctly, the following may work: # Utility function to compute all pairwise differences of a vector: # The upper triangle subtracts x_i - x_j for j i; if you want it the # other way around, use lower.tri() instead of upper.tri(). # Coercion to vector means that the

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread surreyj
Thanks so much that works, but I just realised I was unclear, I meant I need to select all the MagDwn after every Resp :) -- View this message in context: http://r.789695.n4.nabble.com/Selecting-the-first-occurrence-of-a-value-after-an-occurrence-of-a-different-value-tp3217340p3217456.html Sent

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread Bart Joosen
Ofcourse you can loop over your data, but a vectorised way: f.search - function(x, ref, search) { cs - match(cumsum(x==ref), cumsum(x==ref)) outp - suppressWarnings(tapply(x==search,cs, function(x) min(which(x==1 outp - outp[outp!=Inf] # To remove the occurences where nothing was

Re: [R] bug in qplot (library ggplot2)

2011-01-14 Thread Pierre-Olivier Chasset
The corrected code: library(ggplot2) for (i in 1:2) { png(file=paste('test ',i,'.png',sep='')) print(qplot(carat, data=diamonds, fill=color,geom='histogram')+scale_y_continuous(i)) dev.off() } Thanks Le 14/01/2011 02:17, Pierre-Olivier Chasset a écrit : Hello, this following code give

Re: [R] bug in qplot (library ggplot2)

2011-01-14 Thread ONKELINX, Thierry
Dear Pierre, A more elegant solution is to use ggsave() library(ggplot2) for (i in 1:2) { p - qplot(carat, data=diamonds, fill=color,geom='histogram')+scale_y_continuous(i) ggsave(filename = paste('test ',i,'.png',sep=''), plot = p) } Best regards, Thierry

[R] Getting the minimum/maximum value of each row of a matrix

2011-01-14 Thread Barth B. Riley
Hello Is there a straightforward way of getting a vector containing the minimum (or maximum) value of each row of a matrix? Thanks Barth PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for

Re: [R] Getting the minimum/maximum value of each row of a matrix

2011-01-14 Thread Henrique Dallazuanna
apply(your_matrix, 1, range) or apply(your_matrix, 1, min) apply(your_matrix, 1, max) On Fri, Jan 14, 2011 at 11:44 AM, Barth B. Riley bbri...@chestnut.orgwrote: Hello Is there a straightforward way of getting a vector containing the minimum (or maximum) value of each row of a matrix?

Re: [R] test

2011-01-14 Thread K. Elo
Dear Romezo, a solution maybe not that elegant and effective, but seems to work: test_calculate-function() { tarrow-1 TARGET-data.frame(Thesis=0, Day=0,A=0,B=0,C=0) for (i in c(unique(my.data$Thesis))) { for (j in c(unique(my.data$Day[ my.data$Thesis==i ]))) {

Re: [R] test

2011-01-14 Thread ONKELINX, Thierry
Here is a more elegant solution using the plyr package. my.data - expand.grid(Thesis = 1:3, Day = c(0, 14), Run = 1:10) my.data$A - rpois(nrow(my.data), 10) my.data$B - rpois(nrow(my.data), 10) my.data$C - rpois(nrow(my.data), 10) library(plyr) ddply(my.data, .(Thesis, Day), function(x){

[R] subset factor?

2011-01-14 Thread Silvano
Hi, I used subset command, like this: grupoP = subset(dados, grupos=='P', select=c(mortos, vivos, doses, percevejos, p)) and the variables in select option are numeric. I tried fit a model with command: ajuste.logit = glm(cbind(mortos,percevejos)~log10(doses), family=binomial(logit),

Re: [R] subset factor?

2011-01-14 Thread Sarah Goslee
Are you certain they are numeric? Have you tried str() on your data? Sarah On Fri, Jan 14, 2011 at 9:08 AM, Silvano silv...@uel.br wrote: Hi, I used subset command, like this: grupoP = subset(dados, grupos=='P',  select=c(mortos, vivos, doses, percevejos, p)) and the variables in select

[R] Extract Crawley´s datasets and pack them into a new package

2011-01-14 Thread Christoph Scherber
Dear all, I have a seemingly easy question but couldn´t find a solution so far: I´d like to have all datasets from Crawley´s R Book in an own package, so that I can easily access them. Let´s assume they are all saved on C: in the following directory: setwd(C:\\Crawleydata) Now I am loading

Re: [R] CSV value not being read as it appears

2011-01-14 Thread Philipp Pagel
On Fri, Jan 14, 2011 at 07:58:07PM +1000, bgr...@dyson.brisnet.org.au wrote: Thanks for your e-mail. The data was a report derived from a statewide database, saved in EXCEL format, so the usual issue of the vagaries of human data entry variation wasn't the issue as the data was an automated

[R] R2WinBUGS-Windows 7

2011-01-14 Thread Erica Donnelly-Swift
Dear all, I'm having a slight issue with R2WinBugs it cannot detect where WinBUGS is located. Q: How can I change the default path? Any advice is greatly appreciated. Thanks. Regards Erica I'm using R2WinBUGs (R version 2.21.1) on windows platform (Windows 7). I have downloaded

Re: [R] subset factor?

2011-01-14 Thread Peter Ehlers
On 2011-01-14 06:20, Sarah Goslee wrote: Are you certain they are numeric? Have you tried str() on your data? Sarah Silvano: As Sarah says, do str(dados) to see that 'doses' is NOT numeric. The error message is very clear; it tells you that 'doses' is a factor. My guess is that you imported

Re: [R] CSV value not being read as it appears

2011-01-14 Thread Peter Ehlers
On 2011-01-14 02:09, bgr...@dyson.brisnet.org.au wrote: Brian, Thanks. My response to David follows. I should add that this problem has never occurred previously as far as I know (I have now checked the previous report I was sent): This problem occurs to me frequently. Like Philipp and

Re: [R] R2WinBUGS-Windows 7

2011-01-14 Thread Uwe Ligges
Would you please mind to read ?bugs and see that the argument called bugs.directory may be relevant? Uwe Ligges On 14.01.2011 15:53, Erica Donnelly-Swift wrote: Dear all, I'm having a slight issue with R2WinBugs it cannot detect where WinBUGS is located. Q: How can I change the

Re: [R] R2WinBUGS-Windows 7

2011-01-14 Thread Erica Donnelly-Swift
Yes, I just realised this Apologies for the inconvenience Thanks From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: 14 January 2011 15:20 To: Erica Donnelly-Swift Cc: r-help@R-project.org Subject: Re: [R] R2WinBUGS-Windows 7 Would you please

Re: [R] subset factor?

2011-01-14 Thread Erik Iverson
Silvano wrote: Hi, I used subset command, like this: grupoP = subset(dados, grupos=='P', select=c(mortos, vivos, doses, percevejos, p)) and the variables in select option are numeric. They may *look* numeric, but are they really? You don't give us enough information to determine that.

[R] piecewise regression

2011-01-14 Thread Federico Bonofiglio
Hello everybody Quick question, if you'd like to throw a little tip: does anyone knows a function that runs piecewise regression models with coefficients estimation and inferences ? Thank you [[alternative HTML version deleted]] __

Re: [R] piecewise regression

2011-01-14 Thread David Winsemius
Searching the archives would surely be a better way to assemble a list of candidate packages but the segmented package is surely in the list. On Jan 14, 2011, at 9:42 AM, Federico Bonofiglio wrote: Hello everybody Quick question, if you'd like to throw a little tip: does anyone knows a

Re: [R] CSV value not being read as it appears

2011-01-14 Thread Heinz Tuechler
At 14.01.2011 07:09 -0800, Peter Ehlers wrote: On 2011-01-14 02:09, bgr...@dyson.brisnet.org.au wrote: Brian, Thanks. My response to David follows. I should add that this problem has never occurred previously as far as I know (I have now checked the previous report I was sent): This problem

[R] one sided t test

2011-01-14 Thread Ingo
Dear R, I am using this R version:R version 2.11.1 (2010-05-31)(Cran Mirror Berlin) It seems to me, that R constructs a wrong confidence intervall if you try to get a one sided t-test. If the true mean is 1 and my alternative hypothesis (H1) says that mu is smaller (less)than zero the conf.

Re: [R] piecewise regression

2011-01-14 Thread Spencer Graves
Hello: I just found 58 help pages in 32 contributed packages containing the terms piecewise and regression, as follows: library(sos) pr - ???'piecewise regression' # for piecewise with regression summary(pr) # 58 matches in 32 packages pr # view the 58 links sorted by package in a web

Re: [R] piecewise regression

2011-01-14 Thread Gene Leynes
I wish I had a better answer. There are two things that I know of that use a direct approach: The segmentation package seems to work well if you are doing a few fits, but I had problems when I tried running it on loads of data. It's a bit tricky to parametrize. When I tried investigating the

Re: [R] one sided t test

2011-01-14 Thread Uwe Ligges
No, all is fine, for this one-sided test, you want to calculate the upper part of the confidence interval. If it is less than zero you have shown that the alternative is probably right - the true value is below the upper confidence interval boarder with probability 1-\alpha. Uwe Ligges On

Re: [R] Extract Crawley´s datasets and pack them into a new package

2011-01-14 Thread Uwe Ligges
More or less untested without using package.skeleton after preparing the package directories: datapath - c:/packagename/data within(LL3, for(i in ls()) save(list=i, file=file.path(datapath, paste(i, .RData, sep= or with package.skeleton: package.skeleton(packagename, path=c:/,

Re: [R] piecewise regression

2011-01-14 Thread Gene Leynes
oh yes, and the structchange package. After a day of experimentation I couldn't figure out how to get the structchange package to work for my problems. Although it is probably user error on my part, the package seems to be specific to time series problems. Also, I think it needed regularly

[R] Help on a Display function

2011-01-14 Thread Hans W Borchers
I wanted to simulate the Matlab DISPLAY function for some time now. After seeing a recent proposal by Gabor Grothendieck I came up with the following solution, display - function(...) { my_names - lapply(substitute(placeholderFunction(...))[-1], deparse) for (my in my_names) cat(my, =,

Re: [R] piecewise regression

2011-01-14 Thread Bert Gunter
You failed to specify 2 crucial issues: Are the join points known (linear rgression, splines) or unknown (nonlinear regression)? And as several have already indicated, what are the smoothness constraints? -- Bert On Fri, Jan 14, 2011 at 6:42 AM, Federico Bonofiglio bonori...@gmail.com wrote:

Re: [R] help in calculating ar on ranked vector

2011-01-14 Thread Uwe Ligges
Works for my examples. But you have not specified what you actual call to ar() was. Uwe Ligges On 12.01.2011 21:17, Raymond Wong wrote: I was using ar(stats) to calculate autoregressive coefficient. It works on vector z, but it will not work on vector rz-rank (z, ties.method=average).

Re: [R] Help on a Display function

2011-01-14 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Hans W Borchers Sent: Friday, January 14, 2011 8:55 AM To: r-h...@stat.math.ethz.ch Subject: [R] Help on a Display function I wanted to simulate the Matlab DISPLAY function

Re: [R] question about svm(e1071)

2011-01-14 Thread Uwe Ligges
Looking at your results suggests that differences are probably based on expected minor numerical inaccuracies and the possibly alternating sign of the support vectors. Best, Uwe Ligges On 13.01.2011 01:28, muto...@chugai-pharm.co.jp wrote: Dear all, I executed svm calculation using e1071

[R] Predictive Analytics with R, PMML, ADAPA and Excel

2011-01-14 Thread Guazzelli, Alex
YouTube video available: http://www.youtube.com/watch?v=VuSaP-vwSpI In this video, I start by building a decision tree model in R. I then export it as a PMML file and deploy it in the ADAPA Scoring Engine. For that, I use the ADAPA trial subscription available for free on the Zementis website

[R] Survfit: why different survival curves but same parameter estimates?

2011-01-14 Thread Denis Pelletier
Hello, I'm trying to estimate a Cox proportional hazard model with time-varying covariates using coxph. The parameter estimates are fine but there is something wrong with the survival curves I get with survfit (results are not plausible). Let me explain why I think something's wrong. To make

[R] Write.dta and export of variable labels

2011-01-14 Thread Andrew Owen
When I import a data file in stata format using read.dta, the full variable labels (e.g. variable= inc2000; variable label= Total household income in year 2000). When I then export the same data file using write.dta, the variable labels are not included in the new .dta file. Is there any way to

[R] filtering a dataframe with a vector of rownames

2011-01-14 Thread Jonathan Hughes
Hello, Here's my problem. I have a large data frame and a vector with some of its row names. I'd like to have a new data frame only with those rows that match this vector of row names. I tried this: data-cbind(c(1,2,3,4,5,6),c(2,3,4,5,6,7)) rownames(data)-c(a, b, c,d,e,f) names.to.keep-c(a,

Re: [R] filtering a dataframe with a vector of rownames

2011-01-14 Thread Phil Spector
Jonathan - To make your approach work, you'd need to replace == with %in%: rows.to.keep-which(rownames(data) %in% names.to.keep) [1] 1 3 4 But to answer you're original question, remember that the point of rownames is that they can be used to index a data frame: data[rows.to.keep,]

Re: [R] filtering a dataframe with a vector of rownames

2011-01-14 Thread ANJAN PURKAYASTHA
subset(data, row.names(data) %in% name.to.keep HTH, Anjan On Fri, Jan 14, 2011 at 1:25 PM, Jonathan Hughes jonathan.hughes...@live.com wrote: Hello, Here's my problem. I have a large data frame and a vector with some of its row names. I'd like to have a new data frame only with those rows

Re: [R] filtering a dataframe with a vector of rownames

2011-01-14 Thread Uwe Ligges
On 14.01.2011 19:25, Jonathan Hughes wrote: Hello, Here's my problem. I have a large data frame and a vector with some of its row names. I'd like to have a new data frame only with those rows that match this vector of row names. I tried this: data-cbind(c(1,2,3,4,5,6),c(2,3,4,5,6,7))

Re: [R] piecewise regression

2011-01-14 Thread John Sorkin
If you know the knot and want linear segments, lm (or any other normal regression software) can perform the analysis. For example if you want to regress y on x and have a knot a 20 the following code will work: x - runif(500,0,40) plot(x) for (i in 1:500) { if (x[i] 20) y[i] -

[R] holding objects in dataframes

2011-01-14 Thread Alexander Shenkin
Hello list, I need to keep track of objects that are related to particular observations. In this case, I need to keep track of polygons that are associated with observations. What I would ideally have is one column of a dataframe hold a polygonal object (from the spatstat package). My

[R] read in data, maintain decimal places

2011-01-14 Thread Jim Moon
Good day, All, Is there any way to maintain the number of decimal places in the type of situation below? I would like to maintain the number of decimal places in 0.667, despite the fact that its column-mates have a fourth decimal place. Thank you for your time. Jim dat.txt contents:

Re: [R] read in data, maintain decimal places

2011-01-14 Thread David Winsemius
On Jan 14, 2011, at 5:22 PM, Jim Moon wrote: Good day, All, Is there any way to maintain the number of decimal places in the type of situation below? I would like to maintain the number of decimal places in 0.667, despite the fact that its column-mates have a fourth decimal place. You

Re: [R] Fitting an Inverse Gamma Distribution

2011-01-14 Thread emorway
Hello David, Thank you for pointing me to the GeneralizedHyperbolic package. I've been playing around with hyperbFit with my data, but get: Warning Messages: In besselK(zeta, nu = 1) : value out of range in 'bessel_k' 10 Next, just to see if I could get something to plot I tried

Re: [R] read in data, maintain decimal places

2011-01-14 Thread Jim Moon
David, Perfect. Thank you! Jim -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, January 14, 2011 2:26 PM To: Jim Moon Cc: r-help@r-project.org Subject: Re: [R] read in data, maintain decimal places On Jan 14, 2011, at 5:22 PM, Jim Moon wrote:

[R] Problems with TeachingDemos package

2011-01-14 Thread gaiarrido
Hi, somebody can help me. Idon't understand very well the manual of the this package, I suppose I must enter wdtxtStart, before I start working, but is supposed that this command should open Word, but nothing happens. I use Rgui, not Rcmdr. Thanks - Mario Garrido Escudero PhD student Dpto.

Re: [R] filtering a dataframe with a vector of rownames

2011-01-14 Thread Jonathan Hughes
Thank you so much! jonathan Date: Fri, 14 Jan 2011 10:47:57 -0800 From: spec...@stat.berkeley.edu To: jonathan.hughes...@live.com CC: r-help@r-project.org Subject: Re: [R] filtering a dataframe with a vector of rownames Jonathan - To make your approach work, you'd need to replace

Re: [R] Problems with TeachingDemos package

2011-01-14 Thread Greg Snow
Do you have R2wd installed and working? Is the Rcomm system working for you? Do you receive any errors or warnings? I just tested it using the R gui under windows and when I do wdtxtStart() without any word documents open a new one starts and the output gets sent there. So there must be

Re: [R] CSV value not being read as it appears

2011-01-14 Thread David Scott
I am a bit confused by this. You are doing a transfer from Excel (.xls or .xlsx) to .csv, then a subset in R and ending up with a couple of entries which are Open rather than Open. So where are they coming from? You say they are not in the original Excel, so that suggests the transfer to .csv

Re: [R] piecewise regression

2011-01-14 Thread vito.muggeo
dear all, The package segmented allows to estimate piecewise linear relationships (*connected* lines, i.e. a gradual change in the slope) with several breakpoints (known or unknown) within (generalized) linear models.. The package also includes some functions for plotting and testing.. Have a

[R] Revolutions Blog: December Roundup

2011-01-14 Thread David Smith
Happy New Year, R users! I write about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you missed them, here are some articles related to R from

[R] Rounding variables in a data frame

2011-01-14 Thread Pete B
Hi All I am trying to use the round function on some columns of a dataframe while leaving others unchanged. I wish to specify those columns to leave unchanged. My attempt is below - here, I would like the column d3 to be left but columns d1, d2 and d4 to be rounded to 0 decimal places. I would

Re: [R] Rounding variables in a data frame

2011-01-14 Thread Bill.Venables
If you can specify the omitted columns as numbers there is a quick way to do it. e.g. d d1 d2d3d4 1 9.586524 4.833417 0.8142588 -3.237877 2 11.481521 6.536360 2.3361894 -4.042314 3 10.243192 5.506440 2.0443788 -3.478543 4 9.969548 6.159666 3.0449121

Re: [R] Rounding variables in a data frame

2011-01-14 Thread Joshua Wiley
Hi Pete, Here is one option. The first part of sapply() just serves to get all names of d except those you excluded in 'exc'. If you were including fewer variables than you were excluding, just get rid of the logical ! operator. d - data.frame(d1 = rnorm(10, 10), d2 = rnorm(10, 6), d3 =

[R] Weighted least squares regression for an exponential decay function

2011-01-14 Thread Erik Thulin
Hello, I have a data set of data which is best fit by an exponential decay function. I would like to use a nonlinear weighted least squares regression. What function should I be using? Thank you! [[alternative HTML version deleted]] __

Re: [R] Weighted least squares regression for an exponential decay function

2011-01-14 Thread Bill.Venables
nls in the stats package. ?nls From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Erik Thulin [ethu...@gmail.com] Sent: 15 January 2011 16:16 To: r-help@r-project.org Subject: [R] Weighted least squares regression for an

Re: [R] Rounding variables in a data frame

2011-01-14 Thread Phil Spector
Is sapply really necessary here? exc = !names(d) %in% d3 d[,exc] = round(d[,exc]) d d1 d2 d3 d4 1 10 6 2.3749642 -4 2 11 6 -0.2081097 -2 3 10 4 1.2675955 -4 4 10 8 1.2468859 -2 5 10 6 2.7193027 -4 6 9 6 1.9195531 -5 7 9 6 2.8188036 -6 8 10 7 2.5755148 -4 9