Re: [R] Remove duplicated rows

2010-04-26 Thread chrisli1223

Thank you Petr, Gustaf and Gabor. Your help is much appreciated.

I have tried:

dataset[!duplicated(dataset[,-2]),]

and it solves my problem.

Thanks,
Chris
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Remove-duplicated-rows-tp2023065p2065997.html
Sent from the R help mailing list archive at Nabble.com.

__
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] User inputs

2010-04-22 Thread chrisli1223

Thank you very much Dieter and Don. This solves my problem. :)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/User-inputs-tp2018251p2023067.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Remove duplicated rows

2010-04-22 Thread chrisli1223

Hi all,

I have a dataset similar to the following

NameDateValue
A   1/01/2000   4
A   2/01/2000   4
A   3/01/2000   5
A   4/01/2000   4
A   5/01/2000   1
B   6/01/2000   2
B   7/01/2000   1
B   8/01/2000   1

I would like R to remove duplicates based on column 1 and 3 only. In
addition, I would like R to remove duplicates based on the underlying and
overlying row only. For example, for A, I would like to remove row 2 only
and keep row 1, 3 and 4.

I have tried: unique() and replicated(), but I do not have much success. I
have also tried: dataset<-c(1,diff(dataset)!=0), but I don't know how to
apply it to this multi-column situation.

Any help would be greatly appreciated.

Thanks in advance,
Chris
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Remove-duplicated-rows-tp2023065p2023065.html
Sent from the R help mailing list archive at Nabble.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-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] User inputs

2010-04-20 Thread chrisli1223

Hi everyone,

I have been searching for answers for the following questions but I don't
have much success. The following questions may actually be quite simple. Any
help would be greatly appreciated.

(1) I have written a script which requires user input. I am using the
readline() command.However, everytime when I run the script, R does not wait
for the user input and proceed to the next line. Is there something like
par(ask=T) to solve this problem?

(2) In my script, I want it to stop running when a certain condition is met.
I have tried using the stop() function, but apparently R only stops reading
that line and start reading the following lines. I have also thought about
quit() but it is not quite what I want. May someone please lead me to the
right function please?

(3) When a minor error happens, I would like to get the user permission by
pressing the return key before the script continues to run. What function
should I be looking at?

Many thanks,
Chris
-- 
View this message in context: 
http://n4.nabble.com/User-inputs-tp2018251p2018251.html
Sent from the R help mailing list archive at Nabble.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-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Words appear to be bolded in the PDF output

2010-04-20 Thread chrisli1223

Problem solved. Yes, I found that the text is overlaid several times!
Thank you very much for your help, greatly appreciated. :)
-- 
View this message in context: 
http://n4.nabble.com/Words-appear-to-be-bolded-in-the-PDF-output-tp2016971p2018219.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Words appear to be bolded in the PDF output

2010-04-19 Thread chrisli1223

Hi all,

I have written a note near each of my graphs using mtext.
mtext(text,side=1,line=4,cex=0.5,adj=0)

Then I have exported the graphs as a PDF file.
pdf(file=name,paper='a4',width=7.27,height=10.69)

The mtext appears OK in R. But it looks like it is bolded in the PDF file.
http://n4.nabble.com/file/n2016971/graph.png 

I am not sure if this is actually my monitor/computer's problem. But I want
to see if it can be fixed in R.

Many thanks,
Chris

-- 
View this message in context: 
http://n4.nabble.com/Words-appear-to-be-bolded-in-the-PDF-output-tp2016971p2016971.html
Sent from the R help mailing list archive at Nabble.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-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Exporting PDF

2010-04-18 Thread chrisli1223

Problem solved. I combined file.exists and while loop to create version
number. Thank you very much for your help.
-- 
View this message in context: 
http://n4.nabble.com/Exporting-PDF-tp2015263p2015366.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Exporting PDF

2010-04-18 Thread chrisli1223

Hi everyone,

I have written a script which exports my graphs as a PDF file using the
function pdf().

For instance, I run the script and it exports a PDF called "version 1". 
Then, I have got a new dataset and want to run the script again. What it
usually does is overwriting "version 1". But I want it to check if "version
1" already exists. If so, then I want the new graphs to be exported as
"version 2", and so on.

Is it possible to do it in R?

Thanks in advance,
Chris
-- 
View this message in context: 
http://n4.nabble.com/Exporting-PDF-tp2015263p2015263.html
Sent from the R help mailing list archive at Nabble.com.

__
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] R exponential regression

2010-01-10 Thread chrisli1223

Thank you very much Murray! Greatly appreciated. :]

Chris

Murray Cooper wrote:
> 
> Chris,
> 
> I haven't seen anyone post a reply yet so thought I'd
> throw in my thoughts. I'm no R expert!
> 
> When you talk about an exponential trend line are you
> refering to:
> 
> 1)  y=ax^b
> or
> 2) y=ae^(bx)
> 
> If 1) then take base10 logs of y and x and then fit them
> with simple linear regression. Then calculate the antilog
> of the residulas and plot these as your trendline.
> 
> If 2) then take natural logs of y and x and follow the rest
> of the procedure described in 1).
> 
> Hope this helps.
> 
> Murray M Cooper, Ph.D.
> Richland Statistics
> 9800 N 24th St
> Richland, MI, USA 49083
> Mail: richs...@earthlink.net
> 
> - Original Message - 
> From: "chrisli1223" 
> To: 
> Sent: Thursday, January 07, 2010 10:33 PM
> Subject: [R] R exponential regression
> 
> 
>>
>> Hi all,
>>
>> I have a dataset which consists of 2 columns. I'd like to plot them on a 
>> x-y
>> scatter plot and fit an exponential trendline. I'd like R to determine
>> the
>> equation for the trendline and display it on the graph.
>>
>> Since I am new to R (and statistics), any advice on how to achieve this 
>> will
>> be greatly appreciated.
>>
>> Many thanks,
>> Chris
>> -- 
>> View this message in context: 
>> http://n4.nabble.com/R-exponential-regression-tp1009449p1009449.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/R-exponential-regression-tp1009449p1010914.html
Sent from the R help mailing list archive at Nabble.com.

__
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] R exponential regression

2010-01-07 Thread chrisli1223

Hi all,

I have a dataset which consists of 2 columns. I'd like to plot them on a x-y
scatter plot and fit an exponential trendline. I'd like R to determine the
equation for the trendline and display it on the graph.

Since I am new to R (and statistics), any advice on how to achieve this will
be greatly appreciated.

Many thanks,
Chris
-- 
View this message in context: 
http://n4.nabble.com/R-exponential-regression-tp1009449p1009449.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Polynomial equation

2010-01-07 Thread chrisli1223

Thank you very much for your help. Greatly appreciated!

However, due to my limited stats background, I am unable to find out the
equation of the trendline from the summary table. Besides, how do I fit the
trendline on the graph?

I intend to put the first column of data onto x axis and the second column
onto y axis. Are they the x and y in your example?

Many thanks,
Chris


Moshe Olshansky-2 wrote:
> 
> Hi Chris,
> 
> You can use lm with poly (look ?lm, ?poly).
> If x and y are your arrays of points and you wish to fit a polynom of
> degree 4, say, enter:  model <- lm(y~poly(x,4,raw=TRUE) and then
> summary(model)
> The raw=TRUE causes poly to use 1,x,x^2,x^3,... instead of orthogonal
> polynomials (which are "better" numerically but may be not what you need).
> 
> Regards,
> Moshe.
> 
> --- On Fri, 8/1/10, chrisli1223  wrote:
> 
>> From: chrisli1223 
>> Subject: [R]  Polynomial equation
>> To: r-help@r-project.org
>> Received: Friday, 8 January, 2010, 12:32 PM
>> 
>> Hi all,
>> 
>> I have got a dataset. In Excel, I can fit a polynomial
>> trend line
>> beautifully. However, the equation that Excel calculates
>> appear to be
>> incorrect. So I am thinking about using R.
>> 
>> My questions are:
>> (1) How do I fit a polynomial trendline to a graph?
>> (2) How do I calculate and display the equation for that
>> trendline?
>> 
>> Many thanks for your help. Greatly appreciated.
>> 
>> Chris
>> -- 
>> View this message in context:
>> http://n4.nabble.com/Polynomial-equation-tp1009398p1009398.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> __
>> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Polynomial-equation-tp1009398p1009438.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Polynomial equation

2010-01-07 Thread chrisli1223

Hi all,

I have got a dataset. In Excel, I can fit a polynomial trend line
beautifully. However, the equation that Excel calculates appear to be
incorrect. So I am thinking about using R.

My questions are:
(1) How do I fit a polynomial trendline to a graph?
(2) How do I calculate and display the equation for that trendline?

Many thanks for your help. Greatly appreciated.

Chris
-- 
View this message in context: 
http://n4.nabble.com/Polynomial-equation-tp1009398p1009398.html
Sent from the R help mailing list archive at Nabble.com.

__
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] R treating time

2010-01-06 Thread chrisli1223

Hi all,

I have imported a value 3:00 from Excel into R using read.csv. I want R to
recognise it as 3:00am (time data). How do I do it?

Thanks in advance,
Chris
-- 
View this message in context: 
http://n4.nabble.com/R-treating-time-tp1008608p1008608.html
Sent from the R help mailing list archive at Nabble.com.

__
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.