An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20071203/e67be5be/attachment.pl
restore NAs in residuals
6 messages · rem la, Gabor Grothendieck, Brian Ripley +2 more
Try this:
resid(lm(tt~year, na.action = na.exclude))
1 2 3 4 5 6 7
0.7114894 1.2231383 0.1447872 -1.8035638 -0.8519149 -0.5302660 NA
8 9 10
NA NA 1.1063298
On Dec 3, 2007 10:31 AM, rem la <remisorama at gmail.com> wrote:
Dear All,
I have two vectors:
tt = c(6.87, 7.43, 6.4, 4.5, 5.5, 5.87, NA, NA, NA, 7.7)
year = 1966:1975
Residuals
lm(tt~year)$res
do not contain NAs for the three years of missing temperature tt. Is there a
simple way to get these NAs back into the residual's vector?
Thank you,
Sorama
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
You need to use na.action=na.exclude, _and_ to use the proper extractor function residuals() rather than pick up a component of the fitted object by partial matching. See ?residuals.lm and ?naresid
On Mon, 3 Dec 2007, rem la wrote:
Dear All, I have two vectors: tt = c(6.87, 7.43, 6.4, 4.5, 5.5, 5.87, NA, NA, NA, 7.7) year = 1966:1975 Residuals lm(tt~year)$res do not contain NAs for the three years of missing temperature tt. Is there a simple way to get these NAs back into the residual's vector? Thank you, Sorama
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hallo, I am trying to import a website and structure it from within R: The following code: data <- scan(file='http://en.wikipedia.org/wiki/Special:Recentchanges',what='character') results in the error: Error in file(file, "r") : unable to open connection In addition: Warning message: cannot open: HTTP status was '403 Forbidden' in: file(file, "r") It seems that the error is connected to the UTF-8-format of wikipedia, since the following line works: data <- scan(file='http://www.google.de',what='character') I am looking forward to your answers. Greetings Marc Schwenzer
Hello Works fine for me:
data
<-scan(file='http://en.wikipedia.org/wiki/Special:Recentchanges',what='c haracter') Read 3581 items
So I don't think it is the Wikipedia end. Regards John Seers --- -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of EUROPOL Sent: 03 December 2007 16:51 To: r-help at stat.math.ethz.ch Subject: [R] Problem with scan() from UTF-8 encoded URL Hallo, I am trying to import a website and structure it from within R: The following code: data <- scan(file='http://en.wikipedia.org/wiki/Special:Recentchanges',what='cha racter') results in the error: Error in file(file, "r") : unable to open connection In addition: Warning message: cannot open: HTTP status was '403 Forbidden' in: file(file, "r") It seems that the error is connected to the UTF-8-format of wikipedia, since the following line works: data <- scan(file='http://www.google.de',what='character') I am looking forward to your answers. Greetings Marc Schwenzer ______________________________________________ R-help at 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.
, Thank you for trying. Strange. I am using R version 2.6.0 Patched (2007-11-09 r43408) on OSX and it is not working. I guess it has something to do with the language settings. However. Regards Marc Schwenzer
john seers (IFR) wrote:
Hello Works fine for me:
data
<-scan(file='http://en.wikipedia.org/wiki/Special:Recentchanges',what='c haracter') Read 3581 items So I don't think it is the Wikipedia end. Regards John Seers --- -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of EUROPOL Sent: 03 December 2007 16:51 To: r-help at stat.math.ethz.ch Subject: [R] Problem with scan() from UTF-8 encoded URL Hallo, I am trying to import a website and structure it from within R: The following code: data <- scan(file='http://en.wikipedia.org/wiki/Special:Recentchanges',what='cha racter') results in the error: Error in file(file, "r") : unable to open connection In addition: Warning message: cannot open: HTTP status was '403 Forbidden' in: file(file, "r") It seems that the error is connected to the UTF-8-format of wikipedia, since the following line works: data <- scan(file='http://www.google.de',what='character') I am looking forward to your answers. Greetings Marc Schwenzer
______________________________________________ R-help at 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.