[R] problem reading from serial connection since 2.10.0

2009-12-29 Thread Tom Gottfried
Dear list,

I have a balance connected to the serial port of a windows machine (COM1) and 
I read the text
output of the balance with

scan(COM1, what=character, sep=\n, n=1)

after calling the previous line I press the print key on the balance which 
triggers sending one line
of text to the serial connection and with R 2.9.2 I get something like

Read 1 item
+  32.004 mg

Now with R 2.10.1 (and previously with 2.10.0) I have to press the print key on 
the balance twice to
get the same result, thus apparently I have to send two lines of text to make 
scan() reading only
one. But this is only when reading from the serial port, not when reading from 
a text file on disk.
The same is true for 2.10.1 on Linux (I did not try 2.9.2 nor 2.10.0 on Linux).
I can't figure out from the documentation nor the NEWS whether something should 
be specified
differently when calling scan since 2.10.0. Any ideas what this behaviour comes 
from?

Here the sessionInfo() for the three cases I have tested:
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  grDevices utils datasets
[6] methods   base

respectively:

R version 2.10.1 (2009-12-14)
i386-pc-mingw32

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

respectively:
R version 2.10.1 (2009-12-14)
x86_64-unknown-linux-gnu

locale:
 [1] LC_CTYPE=de_DE.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=de_DE.UTF-8LC_COLLATE=de_DE.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=de_DE.UTF-8
 [7] LC_PAPER=de_DE.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils methods   base

other attached packages:
[1] lattice_0.17-26 RODBC_1.3-1

loaded via a namespace (and not attached):
[1] grid_2.10.1

Thanks a lot!
Tom

__
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.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how do I plot a regression curve with the data?

2009-10-28 Thread Tom Gottfried
?curve

regards,
Tom

Ken Ervin schrieb:
 I have a data set of 6 or so ordered pairs, and I've been able to graph
 them and have decided to use a high-order polynomial regression.  I've
 used the following piece of code:
 
 regression - function(x,y) {
x - c(insert_numbers_here)
y - c(insert_other_numbers_here)
fit - lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) + I(x^7)
 + I(x^8) + I(x^9))
summary(fit)
 
 This gives me the coefficients for the regression very nicely, but I
 would like to plot both the data and the regression curve together.  How
 do I plot that regression curve as a function, and can I put it on the
 same set of axes as my data scatter plot?
 
 Thanks in advance for your help!
 
 -KE
 
 __
 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.html
 and provide commented, minimal, self-contained, reproducible code.

__
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.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-24 Thread Tom Gottfried
I think it would be much easier to use grid-graphics for your task.  
It's made for such things.


This is a good introduction:
Paul Murrell. The grid graphics package. R News, 2(2):14-19, June 2002

Tom

__
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.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-23 Thread Tom Gottfried
Janke,

Janke ten Holt schrieb:
 Dear list,
 
 I would like to produce a matrix of plots, where par() is reset after
 each plot (see below [simplified] example). When I use layout() to do
 so, I seem to also reset the layout. I have not been able to figure out
 how to prevent this from happening.
 
 Any help is greatly appreciated!
 Janke
 
 Example code:
 #Desired result is a layout of 2 plots: one red and one black
 layout(matrix(1:2, nr=2))
 par.ini - par(no.readonly=TRUE)

look at par.ini: it's a list with all the argument-value pairs for par(). You 
might be able to solve
your problem by removing the appropriate elements from par.ini before calling 
par(par.ini). Do the
following to look which ones need to be kept for the layout:

par()
layout(matrix(1:2, nr=2))
par()

Tom

 par(col=red)
 plot(1:100)
 
 par(par.ini)
 
 plot(1:10)
 
 --
 Janke ten Holt
 Dept. of Psychology/Sociology
 University of Groningen, the Netherlands
 
 __
 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.html
 and provide commented, minimal, self-contained, reproducible code.

__
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.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Change positions of columns in data frame

2009-10-23 Thread Tom Gottfried
You can change the order of nearly everything just by applying an appropriate 
index and assigning to
the original object. Something like

data - data[,order_of_columns]

Tom

Joel Fürstenberg-Hägg schrieb:
 Hi all,
 
 Probably a simple question, but I just can't find a simple answear in the 
 older threads or anywhere else.
 
 I've added some new vectors as columns in a data frame using cbind(). As 
 they're all put as the last columns inte the data frame, I would like to move 
 them to specific positions. How do you do to change the position of a column 
 in a data frame?
 
 I know I can use 
 fieldTrial0809=data.frame(Sample_ID=as.factor(fieldTrial0809$Sample_ID), 
 Plant_ID=as.factor(fieldTrial0809$Plant_ID), ...) to create a new data frame 
 with the given columns in the specified order, but there must be an easier 
 way..?
 
 All the best,
 
 Joel
 
 _
 Nya Windows 7 - Hitta en dator som passar dig! Mer information. 
 http://windows.microsoft.com/shop
   [[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-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Am Hochanger 1
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax:   ++49 (0)8161 713243
email: tom.gottfr...@wzw.tum.de
http://www.wzw.tum.de/gruenland

__
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.html
and provide commented, minimal, self-contained, reproducible code.