Re: [R] sorting a data.frame by mean values of grouped data
Thanks Mark, I see that I made an error in my original request for help. I got my labels and groups mixed up (see below). Nonetheless, your code has been a good pointer in the direction of a solution. I'll post it up when I have it working. Thanks again, Stephen Barry. I should have written it more like this: Given data.frame: Value Group Label 55 D Small 33 D Small 11 D Small 55 D Small 66 D Small 11 D Small 19 A Big 29 A Big 39 A Big 3 B Small 2 B Small 5 B Small 6 B Small 5 B Small 6 B Small 2 C Big 3 C Big 3 C Big 3 C Big 3 C Big 3 C Big 3 C Big end up with: Value Group Label 19 A Big 29 A Big 39 A Big 2 C Big 3 C Big 3 C Big 3 C Big 3 C Big 3 C Big 3 C Big 55 D Small 33 D Small 11 D Small 55 D Small 66 D Small 11 D Small 3 B Small 2 B Small 5 B Small 6 B Small 5 B Small 6 B Small > Mark W Kimpel wrote: > Stephen, > > I am sure someone will have a more elegant solution, but the following > works. Mark > > d.lst <- split(x = d, f = as.factor(d$Group), drop = FALSE) > d.lst.mn <- sapply(d.lst, FUN = > function(x){mean(as.numeric(as.character(x$Value)))}) > o <- order(d.lst.mn, decreasing = TRUE) > d.lst.mn <- d.lst.mn[o] > > e <- NULL > for (i in 1:length(d.lst.mn)){ > if (i == 1){ > e <- d[d$Group == names(d.lst.mn)[i],] > } else { > e <- rbind(e, d[as.character(d$Group) == names(d.lst.mn)[i],]) > } > } > e > > Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry > Indiana University School of Medicine > > 15032 Hunter Court, Westfield, IN 46074 > > (317) 490-5129 Work, & Mobile & VoiceMail > (317) 204-4202 Home (no voice mail please) > > mwkimpelgmailcom > > ** > > > sjbarry wrote: >> Hi, >> >> I have what I think is a fairly straightforward problem. I've looked >> through the FAQ's and mailing lists but have been unable to identify >> a solution, probably because I don't understand the language well >> enough. >> >> I have a set of data d, with 3 columns as shown, >> I want to sort the data Group, mean(Value by Label). I know that this >> can be done for one level, say Label, using factor() but I cannot see >> how to extend that. I have included the code to create the data.frame >> below and would greatly appreciate a solution or a link to a similar >> problem that has already been solved in the mailing list. >>Value Label Group >> 19 Big A >> 29 Big A >> 39 Big A >> 55 Small D >> 33 Small D >> 11 Small D >> 55 Small D >> 66 Small D >> 11 Small D >> 2 Big C >> 3 Big C >> 3 Big C >> 3 Big C >> 3 Big C >> 3 Big C >> 3 Big C >> 3 Small B >> 2 Small B >> 5 Small B >> 6 Small B >> 5 Small B >> 6 Small B >> >> Value <- c(19,29,39,55,33,11,55,66,11,2,3,3,3,3,3,3,3,2,5,6,5,6) >> Group <- c("A","A","A","D","D","D","D","D","D", >> "C","C","C","C","C","C","C","B","B","B","B","B","B") >> Label <- c("Big","Big","Big", >> "Small","Small","Small","Small","Small","Small", >> "Big","Big","Big","Big","Big","Big","Big", >> "Small","Small","Small","Small","Small","Small") >> d <- as.data.frame(cbind(Value, Label, Group)) >> >> >> Thanks >> >> Stephen Barry >> -- Stephen Barry School of Earth and Environmental Sciences University of Wollongong Northfields Ave. Wollongong, NSW. 2522 Australia __ 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] survival analysis and censoring
Dear Prof. Therneau, Many thanks for this, On 3/13/08, Terry Therneau <[EMAIL PROTECTED]> wrote: > > In your particular case I don't think that censoring is an issue, at least > not > for the reason that you discuss. The basic censoring assumption in the Cox > model is that subjects who are censored have the same future risk as those > who > were a. not censored and b. have the same covariates. >The real problem with informative censoring are the covaraites that are not > in the model; ones that I likely don't even know exist. Assume for instance > that some unknown exposure X, Perth sunlight say, makes people much more > likely > to get both of the outcomes. Assume further that it matters, i.e., the study > includes a reasonable number of people with and without this exposure. Then > someone who has an early heart attack actually has a higher risk of > colorectal > cancer than a colleague of the same age/sex/followup who did not have a heart > attack, the reason being that the HA guy is more likely to be from Perth. > >Your simulation went wrong by not actually accounting for time. You > created > an outcome table for CC & HD and added a random time vector to it. If > someone > would have had CC at 2 years and now has HD at 1 year, you can't just change > the > status to make them censored at 2. The gambling analogy would be kicking > someone out of the casino just before they win -- it does odd things to the > odds. I'm still astonished that this is the explanation, but I've spent an hour playing with my little R code model and this is exactly the problem. Score 1 for solid maths and 0 for my intuition. Many Thanks, Geoff > >Terry Therneau > > > __ 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] sorting a data.frame by mean values of grouped data
Stephen, I am sure someone will have a more elegant solution, but the following works. Mark d.lst <- split(x = d, f = as.factor(d$Group), drop = FALSE) d.lst.mn <- sapply(d.lst, FUN = function(x){mean(as.numeric(as.character(x$Value)))}) o <- order(d.lst.mn, decreasing = TRUE) d.lst.mn <- d.lst.mn[o] e <- NULL for (i in 1:length(d.lst.mn)){ if (i == 1){ e <- d[d$Group == names(d.lst.mn)[i],] } else { e <- rbind(e, d[as.character(d$Group) == names(d.lst.mn)[i],]) } } e Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 204-4202 Home (no voice mail please) mwkimpelgmailcom ** sjbarry wrote: > Hi, > > I have what I think is a fairly straightforward problem. I've looked > through the FAQ's and mailing lists but have been unable to identify a > solution, probably because I don't understand the language well enough. > > I have a set of data d, with 3 columns as shown, > I want to sort the data Group, mean(Value by Label). I know that this > can be done for one level, say Label, using factor() but I cannot see > how to extend that. I have included the code to create the data.frame > below and would greatly appreciate a solution or a link to a similar > problem that has already been solved in the mailing list. >Value Label Group > 19 Big A > 29 Big A > 39 Big A > 55 Small D > 33 Small D > 11 Small D > 55 Small D > 66 Small D > 11 Small D > 2 Big C > 3 Big C > 3 Big C > 3 Big C > 3 Big C > 3 Big C > 3 Big C > 3 Small B > 2 Small B > 5 Small B > 6 Small B > 5 Small B > 6 Small B > > Value <- c(19,29,39,55,33,11,55,66,11,2,3,3,3,3,3,3,3,2,5,6,5,6) > Group <- c("A","A","A","D","D","D","D","D","D", > "C","C","C","C","C","C","C","B","B","B","B","B","B") > Label <- c("Big","Big","Big", > "Small","Small","Small","Small","Small","Small", > "Big","Big","Big","Big","Big","Big","Big", > "Small","Small","Small","Small","Small","Small") > d <- as.data.frame(cbind(Value, Label, Group)) > > > Thanks > > Stephen Barry > __ 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] sorting a data.frame by mean values of grouped data
Hi, I have what I think is a fairly straightforward problem. I've looked through the FAQ's and mailing lists but have been unable to identify a solution, probably because I don't understand the language well enough. I have a set of data d, with 3 columns as shown, I want to sort the data Group, mean(Value by Label). I know that this can be done for one level, say Label, using factor() but I cannot see how to extend that. I have included the code to create the data.frame below and would greatly appreciate a solution or a link to a similar problem that has already been solved in the mailing list. Value Label Group 19 Big A 29 Big A 39 Big A 55 Small D 33 Small D 11 Small D 55 Small D 66 Small D 11 Small D 2 Big C 3 Big C 3 Big C 3 Big C 3 Big C 3 Big C 3 Big C 3 Small B 2 Small B 5 Small B 6 Small B 5 Small B 6 Small B Value <- c(19,29,39,55,33,11,55,66,11,2,3,3,3,3,3,3,3,2,5,6,5,6) Group <- c("A","A","A","D","D","D","D","D","D", "C","C","C","C","C","C","C","B","B","B","B","B","B") Label <- c("Big","Big","Big", "Small","Small","Small","Small","Small","Small", "Big","Big","Big","Big","Big","Big","Big", "Small","Small","Small","Small","Small","Small") d <- as.data.frame(cbind(Value, Label, Group)) Thanks Stephen Barry -- School of Earth and Environmental Sciences University of Wollongong Northfields Ave. Wollongong, NSW. 2522 Australia __ 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] regular expressions
Try this one: > gsub("^(plif)([a-z]*)", "\\1ONE", words) [1] "plifONE" "plafboum" "ploufbang" "plifONE" -Christos > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of GOUACHE David > Sent: Wednesday, March 12, 2008 12:15 PM > To: [EMAIL PROTECTED] > Subject: [R] regular expressions > > Hello all, > > Still fighting with regular expressions and such, I am again stuck: > > Suppose I have a vector of character chains. In this vector, > I wish to identify which character chains start with a given > pattern, and then replace everything that comes after said pattern. > > Here is a quick example : > > words<-c("plifboum","plafboum","ploufbang","plifplaf") > > I want to end up with something like this: > > "plifONE","plafboum","ploufbang","plifONE" > > All I can produce so far is this : > gsub("\\bplif.","ONE",words,perl=T) > > which turns out : > "ONEboum","plafboum","ploufbang","ONEplaf" > > Thanks in advance for your help. > > David Gouache > > Arvalis - Institut du Végétal > > Station de La Minière > > 78280 Guyancourt > > Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 > > > > > __ > 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.
[R] regular expressions
Hello all, Still fighting with regular expressions and such, I am again stuck: Suppose I have a vector of character chains. In this vector, I wish to identify which character chains start with a given pattern, and then replace everything that comes after said pattern. Here is a quick example : words<-c("plifboum","plafboum","ploufbang","plifplaf") I want to end up with something like this: "plifONE","plafboum","ploufbang","plifONE" All I can produce so far is this : gsub("\\bplif.","ONE",words,perl=T) which turns out : "ONEboum","plafboum","ploufbang","ONEplaf" Thanks in advance for your help. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 __ 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] Data Structures
?list On 13/03/2008, at 3:50 PM, Scott Romans wrote: > Matlab has an aggregate variable called a structure, which consists of > component variables each of which can be of a different data type and > dimension. For example, I can have a single structure Model which > consists of Model.variable1, Model.variable2, and Model.variable3, > where variable1 is a string variable, variable 2 is a 1x24 vector, and > variable 3 is a 6x6x6 array. The benefit is that the aggregate > variable Model can be passed between programs without having to pass > each of the component variables. Does R have anything similar? > > __ > 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. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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] Data Structures
Hello - Scott Romans wrote: > Matlab has an aggregate variable called a structure, which consists of > component variables each of which can be of a different data type and > dimension. For example, I can have a single structure Model which > consists of Model.variable1, Model.variable2, and Model.variable3, > where variable1 is a string variable, variable 2 is a 1x24 vector, and > variable 3 is a 6x6x6 array. The benefit is that the aggregate > variable Model can be passed between programs without having to pass > each of the component variables. Does R have anything similar? > These are objects of class "list" in R and play a very important role when using and programming R. See ?list, "An Introduction to R" on CRAN, or any introductory book on R to learn about lists. Best, Erik Iverson > __ > 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.
[R] Data Structures
Matlab has an aggregate variable called a structure, which consists of component variables each of which can be of a different data type and dimension. For example, I can have a single structure Model which consists of Model.variable1, Model.variable2, and Model.variable3, where variable1 is a string variable, variable 2 is a 1x24 vector, and variable 3 is a 6x6x6 array. The benefit is that the aggregate variable Model can be passed between programs without having to pass each of the component variables. Does R have anything similar? __ 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] Convert a List of Distances to a Distance Matrix
Here is one way of doing it: > x <- read.table(textConnection("A A 0 + A B .5 + A C .25 + B C .5"), as.is=TRUE) > closeAllConnections() > # get the unique names > x.names <- sort(unique(c(x[[1]], x[[2]]))) > # create a matrix of the right size and put names on it > x.dist <- matrix(0, length(x.names), length(x.names)) > dimnames(x.dist) <- list(x.names, x.names) > # create indices by converting names to numbers and create the normal and > reversed > # to fill in all the matrix > x.ind <- rbind(cbind(match(x[[1]], x.names), match(x[[2]], x.names)), +cbind(match(x[[2]], x.names), match(x[[1]], x.names))) > x.dist[x.ind] <- rep(x[[3]], 2) > x.dist A BC A 0.00 0.5 0.25 B 0.50 0.0 0.50 C 0.25 0.5 0.00 > On Wed, Mar 12, 2008 at 7:45 PM, Charles Willis <[EMAIL PROTECTED]> wrote: > Hello, > > Is there an easy function for switching list to matrix. My list is of > genetic distances between species pairs: > > A A 0 > A B .5 > A C .25 > B C .5 > > and I want a distance matrix such as: > > A B C > A 0 .5 .25 > B .5 0 .5 > C .25 .5 0 > > for use in a mantel test. > > Thank you for the help! > > cheers, > charlie > > -- > ~~ > Charles G. Willis > Department of Organismic and Evolutionary Biology > 22 Divinity Ave Cambridge MA 02139 > HP (857) 488-2506 > WP (617) 496-3890 > [EMAIL PROTECTED] > http://www.people.fas.harvard.edu/%7Ecgwillis/ > ~~ > >[[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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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] type of object of a variable in a data frame
is(data$V1) Have a look at the refcard that you can download from cran.r-project.org or please take a look at one of the many other manuals that are provided there for free (many manuals are also available elsewhere on the internet, so you can google them). Almost all of them answer these basic questions. (Sorry for not giving credit to the one who has written the refcard, but it slipped my mind who.) Also you can type help.search("put your search term here") or RSiteSearch("put your search term here") to check whether your question has been addressed by others before. Cheers. - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Chang Liu Gesendet: Wednesday, March 12, 2008 7:18 PM An: R Help Betreff: [R] type of object of a variable in a data frame Hello! I have used read.csv to read in a data frame, and there are a few variables in it, however, when I tried is.list(data$V1) >FALSE In fact, I have tried, they are not vectors either. I'm wondering: 1. What objects are these "lists" of data? 2. How could I find out about the type/inheritence of an object in general? 3. The reason I want it to be a list or vector, is that I want to fill in some blank values, i can't seem to do things like: data$V1[1] = 3 Is it because these variables are pointers? Is there a better way to do this? Sorry to cram so many questions in one email! Karen _ l. Click here to learn how. [[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-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] transpose dataset
if x is your data: t(x) - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Felipe Carrillo Gesendet: Wednesday, March 12, 2008 8:19 PM An: [EMAIL PROTECTED] Betreff: [R] transpose dataset Hi all: How can I transpose this dataset from column to row idweek value 1 5 51 2 6 73 3 7 41 4 8 22 5 9 83 6 10 55 7 11 42 to something like this... id1 2 3 4 5 6 7 week 5 6 7 8 9 10 11 value 51 73 41 22 83 55 42 Felipe D. Carrillo Fishery Biologist US Fish & Wildlife Service California, USA __ 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.
[R] Convert a List of Distances to a Distance Matrix
Hello, Is there an easy function for switching list to matrix. My list is of genetic distances between species pairs: A A 0 A B .5 A C .25 B C .5 and I want a distance matrix such as: A B C A 0 .5 .25 B .5 0 .5 C .25 .5 0 for use in a mantel test. Thank you for the help! cheers, charlie -- ~~ Charles G. Willis Department of Organismic and Evolutionary Biology 22 Divinity Ave Cambridge MA 02139 HP (857) 488-2506 WP (617) 496-3890 [EMAIL PROTECTED] http://www.people.fas.harvard.edu/%7Ecgwillis/ ~~ [[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] Distances between two datasets of x and y co-ordinates
Here's what I would try. Suppose x1, y1 and x2, y2 are the two data sets. z1 <- complex(real = x1, imaginary = y1) z2 <- complex(real = x2, imaginary = y2) dMat <- outer(z1, z2, function(z1, z2) Mod(z1-z2)) Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew McFadden Sent: Thursday, 13 March 2008 6:47 AM To: r-help@r-project.org Subject: [R] Distances between two datasets of x and y co-ordinates Hi all I am trying to determine the distances between two datasets of x and y points. The number of points in dataset One is very small i.e. perhaps 5-10. The number of points in dataset Two is likely to be very large i.e. 20,000-30,000. My initial approach was to append the first dataset to the second and then carry out the calculation: dists <- as.matrix(dist(gis data from 2 * datasets)) However, the memory of the computer is not sufficient. A lot of calculations carried out in this situation are unnecessary as I only want approx 5 * 20,000 calculations versus 20,000 *20,000. x <- c(2660156,2663703,2658165,2659303,2661531,2660914) y <- c(6476767,6475013,6475487,6479659,6477004,6476388) data2<-cbind(x,y) x <- c(266500,261) y <- c(6478767,6485013) data1<-cbind(x,y) Any suggestions on how to do this would be appreciated. Regards Andrew Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St Upper Hutt This email message and any attachment(s) is intended solely for the addressee(s) named above. The information it contains is confidential and may be legally privileged. Unauthorised use of the message, or the information it contains, may be unlawful. If you have received this message by mistake please call the sender immediately on 64 4 8940100 or notify us by return email and erase the original message and attachments. Thank you. The Ministry of Agriculture and Forestry accepts no responsibility for changes made to this email or to any attachments after transmission from the office. [[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-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] transpose dataset
Hi all: How can I transpose this dataset from column to row idweek value 1 5 51 2 6 73 3 7 41 4 8 22 5 9 83 6 10 55 7 11 42 to something like this... id1 2 3 4 5 6 7 week 5 6 7 8 9 10 11 value 51 73 41 22 83 55 42 Felipe D. Carrillo Fishery Biologist US Fish & Wildlife Service California, USA __ 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] Specifying relative position of text in a plot
Here is one way. ... usr <- par("usr") # get user coordinates par(usr = c(0, 1, 0, 1)) # new relative user coordinates text(0.1, 0.5, "Some text", adj = 0) # if that's what you want par(usr = usr) # restore original user coordinates ... If you were going to be doing this a lot, you could write a simple wrapper function to text(...) to incorporate this change to relative coordinates and back again. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom La Bone Sent: Thursday, 13 March 2008 12:34 AM To: r-help@r-project.org Subject: [R] Specifying relative position of text in a plot What is the simplest way to specify the location of text in a scatter plot (created using the plot function) in relative terms rather than specific x-y coordinates? For example, rather than putting text at (300,49) on a plot, how do I put it 1/10 of the way over from the y axis and 1/2 of the way up from the x axis? Thanks. Tom -- View this message in context: http://www.nabble.com/Specifying-relative-position-of-text-in-a-plot-tp1 6002549p16002549.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.
[R] survival curve for only certain values of a factor
Hello: Using the built-in dataset aml as an example: data(aml) If I use instead dummy variables: aml$x1 = (aml$x=="maintained")aml$x2 = (aml$x=="unmaintained") and I want to plot the survival curve using x1, x2, and I just want the 2 levels, rather than 4 curves from: fit <- survfit(Surv(time, status) ~ x1+x2, data=aml) plot(fit) I guess because there are 2 levels for each variable? Thanks! p.s. I need to do this more because my dummies are not good to combine and I want to be able to work with them separately also, not becuase I'm crazy! _ Create a handy button so your friends can add U to their buddy list. Try it now! [[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] subset list based on logical within element flag
Try: > names(which(my_list == 'Fred')) [1] "name" You can break down the two nested calls to figure out what is happening. -Christos > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Srinivas Iyyer > Sent: Wednesday, March 12, 2008 6:53 PM > To: Benilton Carvalho; [EMAIL PROTECTED] > Cc: R Help > Subject: Re: [R] subset list based on logical within element flag > > Hi I have the smililar question. > > I have a list: > my_list <- list(name="Fred", wife="Mary", no.children=3, > child.ages=c(4,7,9)) > > > > my_list > $name > [1] "Fred" > > $wife > [1] "Mary" > > $no.children > [1] 3 > > $child.ages > [1] 4 7 9 > > > Now I want to search "Fred" and get attribute of that value > which is 'name'. > > how do I get it. > > > match(my_list,"Fred") > [1] 1 NA NA NA > > my thinking stops right here... > > list operations in R is too tough to digest and there is not > good documentations. > > Could any one please help. > > thanks > Srini > > > > > > > > --- Benilton Carvalho <[EMAIL PROTECTED]> wrote: > > > gene.pair.tf.lst[sapply(gene.pair.tf.lst, "[[", "sig.cor")] > > > > b > > > > > > On Mar 12, 2008, at 5:24 PM, Mark W Kimpel wrote: > > > > > I have a very long list that I'd like to subset > > based on a logical > > > value > > > within each element. Example below. I'd like to > > get just those list > > > elements for further study whose $sig.cor slot is > > TRUE. In this > > > example, > > > I'd only want element [[2]]. > > > > > > Should be simple, I know. How can I do this? > > Thanks, Mark > > > > > >> gene.pair.tf.lst > > > [[1]] > > > [[1]]$gene.pair > > > [1] "Lgals1:Pxmp2" > > > > > > [[1]]$sig.cor > > > [1] FALSE > > > > > > > > > [[2]] > > > [[2]]$gene.pair > > > [1] "Lgals1:Pxmp2" > > > > > > [[2]]$sig.cor > > > [1] TRUE > > > > > > > > > [[3]] > > > [[3]]$gene.pair > > > [1] "Lgals1:Pxmp2" > > > > > > [[3]]$sig.cor > > > [1] FALSE > > > -- > > > > > > Mark W. Kimpel MD ** Neuroinformatics ** Dept. of > > Psychiatry > > > Indiana University School of Medicine > > > > > > 15032 Hunter Court, Westfield, IN 46074 > > > > > > (317) 490-5129 Work, & Mobile & VoiceMail > > > (317) 204-4202 Home (no voice mail please) > > > > > > mwkimpelgmailcom > > > > > > __ > > > 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. > > > > __ > 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] type of object of a variable in a data frame
class(data) class(data$V1) str(data) str(data$V1) dput(data) dput(data$V1) On Wed, Mar 12, 2008 at 7:17 PM, Chang Liu <[EMAIL PROTECTED]> wrote: > > Hello! > I have used read.csv to read in a data frame, and there are a few variables > in it, however, when I tried > is.list(data$V1) > >FALSE > In fact, I have tried, they are not vectors either. > > I'm wondering: > 1. What objects are these "lists" of data? > 2. How could I find out about the type/inheritence of an object in general? > 3. The reason I want it to be a list or vector, is that I want to fill in > some blank values, i can't seem to do things like: > data$V1[1] = 3 > Is it because these variables are pointers? Is there a better way to do this? > > Sorry to cram so many questions in one email! > > Karen > _ > > l. Click here to learn how. > >[[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-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] type of object of a variable in a data frame
Hello! I have used read.csv to read in a data frame, and there are a few variables in it, however, when I tried is.list(data$V1) >FALSE In fact, I have tried, they are not vectors either. I'm wondering: 1. What objects are these "lists" of data? 2. How could I find out about the type/inheritence of an object in general? 3. The reason I want it to be a list or vector, is that I want to fill in some blank values, i can't seem to do things like: data$V1[1] = 3 Is it because these variables are pointers? Is there a better way to do this? Sorry to cram so many questions in one email! Karen _ l. Click here to learn how. [[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] subset list based on logical within element flag
Hi I have the smililar question. I have a list: my_list <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9)) > my_list $name [1] "Fred" $wife [1] "Mary" $no.children [1] 3 $child.ages [1] 4 7 9 Now I want to search "Fred" and get attribute of that value which is 'name'. how do I get it. > match(my_list,"Fred") [1] 1 NA NA NA my thinking stops right here... list operations in R is too tough to digest and there is not good documentations. Could any one please help. thanks Srini --- Benilton Carvalho <[EMAIL PROTECTED]> wrote: > gene.pair.tf.lst[sapply(gene.pair.tf.lst, "[[", > "sig.cor")] > > b > > > On Mar 12, 2008, at 5:24 PM, Mark W Kimpel wrote: > > > I have a very long list that I'd like to subset > based on a logical > > value > > within each element. Example below. I'd like to > get just those list > > elements for further study whose $sig.cor slot is > TRUE. In this > > example, > > I'd only want element [[2]]. > > > > Should be simple, I know. How can I do this? > Thanks, Mark > > > >> gene.pair.tf.lst > > [[1]] > > [[1]]$gene.pair > > [1] "Lgals1:Pxmp2" > > > > [[1]]$sig.cor > > [1] FALSE > > > > > > [[2]] > > [[2]]$gene.pair > > [1] "Lgals1:Pxmp2" > > > > [[2]]$sig.cor > > [1] TRUE > > > > > > [[3]] > > [[3]]$gene.pair > > [1] "Lgals1:Pxmp2" > > > > [[3]]$sig.cor > > [1] FALSE > > -- > > > > Mark W. Kimpel MD ** Neuroinformatics ** Dept. of > Psychiatry > > Indiana University School of Medicine > > > > 15032 Hunter Court, Westfield, IN 46074 > > > > (317) 490-5129 Work, & Mobile & VoiceMail > > (317) 204-4202 Home (no voice mail please) > > > > mwkimpelgmailcom > > > > __ > > 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. > __ 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] Negative/ positive rolling correlation
Hi everybody, I really appeciate the help you have given me. I am getting around R comfortably now and am able to import research project data, do mathematical analysis of the data and produce graphs. My PhD project is going really well in its early days, already collecting data and proposal completed soon! There is one question I have though. I can see that worksheets and history can be saved, however I am beat as to exactly what they save? Do they save the command lines and associated data sheets and graphs? Oh, I'm using Rcmdr. In my case it is an excellent software that cuts hours off my progamming work freeing up time for other parts of the project and breaks, lol! The other, I want to do a correlation to highlight matching patterns between two columns of radon levels (96 lines each) divided by the hour they were recorded in the two machines. A scattergraph is similar but I want to produce visualtisations for negative/ positive correlation against time. Can anyone suggest anything? Thanks. Cheers if you can help. -- View this message in context: http://www.nabble.com/Negative--positive-rolling-correlation-tp16013887p16013887.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] howto find corresponding values in datasource?
Hi, i am sure, that this is a noob-question, but i have searched for hours without any good result. I want to draw a vertical line through the maximum of the first derivation. Here is a small example. --8<-[mydata.csv] HM 115 222 323 417 510 --8<-[myquestion.R]-- mydata <- read.table("mydata.csv", header=TRUE, sep="\t") attach(mydata) # make a smooth fit through the points and calculate the first derivation d/dx myspl <- smooth.spline(H, M, all.knots = FALSE, nknots = 10, spar=0.5) mydiff <- predict(myspl, 0:max(H), deriv=1) # find the maximum peak max(y) y1=y2= max(mydiff$y) # now i want to plot a line through the maximum of the derivation # how can i get the x-coordinate? # segments(x1,y1,x2,y2) detach() --8<- Thank you, -- Jonas Stein __ 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] subset list based on logical within element flag
I'm not sure exactly what you want, but try something like lapply(gene.pair.tf.lst, function(x) if(x$sig.cor) x$gene.pair) If you only want the non-NULL entries (and how would you know which they are, given you have duplicates?) gene.pair.tf.lst <- list(list(gene.pair="Lgals1:Pxmp2", sig.cor=FALSE), list(gene.pair="Lgals1:Pxmp2", sig.cor=TRUE), list(gene.pair="Lgals1:Pxmp2", sig.cor=FALSE)) tmp <- lapply(gene.pair.tf.lst, function(x) if(x$sig.cor) x$gene.pair) tmp[!sapply(tmp, is.null)] On Wed, 12 Mar 2008, Mark W Kimpel wrote: > I have a very long list that I'd like to subset based on a logical value > within each element. Example below. I'd like to get just those list > elements for further study whose $sig.cor slot is TRUE. In this example, > I'd only want element [[2]]. > > Should be simple, I know. How can I do this? Thanks, Mark > > > gene.pair.tf.lst > [[1]] > [[1]]$gene.pair > [1] "Lgals1:Pxmp2" > > [[1]]$sig.cor > [1] FALSE > > > [[2]] > [[2]]$gene.pair > [1] "Lgals1:Pxmp2" > > [[2]]$sig.cor > [1] TRUE > > > [[3]] > [[3]]$gene.pair > [1] "Lgals1:Pxmp2" > > [[3]]$sig.cor > [1] FALSE > -- > > Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry > Indiana University School of Medicine > > 15032 Hunter Court, Westfield, IN 46074 > > (317) 490-5129 Work, & Mobile & VoiceMail > (317) 204-4202 Home (no voice mail please) > > mwkimpelgmailcom > > __ > 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. > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] subset list based on logical within element flag
gene.pair.tf.lst[sapply(gene.pair.tf.lst, "[[", "sig.cor")] b On Mar 12, 2008, at 5:24 PM, Mark W Kimpel wrote: I have a very long list that I'd like to subset based on a logical value within each element. Example below. I'd like to get just those list elements for further study whose $sig.cor slot is TRUE. In this example, I'd only want element [[2]]. Should be simple, I know. How can I do this? Thanks, Mark gene.pair.tf.lst [[1]] [[1]]$gene.pair [1] "Lgals1:Pxmp2" [[1]]$sig.cor [1] FALSE [[2]] [[2]]$gene.pair [1] "Lgals1:Pxmp2" [[2]]$sig.cor [1] TRUE [[3]] [[3]]$gene.pair [1] "Lgals1:Pxmp2" [[3]]$sig.cor [1] FALSE -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 204-4202 Home (no voice mail please) mwkimpelgmailcom __ 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.
[R] subset list based on logical within element flag
I have a very long list that I'd like to subset based on a logical value within each element. Example below. I'd like to get just those list elements for further study whose $sig.cor slot is TRUE. In this example, I'd only want element [[2]]. Should be simple, I know. How can I do this? Thanks, Mark > gene.pair.tf.lst [[1]] [[1]]$gene.pair [1] "Lgals1:Pxmp2" [[1]]$sig.cor [1] FALSE [[2]] [[2]]$gene.pair [1] "Lgals1:Pxmp2" [[2]]$sig.cor [1] TRUE [[3]] [[3]]$gene.pair [1] "Lgals1:Pxmp2" [[3]]$sig.cor [1] FALSE -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 204-4202 Home (no voice mail please) mwkimpelgmailcom __ 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] question for aov and kruskal
I thought your question was well expressed and that you followed the posting guide better than most. I'm no expert on such issues, but I'd like to kick in a few opinions (with which others may disagree). (1) All of the anova stuff is based on the assumption of homogeneity of variance. However my understanding is that the model is quite robust to this assumption. Problems may arise if there are small sample sizes in some cells and if the small samples are associated with large variances. Otherwise there is not all that much of a worry. (2) The Tukey test is indeed based on the assumption of equal sample sizes. The version of the test for unbalanced data is an approximation. My understanding is that it's a pretty good approximation. (3) For multiple comparisons after applying the Kruskal-Wallis test: Experts on non-parametric statistics may know about more powerful methods, but I would be inclined simply to apply a Bonferroni correction to a collection of pairwise tests (e.g. wilcox.test). Just multiply the p- values by the number of pairwise comparisons, k-choose-2 where k is the number of groups (= 3-choose-2 = 3 in your toy example). (4) Generally speaking I would say that if a classical test and a non- parametric test give different answers, then your data are being coy about revealing their true import. I would have very little faith in either answer, and would claim that you really need more data. Unfortunately this need can rarely be satisfied. If you have to make a decision one way or another, then you should go with the non- parametric answer. (5) Finally, my universal prescription is: ``When in doubt, simulate.'' I.e. simulate multiple data sets on the basis of models fitted to, or related to, your real data. Run the possible tests on the simulated data sets. Since these data are simulated, you know what the right answer is. Count up how often you get the right answer. Such an exercise can be quite revealing. HTH cheers, Rolf Turner On 13/03/2008, at 9:19 AM, eugen pircalabelu wrote: > Hi, > > My data was only a toy example that matched the real situation, > with real data, but i could not have posted the entire data.set and > so i gave a self contained example of what i thought was my > problem. Of course you can see with the naked eye that the data is > unbalanced, (this was done intentionally) but like i said this was > only a toy example, mimicking a problem from a real data set. > > Thank you and have a great ahead! > > > David Hewitt <[EMAIL PROTECTED]> wrote: > > >> I have the following problem: how appropriate is my aov model >> under the >> violation of anova assumptions? >> >> Example: >> a<-c(1,1,1,1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,3,3) >> b<-c(101,1010,200,300,400, 202, 121, 234, 55,555,66,76,88,34,239, >> 30, 40, >> 50,50,60) >> z<-data.frame(a, b) >> fligner.test(z$b, factor(z$a)) >> aov(z$b~factor(z$a))->ll >> TukeyHSD(ll) >> >> Now from the aov i found that my model is unbalanced, and from the >> flinger test i found out that the assumption of homogeneity of >> variances >> is rejected. Could my Tukey comparison be a valid one under these >> violations? From what i read the Tukey test is valid only when the >> model >> is balanced and when the assumption of homogeneity of variances is >> not >> rejected, am i wrong? Can anyone tell me what would be the correct >> test in >> this case? >> >> Doing a non-parametric Kruskal - wallis test would give me a >> different >> result. But what would be the correct multiple comparison test in >> this >> case? >> > > You shouldn't have needed aov to tell you that the data (not the > model) are > unbalanced. I could see that without running the code! Seriously, > you might > need to think more about the type of model you're using, and what > you want > to know, and then consider how to estimate the effect sizes of > interest. > > > - > David Hewitt > Virginia Institute of Marine Science > http://www.vims.edu/fish/students/dhewitt/ > -- > View this message in context: http://www.nabble.com/question-for- > aov-and-kruskal-tp15955385p15976643.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. > > > > - > > [[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, minim
Re: [R] Distances between two datasets of x and y co-ordinates
Andrew McFadden said the following on 3/12/2008 1:47 PM: > Hi all > > I am trying to determine the distances between two datasets of x and y > points. The number of points in dataset One is very small i.e. perhaps > 5-10. The number of points in dataset Two is likely to be very large > i.e. 20,000-30,000. My initial approach was to append the first dataset > to the second and then carry out the calculation: > > dists <- as.matrix(dist(gis data from 2 * datasets)) > > However, the memory of the computer is not sufficient. A lot of > calculations carried out in this situation are unnecessary as I only > want approx 5 * 20,000 calculations versus 20,000 *20,000. > > x <- c(2660156,2663703,2658165,2659303,2661531,2660914) > y <- c(6476767,6475013,6475487,6479659,6477004,6476388) > data2<-cbind(x,y) > > x <- c(266500,261) > y <- c(6478767,6485013) > data1<-cbind(x,y) > > Any suggestions on how to do this would be appreciated. > > Regards > > Andrew If you're trying to find only the closest point in data1 to data2, then use knn (or knn1) in the 'class' package: library(class) nn <- knn1(data2, data1, 1:nrow(data2)) which gives you the rows in data1 closest to each row in data2. Then compute the distance: rowSums((data2[nn, ] - data1)^2)^0.5 HTH, --sundar __ 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] Problem with approximate null distribution (package: coin)
Hi, I am trying to make use of "approximate" option to obtain null distribution through Monte-Carlo resampling, as described in coin library documentation. Unfortunately, this does not play well with my data -- permutation process swallows astonishingly large amounts of RAM (4-5Gb) and runs far too long (30 min for B=10). Apparently, this is caused by the size of my dataset (see example below) but I was under impression that permutation algorithm just draws random contingency tables from the fixed conditional marginals, in which case the amount of memory required should not depend on the dataset size very much, as well as the execution time should only depend on B. Obviously, I was wrong about both assumptions. Is there any reasonable way to work around these limitations in case of a large dataset? It's not that large in fact, so I am a bit surprised the efficiency of resampling is so poor. Below is the dataset example, what I am trying to do is perform cmh_test() on a 4x2x3 table. > adata , , Content = low Response Time YesNo 0 384597259 1 585888039 2 621896102 31466 1606456 , , Content = medium Response Time YesNo 0 101 99525 1 160191698 2 173146814 3 469485012 , , Content = high Response Time YesNo 0 119175938 1 167163881 2 77131063 3 522548924 --Ivan The information transmitted in this electronic communica...{{dropped:10}} __ 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] Distances between two datasets of x and y co-ordinates
Hi all I am trying to determine the distances between two datasets of x and y points. The number of points in dataset One is very small i.e. perhaps 5-10. The number of points in dataset Two is likely to be very large i.e. 20,000-30,000. My initial approach was to append the first dataset to the second and then carry out the calculation: dists <- as.matrix(dist(gis data from 2 * datasets)) However, the memory of the computer is not sufficient. A lot of calculations carried out in this situation are unnecessary as I only want approx 5 * 20,000 calculations versus 20,000 *20,000. x <- c(2660156,2663703,2658165,2659303,2661531,2660914) y <- c(6476767,6475013,6475487,6479659,6477004,6476388) data2<-cbind(x,y) x <- c(266500,261) y <- c(6478767,6485013) data1<-cbind(x,y) Any suggestions on how to do this would be appreciated. Regards Andrew Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St Upper Hutt This email message and any attachment(s) is intended solely for the addressee(s) named above. The information it contains is confidential and may be legally privileged. Unauthorised use of the message, or the information it contains, may be unlawful. If you have received this message by mistake please call the sender immediately on 64 4 8940100 or notify us by return email and erase the original message and attachments. Thank you. The Ministry of Agriculture and Forestry accepts no responsibility for changes made to this email or to any attachments after transmission from the office. [[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] internet proxy settings (win)
Hi Thomas maybe try the following: 1) start R with option "C:\Program Files\R\R-2.6.2\bin\Rgui.exe" -- internet2 2) disable anything in your Rprofile.site and .Rprofile to have a clean start of R I recently upgraded from an earlier version of R to v 2.6.2, and was using all my old libs, and startup files, and when I tried to install any packages I repeatedly ran into the gzfile(file,"r") error message. 1) fixed the problem I had with not being able to see any of the CRAN mirrors, and 2) seemed to fix the gzfile issue. After I got things working, I started adding things back into Rprofile.site and .Rprofile. Potentially, you can skip 1) and only do 2). Hope it works for you as well! Philipp On 12 Mar 2008, at 09:46, Thomas Steiner wrote: > Thanks Liviu, I am trying out what is proposed in the mentioned > thread. > > I start R by > "C:\Program Files\R\R-2.6.2\bin\Rgui.exe" > http_proxy="http://proxy.haifis.org:8080"; > > Then I do the following (selecting "Austria" as mirror) > >> install.packages("package", method="wget") > --- Please select a CRAN mirror for use in this session --- > Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen > Zusätzlich: Warning message: > In gzfile(file, "r") : > cannot open compressed file > 'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file678418be', probable > reason 'No such file or directory' >> setwd('C:\\DOCUME~1\\n301545\\LOCALS~1\\Temp\\RtmpnsKQdi') >> install.packages("package", method="wget") > Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen > Zusätzlich: Warning message: > In gzfile(file, "r") : > cannot open compressed file > 'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file3d6c4ae1', probable > reason 'No such file or directory' >> update.packages(ask='graphics') > Fehler: Indizierung außerhalb der Grenzen > Zusätzlich: Warning messages: > 1: In read.dcf(file = tmpf) : Line starting ' ...' is malformed! > 2: In read.dcf(file = tmpf) : Line starting '...' is > malformed! > 3: In read.dcf(file = tmpf) : Line starting ' ...' is > malformed! >> options(download.file.method="wget") >> update.packages(ask='graphics') > Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen > Zusätzlich: Warning message: > In gzfile(file, "r") : > cannot open compressed file > 'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file5f906952', probable > reason 'No such file or directory' > > Obviously the update.packages does have access to internet, but has > problems with the html tag. Who can help? > > Thomas > > __ > 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] question for aov and kruskal
Hi, My data was only a toy example that matched the real situation, with real data, but i could not have posted the entire data.set and so i gave a self contained example of what i thought was my problem. Of course you can see with the naked eye that the data is unbalanced, (this was done intentionally) but like i said this was only a toy example, mimicking a problem from a real data set. Thank you and have a great ahead! David Hewitt <[EMAIL PROTECTED]> wrote: > I have the following problem: how appropriate is my aov model under the > violation of anova assumptions? > > Example: > a<-c(1,1,1,1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,3,3) > b<-c(101,1010,200,300,400, 202, 121, 234, 55,555,66,76,88,34,239, 30, 40, > 50,50,60) > z<-data.frame(a, b) > fligner.test(z$b, factor(z$a)) > aov(z$b~factor(z$a))->ll > TukeyHSD(ll) > > Now from the aov i found that my model is unbalanced, and from the > flinger test i found out that the assumption of homogeneity of variances > is rejected. Could my Tukey comparison be a valid one under these > violations? From what i read the Tukey test is valid only when the model > is balanced and when the assumption of homogeneity of variances is not > rejected, am i wrong? Can anyone tell me what would be the correct test in > this case? > > Doing a non-parametric Kruskal - wallis test would give me a different > result. But what would be the correct multiple comparison test in this > case? > You shouldn't have needed aov to tell you that the data (not the model) are unbalanced. I could see that without running the code! Seriously, you might need to think more about the type of model you're using, and what you want to know, and then consider how to estimate the effect sizes of interest. - David Hewitt Virginia Institute of Marine Science http://www.vims.edu/fish/students/dhewitt/ -- View this message in context: http://www.nabble.com/question-for-aov-and-kruskal-tp15955385p15976643.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. - [[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] Problem with specifiying column widths in layout
The problem with your code is that you are passing widths to the matrix function instead of the layout function. The matrix function does not know what you want to do with the "widths" and gives the error. Move that section to between the last 2 parentheses: > layout( matrix( 1:9, ncol=3, byrow=TRUE), widths=c(2,1,1) ) A possibly better approach would be to create an outer margin on the left side and reduce the margins inside: > par(oma=c(0,4,0,0), mar=rep(.1,4)) Then plot without the automatic axes and use the axis function with outer=TRUE to place the axis. Maybe something like: > par( mfrow=c(3,3), oma=c(4,4,0,0)+.1, mar=rep(.1,4) ) > > for(i in 1:9) { + plot( rnorm(10*i), rnorm(10*i), ann=FALSE, axes=FALSE, + xlim=c(-3,3), ylim=c(-3,3) ) + box() + if( i %% 3 == 1 ) axis(2, outer=TRUE) + if( i %/% 3 == 1 ) axis(1, outer=TRUE) + } Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Peter H Singleton > Sent: Wednesday, March 12, 2008 1:51 PM > To: r-help@r-project.org > Subject: [R] Problem with specifiying column widths in layout > > > I am trying to generate a graphic with a matrix of 9 line > graphs (3 rows, 3 columns), all with the same y-axis range, > and only showing the y-axis labels and title at the left edge > of each row of the matrix. I have been trying to use the > widths argument in layout to specify a larger column width in > the left column so that I have room for the y-axis labels and > title, but I get the following error: > > > layout(matrix(1:9, ncol=3, widths=c(2,1,1), byrow=TRUE)) > > Error in matrix(1:9, ncol = 3, widths = c(2, 1, 1), byrow = TRUE) : > unused argument(s) (widths = c(2, 1, 1)) > > I think I'm correctly following the example on p80 in > Murrell, and I've seen other people using this syntax in > listserv posts, but I'm obviously doing something wrong. Any > suggestions? > > <<->><<->><<->><<->><<->><<->><<->> > Peter Singleton > USFS Pacific Northwest Research Station > > __ > 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.
[R] Problem with specifiying column widths in layout
I am trying to generate a graphic with a matrix of 9 line graphs (3 rows, 3 columns), all with the same y-axis range, and only showing the y-axis labels and title at the left edge of each row of the matrix. I have been trying to use the widths argument in layout to specify a larger column width in the left column so that I have room for the y-axis labels and title, but I get the following error: > layout(matrix(1:9, ncol=3, widths=c(2,1,1), byrow=TRUE)) Error in matrix(1:9, ncol = 3, widths = c(2, 1, 1), byrow = TRUE) : unused argument(s) (widths = c(2, 1, 1)) I think I'm correctly following the example on p80 in Murrell, and I've seen other people using this syntax in listserv posts, but I'm obviously doing something wrong. Any suggestions? <<->><<->><<->><<->><<->><<->><<->> Peter Singleton USFS Pacific Northwest Research Station __ 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] generalized linear mixed models with a beta distribution
glmmPQL can fit the same GLM families as glm() can -- it does not list _any_ . Howver, the beta distribution does not give a GLM family and hence your subject line is strictly about a non-existent concept. I'm presuming that you want to model the logit of the mean of a beta by a random effects model -- it is unclear what you want to do with the other parameter. Note that the beta does fit into the framework of package gamlss, but I am not aware of an option for random effects in that framework. On Wed, 12 Mar 2008, Craig A Faulhaber wrote: > Greetings, > > I am interested in using a generalized linear mixed model with data that > best fits a beta distribution (i.e., the data is bounded between 0 and 1 > but is not binomial). I noticed that the beta distribution is not > listed as an option in the "family objects" for glmmPQL or lmer. I > found a thread on this listserve from 2006 ("[R] lmer and a response > that is a proportion") that indicated that there was no package https://stat.ethz.ch/pipermail/r-help/2006-December/121567.html > available for mixed effects models with a beta distribution at that > time. This thread also indicated that package betareg did not allow > inclusion of random effects. But it did suggest modelling this in nlme via a variance specification, and that remains a good suggestion. > Does anyone know of a package or code for a generalized linear mixed > model that allows a beta distribution? Transforming my data might allow > me to use another family, but I would rather not transform the data if > possible. Thanks for your help! > > Sincerely, > Craig Faulhaber -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] Re peated Measures (lme?)
Hello, I have a general data analysis question. I recently visited a lab where they are testing a new treatment and they had done the experiment several times on different dates. They repeated the experiment 3-5 times per day. And then for practical reasons they repeated the whole procedure for 5 days.(they wanted a large sample size but practically they couldn't handle more than 5-10 experiments per day). However there might have been some extra variation between different days because the experimenter changed, although same procedure was being followed. Below are the data: Control data: Cday1=c(5,2,5,3,4); Cday2=c(2,1,3,1); Cday3=c(7,6,4,11,10); Cday4=c(5,13,8,4,10,6); Cday5=c(21,8, 5, 5,11); Treatment data: Tday1=c(17,11,25,21,16); Tday2=c(17,7,12); Tday3=c(16,18,4,20,18,25); Tday4=c(17,20,29,17,19); Tday5=c(14,31,28,34); Then they decided to do a paired t.test on the "mean" per day to measure whether they can detect a difference between the Control and the Treatment, something like: t.test(c(3.8,1.75,7.6,7.66,10),c(18,12,16.83,20.4,26.75),paired=T) But I thought there was something wrong in that procedure, something missing but I couldn't figure out what exactly, my feeling was that they were not capturing the variability in the measurements taken within one day. I thought maybe the solution could be in linear mixed effects models (lme) but could that be used to have some sort of a p-value (or other) to say there is a difference or not between the 2 conditions. Or maybe other procedures? Any ideas? Thanks -- View this message in context: http://www.nabble.com/Repeated-Measures-%28lme-%29-tp16012010p16012010.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] glm.fit: "fitted probabilities numerically 0 or 1 occurr
Thanks Ted and Professor Ripley for the very helpful answers! Now I know what the problem is in my case. All the best, Werner --- [EMAIL PROTECTED] schrieb: > On 11-Mar-08 08:58:55, Werner Wernersen wrote: > > Hi, > > > > could anyone explain to me what this warning > message > > exactly means and what the consequences are? > > Is it due to the fact that there are very extreme > > observations / outliers included or what is the > reason > > for it? > > > > Thanks so much, > > Werner > > What it means is exactly what it says. How it arises > will > probably be some variant of the following kind of > data > (I'm guessing that your application of glm() was to > data > with 0/1 responses, as in a logistic regression): > > X = 0.0 0.5 1.0 1.5 2.0 2.5 3.0 ... > Y = 0001111... > > i.e. all the 0's occur on one side of a value (say > 1.25) > of X, and all the 1's occur on the other side. > > If you take a model (e.g. logistic): > > P(Y=1 | X) = exp((X-a)*b)/(1 + exp((X-a)*b)) > > then, for any finite values of a and b, the formula > will > give a value >0 for P(Y=1 | X) where X < 1.25 (i.e. > where > Y=0) so P(Y=0 | X) < 1; and a value <1 for P(Y=1 | > X) > where X > 1.25 (i.e. Y=1). > > However, if you take say a=1.25 (a value which > separates the > 0's from the 1,s), and then let b -> infinity, then > you will > find that > > P(Y=0 | X) -> 1, P(Y=1 | X) -> 0, for X < 1.25 > P(Y=0 | X) -> 0, P(Y=1 | X) -> 1, for X > 1.25 > > so the limit as b -> inf perfectly predicts the > observed outcome. > > However, the value of a is indeterminate so long as > it is > between the largest X for the Y=0 observations, and > the smallest > X for the Y=1 observations. > > This situation cannot arise with data where the > largest X for > which Y=0 is greater than the smallest X for which > Y=1, e.g. > > X = 0.0 0.5 1.0 1.5 2.0 2.5 3.0 ... > Y = 0010111... > > The above example is a very simple example of what > is called > "linear separation". It arises more generally when > there are > several covariates X1, X2, ... , Xk and there is a > linear > function > > L = a1*X1 + a2*X2 + ... + ak*Xk > > for which (with the data as observed) there is a > value L0 > such that > > Y = 0 for all the data such that L < L0 > Y = 1 for all the data such that L > L0 > > In particular, if ever the number of covariates (k) > is greater > than (n-2), where n is the number of cases in your > data, then > you have (k+1) or fewer points in k dimensions, and > there will > be a k-dimensional plane (as given by L above) which > will > separate the (X1,...,Xk)-points where Y=0 from the > (X1,...,Xk)-points where Y=1. Regardless of how you > assign labels > "Y=0" and "Y=1" to (k+1) or fewer points, they will > be linearly > separable. > > Even if k < n-1, so that they are not *in general* > linearly > separated, there is still a a positive probability > that you > can get data for which they are linerally separated; > and > then the same situation arises. This probability > increases > as the number of covariates (k) increases. > > What the warning message is telling you is that a > perfect > fit is possible within the parametrisation of the > model: > a probability P(Y=1)=0 is fitted to cases where the > observed > Y = 0; and a probability P(Y=1)=1 is fitted to cases > where > the observed Y = 1. > > Best wishes, > Ted. > > > E-Mail: (Ted Harding) <[EMAIL PROTECTED]> > Fax-to-email: +44 (0)870 094 0861 > Date: 11-Mar-08 > Time: 10:08:04 > -- XFMail > -- > Lesen Sie Ihre E-Mails auf dem Handy. __ 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] SPSS import problem
On Wed, 12 Mar 2008, K. Elo wrote: > Hi again, > > many thanks for Your answers. So, if I understood Wei right: > > Zhao, Wei (Cancer Center) wrote (12.3.2008): >> I had a similar problem when read one of my spss.sav with long >> variable label. But when I read another spss.sav with short label the >> same way, I don't have problem. >> Seems like R only allows variable labels of lengths 1...255 as your >> error message showed. > > Searching (in SPSS) all variable labels of length > 255 and coercing > them to the length of 255 should solve the problem. > > @Brian, who wrote: >> read.spss() is not targetted at such a recent version of SPSS, and >> only allows variable labels of lengths 1...255. > > I can save the data in SPSS ver 7 -format, too. Is this version > supported by the import function? I don't know for sure: it was written ca 1998 for the PSPP project and I don't know for sure how the file format was found. > However, the error message "error reading system-file header" gives the > impression that the problem is somewhere else than in the overlength > labels. Or have I understood something wrong? It might be, which is why we need to see an example. I suspected there is more to this that just changing the limit in the read.spss internals. > Unfortunately, I cannot make the whole data file available. I could make > a snapshot resulting in the same error - would that be helpful? Yes, it would. > Kind regards, > Kimmo -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] Specifying relative position of text in a plot
On Wed, 12 Mar 2008, Nordlund, Dan (DSHS/RDA) wrote: >> -Original Message- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Monteiro >> Sent: Wednesday, March 12, 2008 10:28 AM >> To: Tom La Bone; r-help@r-project.org >> Subject: Re: [R] Specifying relative position of text in a plot >> >> >> Tom La Bone asked: >>> >>> What is the simplest way to specify the location of text in a >>> scatter plot >>> (created using the plot function) in relative terms rather than >>> specific x-y coordinates? For example, rather than putting text at >>> (300,49) on a plot, how do I put it 1/10 of the way over from the y >>> axis and 1/2 of the way up from the x axis? Thanks. >>> >> See the help of par: >> ?par >> >> Namely: >> >> plot(rnorm(100), rnorm(100)) >> pu <- par()$usr >> x <- pu[1] * 0.5 + pu[2] * 0.5 >> y <- pu[3] * 0.1 + pu[4] * 0.9 >> text(x, y, "the quick brown fox jumps over a lazy dog") >> >> Alberto Monteiro > > This is a useful example of placing text, but I interpreted the request > as aking for the text to be placed at the left side of the graph (1/10 > of the x range) and centered vertically (with respect to the y scale). > So, then I would calculate x and y as > > x <- pu[1] * 0.9 + pu[2] * 0.1 > y <- pu[3] * 0.5 + pu[4] * 0.5 Yes, and there has been another wrong answer earlier. Note that my suggestion of plot(rnorm(100), rnorm(100)) op <- par(usr=c(0,1,0,1)) text(1/10, 1/2, "some text") par(op) is a lot less error-prone (and it also works with log scales). > Also, text() centers the supplied text at the x,y coordinates. So, if > Tom wants the text "begin" at that point, he will need to adjust the x > coordinate for the length of the string being printed. Better, use the adj= argument to text. -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] SPSS import problem
Hi again, many thanks for Your answers. So, if I understood Wei right: Zhao, Wei (Cancer Center) wrote (12.3.2008): > I had a similar problem when read one of my spss.sav with long > variable label. But when I read another spss.sav with short label the > same way, I don't have problem. > Seems like R only allows variable labels of lengths 1...255 as your > error message showed. Searching (in SPSS) all variable labels of length > 255 and coercing them to the length of 255 should solve the problem. @Brian, who wrote: > read.spss() is not targetted at such a recent version of SPSS, and > only allows variable labels of lengths 1...255. I can save the data in SPSS ver 7 -format, too. Is this version supported by the import function? However, the error message "error reading system-file header" gives the impression that the problem is somewhere else than in the overlength labels. Or have I understood something wrong? Unfortunately, I cannot make the whole data file available. I could make a snapshot resulting in the same error - would that be helpful? Kind regards, Kimmo __ 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 code for kernel density using kd-tree, looking for speed up
Dear R-help-list, The following is R function I wrote for computing multi-dimensional kernel density. I am seeking R experts who can make the code to run faster, 50 times faster ideally. Specifically, for function kernel.estimate = function(points, bw), the argument points is a d by n matrix as the n points in the d-dimensional space, bw is the bandwidth. The function will compute the kernel density estimate at the n-points of the input matrix points. To avoid the n^2 computational burden, I build a rd-tree which allows to quickly determine if a source point is too far away from target point and thus can be skipped in the summation (I used a finite support kernel). The kd-tree was built using R list in a structure provided by R core member Thomas Lumley. Interesting, this is an example that Luke Tierney's R compiler provides three times speed up.. Thanks. alsoRun ### #points are the d by n matrix of the source points get.diameter = function(box.lower.limit, box.upper.limit) { temp = box.lower.limit - box.upper.limit sqrt(sum(temp*temp))/2 } Kconst = function(d, n, bw) { con = gamma(d/2+1)/pi^(d/2); con = con/( (2-2*d)/(d+2) + 2*d*(d+7)/(d+4)/(d+6)); con/n/bw^d; } ### ## create an empty node newtree = function(){ list(center=NULL, diameter=NULL, left=NULL, right=NULL) } ## add a node to the kdtree addNode = function(tree, points) { numOfPoints = ncol(points); if(numOfPoints==1) { tree$center = as.vector(points); return(tree); } ## box.lower.limit = apply(points, 1, min); box.upper.limit = apply(points, 1, max); tree$center = (box.lower.limit + box.upper.limit)/2; tree$diameter = get.diameter(box.lower.limit, box.upper.limit); #preparing for the left and right tree diff = box.upper.limit - box.lower.limit; split.dim = which.max(diff); split.mean = tree$center[split.dim] index1 = (points[split.dim,] < split.mean); leftPoints = points[,index1,drop=F]; rightPoints = points[,!index1, drop=F]; tree$left = addNode(newtree(), leftPoints); tree$right = addNode(newtree(), rightPoints); return(tree); } evaluate.element.obj = function(target.element, bw) { bw2 = bw*bw func1 = function(tree) { temp = target.element - tree$center dis2 = sum(temp*temp) if(is.null(tree$left)) { temp = 1. - dis2/bw2 if(temp<0.) 0. else temp^3 } else { temp2 = bw + tree$diameter if( dis2 > temp2*temp2 ) 0. else func1(tree$left) + func1(tree$right) #faster than using Recall } } func1 } evaluate = function(target, tree, bw) { func = function(x) evaluate.element.obj(x, bw)(tree) estimate = apply(target, 2, FUN=func) estimate*Kconst(d=nrow(target), n=ncol(target), bw) } kernel.estimate = function(points, bw) { tree = addNode(newtree(), points) print(date()) evaluate(points, tree, bw) } main1 = function(n, d) { bw = 1.4794953 - 1/(d+2)*log(n) x = rnorm(n*d); dim(x) = c(d, n) result = kernel.estimate(x, exp(bw)) hist(result) } print(date()) print(system.time(main1(1000*4,2))) print(date()) . - [[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] Specifying relative position of text in a plot
To left justify the text rather than center, use the adj argument, this is easier and probably more reliable than trying to adjust the x coordinate manually. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Nordlund, > Dan (DSHS/RDA) > Sent: Wednesday, March 12, 2008 12:26 PM > To: Alberto Monteiro; Tom La Bone; r-help@r-project.org > Subject: Re: [R] Specifying relative position of text in a plot > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Monteiro > > Sent: Wednesday, March 12, 2008 10:28 AM > > To: Tom La Bone; r-help@r-project.org > > Subject: Re: [R] Specifying relative position of text in a plot > > > > > > Tom La Bone asked: > > > > > > What is the simplest way to specify the location of text in a > > > scatter plot (created using the plot function) in relative terms > > > rather than specific x-y coordinates? For example, rather than > > > putting text at > > > (300,49) on a plot, how do I put it 1/10 of the way over > from the y > > > axis and 1/2 of the way up from the x axis? Thanks. > > > > > See the help of par: > > ?par > > > > Namely: > > > > plot(rnorm(100), rnorm(100)) > > pu <- par()$usr > > x <- pu[1] * 0.5 + pu[2] * 0.5 > > y <- pu[3] * 0.1 + pu[4] * 0.9 > > text(x, y, "the quick brown fox jumps over a lazy dog") > > > > Alberto Monteiro > > > > This is a useful example of placing text, but I interpreted > the request as aking for the text to be placed at the left > side of the graph (1/10 of the x range) and centered > vertically (with respect to the y scale). So, then I would > calculate x and y as > > x <- pu[1] * 0.9 + pu[2] * 0.1 > y <- pu[3] * 0.5 + pu[4] * 0.5 > > Also, text() centers the supplied text at the x,y > coordinates. So, if Tom wants the text "begin" at that point, > he will need to adjust the x coordinate for the length of the > string being printed. > > Hope this is helpful, > > Dan > > Daniel J. Nordlund > Research and Data Analysis > Washington State Department of Social and Health Services > Olympia, WA 98504-5204 > > > > __ > 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] default values
On Wed, 12 Mar 2008, Dwayne Blind wrote: > Dear R users, > > I wrote the following toy example to explain my problem : > > a=0 > f=function(x,y,z) { >if (a==0) x[1]+x[2]+y >if (a!=0) x[1]+x[2]+y+z > } > f(1:2,3) > > > I have not specified z and I get an error. What was the error? It works for me (so I've no idea), and returns NULL, the value of the last expression (invisibly). I think you intended f <- function(x, y, z) if (a==0) x[1]+x[2]+y else x[1]+x[2]+y+z or f <- function(x, y, z) ifelse(a==0, x[1]+x[2]+y, x[1]+x[2]+y+z) > Although a=0, R seems to want to > know z because it's in the expression x[1]+x[2]+y+z. > > So I tried to put a default value : > > a=0 > f=function(x,y,z=0) { >if (a==0) x[1]+x[2]+y >if (a!=0) x[1]+x[2]+y+z > } > f(1:2,3) > > Why isn't it working ? Sometimes everything is fine even though a parameter > is not specified. > > Thanks a lot. > > [[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. > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] generalized linear mixed models with a beta distribution
Greetings, I am interested in using a generalized linear mixed model with data that best fits a beta distribution (i.e., the data is bounded between 0 and 1 but is not binomial). I noticed that the beta distribution is not listed as an option in the "family objects" for glmmPQL or lmer. I found a thread on this listserve from 2006 ("[R] lmer and a response that is a proportion") that indicated that there was no package available for mixed effects models with a beta distribution at that time. This thread also indicated that package betareg did not allow inclusion of random effects. Does anyone know of a package or code for a generalized linear mixed model that allows a beta distribution? Transforming my data might allow me to use another family, but I would rather not transform the data if possible. Thanks for your help! Sincerely, Craig Faulhaber __ 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] default values
You just need to return the values computed when a==0 and when a!=0. a=0 f=function(x,y,z=0) { if (a==0) return(x[1]+x[2]+y) if (a!=0) return(x[1]+x[2]+y+z) } > f(1:2,3) [1] 6 > Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dwayne Blind Sent: Wednesday, March 12, 2008 1:59 PM To: r-help@r-project.org Subject: [R] default values Dear R users, I wrote the following toy example to explain my problem : a=0 f=function(x,y,z) { if (a==0) x[1]+x[2]+y if (a!=0) x[1]+x[2]+y+z } f(1:2,3) I have not specified z and I get an error. Although a=0, R seems to want to know z because it's in the expression x[1]+x[2]+y+z. So I tried to put a default value : a=0 f=function(x,y,z=0) { if (a==0) x[1]+x[2]+y if (a!=0) x[1]+x[2]+y+z } f(1:2,3) Why isn't it working ? Sometimes everything is fine even though a parameter is not specified. Thanks a lot. [[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-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] survival analysis and censoring
In your particular case I don't think that censoring is an issue, at least not for the reason that you discuss. The basic censoring assumption in the Cox model is that subjects who are censored have the same future risk as those who were a. not censored and b. have the same covariates. The real problem with informative censoring are the covaraites that are not in the model; ones that I likely don't even know exist. Assume for instance that some unknown exposure X, Perth sunlight say, makes people much more likely to get both of the outcomes. Assume further that it matters, i.e., the study includes a reasonable number of people with and without this exposure. Then someone who has an early heart attack actually has a higher risk of colorectal cancer than a colleague of the same age/sex/followup who did not have a heart attack, the reason being that the HA guy is more likely to be from Perth. Your simulation went wrong by not actually accounting for time. You created an outcome table for CC & HD and added a random time vector to it. If someone would have had CC at 2 years and now has HD at 1 year, you can't just change the status to make them censored at 2. The gambling analogy would be kicking someone out of the casino just before they win -- it does odd things to the odds. Terry Therneau __ 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] Types of quadrature
Note that integrate accepts upper=Inf. All that is needed is to read the help and do as it asks. On Wed, 12 Mar 2008, Lüthi David (luda) wrote: Dear R-users I would like to integrate something like \int_k^\infty (1 - F(x)) dx, where F(.) is a cumulative distribution function. As mentioned in the "integrate" help-page: integrate(dnorm,0,2) ## fails on many systems. This does not happen for an adaptive Simpson or Lobatto quadrature (cf. Matlab). Even though I am hardly familiar with numerical integration the implementation seems to be fairly straightforward. My questions: - Is this extension of the function "integrate" planned for upcoming versions of R? - Do there exist packages / workarounds? I'm using R 2.6.2 on Windows and the reason why I want to integrate such an expression is for the sake to compute the performance measure "Omega" for financial securities. Best regards, David -- David Lüthi idp - Institute of Data Analysis and Process Design Zurich University of Applied Sciences Postfach 805 CH-8401 Winterthur E-mail: [EMAIL PROTECTED] Phone: 058 934 78 03 http://www.idp.zhaw.ch -- __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595__ 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] Converting a data frame with values into a matrix/
> mm1 <- cast(mm, Class~Name) > aba <- mm1[,2:6] > aba[is.na(aba)] <- 1 > final <- data.frame(mm1$Class, aba) > names(final) <- names(mm1) > final You can abbreviate all this to: final <- cast(mm, Class ~ Name, fill = 1) Hadley -- http://had.co.nz/ __ 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] Specifying relative position of text in a plot
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Monteiro > Sent: Wednesday, March 12, 2008 10:28 AM > To: Tom La Bone; r-help@r-project.org > Subject: Re: [R] Specifying relative position of text in a plot > > > Tom La Bone asked: > > > > What is the simplest way to specify the location of text in a > > scatter plot > > (created using the plot function) in relative terms rather than > > specific x-y coordinates? For example, rather than putting text at > > (300,49) on a plot, how do I put it 1/10 of the way over from the y > > axis and 1/2 of the way up from the x axis? Thanks. > > > See the help of par: > ?par > > Namely: > > plot(rnorm(100), rnorm(100)) > pu <- par()$usr > x <- pu[1] * 0.5 + pu[2] * 0.5 > y <- pu[3] * 0.1 + pu[4] * 0.9 > text(x, y, "the quick brown fox jumps over a lazy dog") > > Alberto Monteiro > This is a useful example of placing text, but I interpreted the request as aking for the text to be placed at the left side of the graph (1/10 of the x range) and centered vertically (with respect to the y scale). So, then I would calculate x and y as x <- pu[1] * 0.9 + pu[2] * 0.1 y <- pu[3] * 0.5 + pu[4] * 0.5 Also, text() centers the supplied text at the x,y coordinates. So, if Tom wants the text "begin" at that point, he will need to adjust the x coordinate for the length of the string being printed. Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204 __ 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] Types of quadrature
Hi, Why do you need an extension of integrate()? integrate() is adaptive - it uses an adaptive Gauss-Kronrod quadrature. You can specify Inf and -Inf as upper and lower limits, resp., in integrate(). In fact, this is what the help page recommends, and it also discourages the use of a large number as a surrogate for Inf. What is the specific problem or distribution that you are having trouble with in using integrate()? Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lüthi David (luda) Sent: Wednesday, March 12, 2008 1:25 PM To: r-help@r-project.org Subject: [R] Types of quadrature Dear R-users I would like to integrate something like \int_k^\infty (1 - F(x)) dx, where (.) is a cumulative distribution function. As mentioned in the "integrate" help-page: integrate(dnorm,0,2) ## fails on many systems. This does not happen for an adaptive Simpson or Lobatto quadrature (cf. Matlab). Even though I am hardly familiar with numerical integration the implementation seems to be fairly straightforward. My questions: - Is this extension of the function "integrate" planned for upcoming versions of R? - Do there exist packages / workarounds? I'm using R 2.6.2 on Windows and the reason why I want to integrate such an expression is for the sake to compute the performance measure "Omega" for financial securities. Best regards, David -- David Lüthi idp - Institute of Data Analysis and Process Design Zurich University of Applied Sciences Postfach 805 CH-8401 Winterthur E-mail: [EMAIL PROTECTED] Phone: 058 934 78 03 http://www.idp.zhaw.ch -- __ 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] Converting a data frame with values into a matrix/
Oops, I just realised that you asked for a matrix not a data.frame Substituing for the last three lines of code final <- as.matrix(aba) colnames(final) <- aa$Name rownames(final) <- mm1$Class should do it. --- John Kane <[EMAIL PROTECTED]> wrote: > The way that you have set up the data.frame is > rather > unusual. It makes NES a factor which I suspect you > don't want. Do str(xx) to see what I mean > > Here is a way that I think does what you want but > with > the data.frame constructed in a different manner. > Again do str(aa) to see the difference > = > aa <- data.frame(Name=c( "Mike" ,"Carl", "Gene", > "James","Dough"), > Class=c( "A", "A", "C", "A", "B"), > NES=c( 0.01, 0.2, 0.3, -0.3, 0) ) > aa > > library(reshape) > mm <- melt(aa, id=c("Name", "Class")) > mm1 <- cast(mm, Class~Name) > > aba <- mm1[,2:6] > aba[is.na(aba)] <- 1 > > final <- data.frame(mm1$Class, aba) > names(final) <- names(mm1) > final > > === > > --- Srinivas Iyyer <[EMAIL PROTECTED]> > wrote: > > > Dear Group, > > I have a data frame like the following: > > > > > > x <- c("Mike","A",0.01) > > x1 <- c("Carl","A",0.2) > > x2 <- c("Gene","C",0.3) > > x3 <- c("James","A",-0.3) > > x4 <- c("Dough","B",0) > > xx <- rbind(x,x1,x2,x3,x4) > > colnames(xx)<-c("Name","Class","NES") > > xx <-as.data.frame(xx) > > > > > xx > > Name Class NES > > x Mike A 0.01 > > x1 Carl A 0.2 > > x2 Gene C 0.3 > > x3 James A -0.3 > > x4 Dough B0 > > > > > > Now I want to create a matrix with unique xx$Name > on > > columns and unique xx$Class as rows. I want to > fill > > my choice of values (in this case 1) if data point > > not > > available. > > > > > > xy <- > > > matrix(1,length(unique(xx$Class)),length(unique(xx[,1]))) > > colnames(xy)<-unique(xx[,1]) > > rownames(xy)<-unique(xx$Class) > > > > > xy > > Mike Carl Gene James Dough > > A111 1 1 > > C111 1 1 > > B111 1 1 > > > > > > > > > > > > I would love to have : > > > > Mike Carl Gene James Dough > > A0.010.21 -0.3 1 > > C111 0.3 1 > > B111 10 > > > > > > > > > > If I am not wrong this is called contigency or > > frequeny table. > > > > I tried xtabs on this. > > > > > z <- xtabs(NES ~ Name+Class,data=xx) > > Error in Summary.factor(4L, na.rm = FALSE) : > > sum not meaningful for factors > > > > > > I tried on other data frames, it worked. BUT the > > problem is it gives me 0. even a value is not > > available for that row and column. So if I have > > data > > -0.00 it is considered 0. > > > > I tried. drop.unused.levels = T, I did not get > what > > I > > want. I want all row.col values not available to > be > > 1. > > > > > > Is there any other trick where I map by row and > > column > > names instead of using advanced xtabs. > > > > thanks > > Srini > > > > __ > > 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. > [[elided trailing spam]] __ 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] default values
Dear R users, I wrote the following toy example to explain my problem : a=0 f=function(x,y,z) { if (a==0) x[1]+x[2]+y if (a!=0) x[1]+x[2]+y+z } f(1:2,3) I have not specified z and I get an error. Although a=0, R seems to want to know z because it's in the expression x[1]+x[2]+y+z. So I tried to put a default value : a=0 f=function(x,y,z=0) { if (a==0) x[1]+x[2]+y if (a!=0) x[1]+x[2]+y+z } f(1:2,3) Why isn't it working ? Sometimes everything is fine even though a parameter is not specified. Thanks a lot. [[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] Converting a data frame with values into a matrix/
The way that you have set up the data.frame is rather unusual. It makes NES a factor which I suspect you don't want. Do str(xx) to see what I mean Here is a way that I think does what you want but with the data.frame constructed in a different manner. Again do str(aa) to see the difference = aa <- data.frame(Name=c( "Mike" ,"Carl", "Gene", "James","Dough"), Class=c( "A", "A", "C", "A", "B"), NES=c( 0.01, 0.2, 0.3, -0.3, 0) ) aa library(reshape) mm <- melt(aa, id=c("Name", "Class")) mm1 <- cast(mm, Class~Name) aba <- mm1[,2:6] aba[is.na(aba)] <- 1 final <- data.frame(mm1$Class, aba) names(final) <- names(mm1) final === --- Srinivas Iyyer <[EMAIL PROTECTED]> wrote: > Dear Group, > I have a data frame like the following: > > > x <- c("Mike","A",0.01) > x1 <- c("Carl","A",0.2) > x2 <- c("Gene","C",0.3) > x3 <- c("James","A",-0.3) > x4 <- c("Dough","B",0) > xx <- rbind(x,x1,x2,x3,x4) > colnames(xx)<-c("Name","Class","NES") > xx <-as.data.frame(xx) > > > xx > Name Class NES > x Mike A 0.01 > x1 Carl A 0.2 > x2 Gene C 0.3 > x3 James A -0.3 > x4 Dough B0 > > > Now I want to create a matrix with unique xx$Name on > columns and unique xx$Class as rows. I want to fill > my choice of values (in this case 1) if data point > not > available. > > > xy <- > matrix(1,length(unique(xx$Class)),length(unique(xx[,1]))) > colnames(xy)<-unique(xx[,1]) > rownames(xy)<-unique(xx$Class) > > > xy > Mike Carl Gene James Dough > A111 1 1 > C111 1 1 > B111 1 1 > > > > > > I would love to have : > > Mike Carl Gene James Dough > A0.010.21 -0.3 1 > C111 0.3 1 > B111 10 > > > > > If I am not wrong this is called contigency or > frequeny table. > > I tried xtabs on this. > > > z <- xtabs(NES ~ Name+Class,data=xx) > Error in Summary.factor(4L, na.rm = FALSE) : > sum not meaningful for factors > > > I tried on other data frames, it worked. BUT the > problem is it gives me 0. even a value is not > available for that row and column. So if I have > data > -0.00 it is considered 0. > > I tried. drop.unused.levels = T, I did not get what > I > want. I want all row.col values not available to be > 1. > > > Is there any other trick where I map by row and > column > names instead of using advanced xtabs. > > thanks > Srini > > __ > 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] Converting a data frame with values into a matrix/
Try: xy <- with(xx, tapply(NES, list(Class, Name), paste)) xy[is.na(xy)] <- 1 On 12/03/2008, Srinivas Iyyer <[EMAIL PROTECTED]> wrote: > Hi Henrique, > Thanks for your tip. > > > how can I map xx onto xy (where xy is a matrix I > created). > > > > > > > xy > Mike Carl Gene James Dough > A111 1 1 > C111 1 1 > B111 1 1 > > > > If I can map xx onto xy, I can have '1' without NAs. > > Thanks > Srini > > > > > --- Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > > > Perhaps in this case: > > > > noquote(with(xx, tapply(NES, list(Class, Name), > > paste))) > > > > > > On 12/03/2008, Srinivas Iyyer > > <[EMAIL PROTECTED]> wrote: > > > Dear Group, > > > I have a data frame like the following: > > > > > > > > > x <- c("Mike","A",0.01) > > > x1 <- c("Carl","A",0.2) > > > x2 <- c("Gene","C",0.3) > > > x3 <- c("James","A",-0.3) > > > x4 <- c("Dough","B",0) > > > xx <- rbind(x,x1,x2,x3,x4) > > > colnames(xx)<-c("Name","Class","NES") > > > xx <-as.data.frame(xx) > > > > > > > xx > > > Name Class NES > > > x Mike A 0.01 > > > x1 Carl A 0.2 > > > x2 Gene C 0.3 > > > x3 James A -0.3 > > > x4 Dough B0 > > > > > > > > > Now I want to create a matrix with unique xx$Name > > on > > > columns and unique xx$Class as rows. I want to > > fill > > > my choice of values (in this case 1) if data > > point not > > > available. > > > > > > > > > xy <- > > > > > > matrix(1,length(unique(xx$Class)),length(unique(xx[,1]))) > > > colnames(xy)<-unique(xx[,1]) > > > rownames(xy)<-unique(xx$Class) > > > > > > > xy > > > Mike Carl Gene James Dough > > > A111 1 1 > > > C111 1 1 > > > B111 1 1 > > > > > > > > > > > > > > > > > > I would love to have : > > > > > > Mike Carl Gene James Dough > > > A0.010.21 -0.3 1 > > > C111 0.3 1 > > > B111 10 > > > > > > > > > > > > > > > If I am not wrong this is called contigency or > > > frequeny table. > > > > > > I tried xtabs on this. > > > > > > > z <- xtabs(NES ~ Name+Class,data=xx) > > > Error in Summary.factor(4L, na.rm = FALSE) : > > > sum not meaningful for factors > > > > > > > > > I tried on other data frames, it worked. BUT the > > > problem is it gives me 0. even a value is not > > > available for that row and column. So if I have > > data > > > -0.00 it is considered 0. > > > > > > I tried. drop.unused.levels = T, I did not get > > what I > > > want. I want all row.col values not available to > > be 1. > > > > > > > > > Is there any other trick where I map by row and > > column > > > names instead of using advanced xtabs. > > > > > > thanks > > > Srini > > > > > > __ > > > 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. > > > > > > > > > -- > > Henrique Dallazuanna > > Curitiba-Paraná-Brasil > > 25° 25' 40" S 49° 16' 22" O > > > > > > > > > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Converting a data frame with values into a matrix/
Hi Henrique, Thanks for your tip. how can I map xx onto xy (where xy is a matrix I created). > > > xy Mike Carl Gene James Dough A111 1 1 C111 1 1 B111 1 1 If I can map xx onto xy, I can have '1' without NAs. Thanks Srini --- Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > Perhaps in this case: > > noquote(with(xx, tapply(NES, list(Class, Name), > paste))) > > > On 12/03/2008, Srinivas Iyyer > <[EMAIL PROTECTED]> wrote: > > Dear Group, > > I have a data frame like the following: > > > > > > x <- c("Mike","A",0.01) > > x1 <- c("Carl","A",0.2) > > x2 <- c("Gene","C",0.3) > > x3 <- c("James","A",-0.3) > > x4 <- c("Dough","B",0) > > xx <- rbind(x,x1,x2,x3,x4) > > colnames(xx)<-c("Name","Class","NES") > > xx <-as.data.frame(xx) > > > > > xx > > Name Class NES > > x Mike A 0.01 > > x1 Carl A 0.2 > > x2 Gene C 0.3 > > x3 James A -0.3 > > x4 Dough B0 > > > > > > Now I want to create a matrix with unique xx$Name > on > > columns and unique xx$Class as rows. I want to > fill > > my choice of values (in this case 1) if data > point not > > available. > > > > > > xy <- > > > matrix(1,length(unique(xx$Class)),length(unique(xx[,1]))) > > colnames(xy)<-unique(xx[,1]) > > rownames(xy)<-unique(xx$Class) > > > > > xy > > Mike Carl Gene James Dough > > A111 1 1 > > C111 1 1 > > B111 1 1 > > > > > > > > > > > > I would love to have : > > > > Mike Carl Gene James Dough > > A0.010.21 -0.3 1 > > C111 0.3 1 > > B111 10 > > > > > > > > > > If I am not wrong this is called contigency or > > frequeny table. > > > > I tried xtabs on this. > > > > > z <- xtabs(NES ~ Name+Class,data=xx) > > Error in Summary.factor(4L, na.rm = FALSE) : > > sum not meaningful for factors > > > > > > I tried on other data frames, it worked. BUT the > > problem is it gives me 0. even a value is not > > available for that row and column. So if I have > data > > -0.00 it is considered 0. > > > > I tried. drop.unused.levels = T, I did not get > what I > > want. I want all row.col values not available to > be 1. > > > > > > Is there any other trick where I map by row and > column > > names instead of using advanced xtabs. > > > > thanks > > Srini > > > > __ > > 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. > > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > __ 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] Types of quadrature
Dear R-users I would like to integrate something like \int_k^\infty (1 - F(x)) dx, where F(.) is a cumulative distribution function. As mentioned in the "integrate" help-page: integrate(dnorm,0,2) ## fails on many systems. This does not happen for an adaptive Simpson or Lobatto quadrature (cf. Matlab). Even though I am hardly familiar with numerical integration the implementation seems to be fairly straightforward. My questions: - Is this extension of the function "integrate" planned for upcoming versions of R? - Do there exist packages / workarounds? I'm using R 2.6.2 on Windows and the reason why I want to integrate such an expression is for the sake to compute the performance measure "Omega" for financial securities. Best regards, David -- David Lüthi idp - Institute of Data Analysis and Process Design Zurich University of Applied Sciences Postfach 805 CH-8401 Winterthur E-mail: [EMAIL PROTECTED] Phone: 058 934 78 03 http://www.idp.zhaw.ch -- __ 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] Converting a data frame with values into a matrix/
Perhaps in this case: noquote(with(xx, tapply(NES, list(Class, Name), paste))) On 12/03/2008, Srinivas Iyyer <[EMAIL PROTECTED]> wrote: > Dear Group, > I have a data frame like the following: > > > x <- c("Mike","A",0.01) > x1 <- c("Carl","A",0.2) > x2 <- c("Gene","C",0.3) > x3 <- c("James","A",-0.3) > x4 <- c("Dough","B",0) > xx <- rbind(x,x1,x2,x3,x4) > colnames(xx)<-c("Name","Class","NES") > xx <-as.data.frame(xx) > > > xx > Name Class NES > x Mike A 0.01 > x1 Carl A 0.2 > x2 Gene C 0.3 > x3 James A -0.3 > x4 Dough B0 > > > Now I want to create a matrix with unique xx$Name on > columns and unique xx$Class as rows. I want to fill > my choice of values (in this case 1) if data point not > available. > > > xy <- > matrix(1,length(unique(xx$Class)),length(unique(xx[,1]))) > colnames(xy)<-unique(xx[,1]) > rownames(xy)<-unique(xx$Class) > > > xy > Mike Carl Gene James Dough > A111 1 1 > C111 1 1 > B111 1 1 > > > > > > I would love to have : > > Mike Carl Gene James Dough > A0.010.21 -0.3 1 > C111 0.3 1 > B111 10 > > > > > If I am not wrong this is called contigency or > frequeny table. > > I tried xtabs on this. > > > z <- xtabs(NES ~ Name+Class,data=xx) > Error in Summary.factor(4L, na.rm = FALSE) : > sum not meaningful for factors > > > I tried on other data frames, it worked. BUT the > problem is it gives me 0. even a value is not > available for that row and column. So if I have data > -0.00 it is considered 0. > > I tried. drop.unused.levels = T, I did not get what I > want. I want all row.col values not available to be 1. > > > Is there any other trick where I map by row and column > names instead of using advanced xtabs. > > thanks > Srini > > __ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Specifying relative position of text in a plot
I tested the main set of examples from cnvrt.coords using the new grconvert functions and they worked perfectly. I have already noted in the help page for cnvrt.coords (for the next version coming out soon) that people should start using grconvertX and grconvertY when they become available. Are there any more of the utilities in TeachingDemos that will be need to be depricated with the release of version 2.7? (I read through the current NEWS file, but are there any more planned?). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Prof Brian Ripley > Sent: Wednesday, March 12, 2008 9:13 AM > To: Tom La Bone > Cc: r-help@r-project.org > Subject: Re: [R] Specifying relative position of text in a plot > > See ?par, entry "usr". Either set a new coordinate system and > use it, or convert 1/10 to user coordinates. > > In R-devel (2.7.0 to be) this is easier: > > text(grconvertX(0.1,"npc"), grconvertY(0.5, "npc"), "some text") > > cnvrt.coords() in package TeachingDemos does something > similar (although it doesn't use the standard R names for > coordinate systems, and there are more than 5). > > On Wed, 12 Mar 2008, Tom La Bone wrote: > > > > > What is the simplest way to specify the location of text in > a scatter > > plot (created using the plot function) in relative terms > rather than > > specific x-y coordinates? For example, rather than putting text at > > (300,49) on a plot, how do I put it 1/10 of the way over from the y > > axis and 1/2 of the way up from the x axis? Thanks. > > > > Tom > > > -- > Brian D. Ripley, [EMAIL PROTECTED] > 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, UKFax: +44 1865 272595 > > __ > 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] Specifying relative position of text in a plot
Tom La Bone asked: > > What is the simplest way to specify the location of text in a > scatter plot > (created using the plot function) in relative terms rather than > specific x-y coordinates? For example, rather than putting text at > (300,49) on a plot, how do I put it 1/10 of the way over from the y > axis and 1/2 of the way up from the x axis? Thanks. > See the help of par: ?par Namely: plot(rnorm(100), rnorm(100)) pu <- par()$usr x <- pu[1] * 0.5 + pu[2] * 0.5 y <- pu[3] * 0.1 + pu[4] * 0.9 text(x, y, "the quick brown fox jumps over a lazy dog") Alberto Monteiro __ 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] How to Read?
Well, i am not sure what do you want how to do the graphs you showed or how to interpret them?? If you want to know how to do them, look at package ade4, especially functions s.corcircle and scatter.dudi, but you can use the function plot as well and choose the right variables since PCA will give you both categories of values (pca loadings, and scores). If you want to know interpretation i suggest to find any book which discusses PCA, for example in ecology or vegetation classification and such. You will see some examples and their interpretation. Monica _ Helping your favorite cause is as easy as instant messaging. You IM, we give. __ 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] Error: arguments imply differing number of rows
Try str() on both objects and see what you get. It does not look like you have two vectors of length=1762. See this for example = aa <- c("A", "B", "D", "D","B", "B","D", "A", "C", "C", "A","D") bb <- rnorm(length(aa)) cc <- matrix(rnorm(length(aa)),nrow=2) length(bb) length(cc) boxplot(bb~aa) boxplot(cc~aa) == --- "Jeffrey T. Steedle" <[EMAIL PROTECTED]> wrote: > I am simply trying to put 4 boxplots on the same > plot, but I keep > getting the "arguments imply differing number of > rows" error. Here, I > have two variables: a factor x of length 1762 (with > 4 levels) and a > numeric variable y of length 1762. How is it that my > arguments imply > differing numbers of rows? > > > length(x) > [1] 1762 > > length(y) > [1] 1762 > > is.factor(x) > [1] TRUE > > is.numeric(y) > [1] TRUE > > plot(x,y) > Error in data.frame(group, x) : >arguments imply differing number of rows: 1762, > 2165 > > boxplot(y~x) > Error in data.frame(group, x) : >arguments imply differing number of rows: 1762, > 2165 > > __ > 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. > [[elided trailing spam]] __ 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] Converting a data frame with values into a matrix/
Dear Group, I have a data frame like the following: x <- c("Mike","A",0.01) x1 <- c("Carl","A",0.2) x2 <- c("Gene","C",0.3) x3 <- c("James","A",-0.3) x4 <- c("Dough","B",0) xx <- rbind(x,x1,x2,x3,x4) colnames(xx)<-c("Name","Class","NES") xx <-as.data.frame(xx) > xx Name Class NES x Mike A 0.01 x1 Carl A 0.2 x2 Gene C 0.3 x3 James A -0.3 x4 Dough B0 Now I want to create a matrix with unique xx$Name on columns and unique xx$Class as rows. I want to fill my choice of values (in this case 1) if data point not available. xy <- matrix(1,length(unique(xx$Class)),length(unique(xx[,1]))) colnames(xy)<-unique(xx[,1]) rownames(xy)<-unique(xx$Class) > xy Mike Carl Gene James Dough A111 1 1 C111 1 1 B111 1 1 I would love to have : Mike Carl Gene James Dough A0.010.21 -0.3 1 C111 0.3 1 B111 10 If I am not wrong this is called contigency or frequeny table. I tried xtabs on this. > z <- xtabs(NES ~ Name+Class,data=xx) Error in Summary.factor(4L, na.rm = FALSE) : sum not meaningful for factors I tried on other data frames, it worked. BUT the problem is it gives me 0. even a value is not available for that row and column. So if I have data -0.00 it is considered 0. I tried. drop.unused.levels = T, I did not get what I want. I want all row.col values not available to be 1. Is there any other trick where I map by row and column names instead of using advanced xtabs. thanks Srini __ 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] More digits in prediction using random forest object
How many trees are you growing in the forest? If you grow a 100-tree forest, the possible predictions (for a two-class data) would simply be {0, 0.01, 0.02, ..., 0.99, 1} Then, of course, if you only grow three trees, the predictions can only be {0, 1/3, 2/3, 1} You can ask for as many digits as R can give you, but it won't do you any good. Andy From: Nagu > > I need to get more digits in predicting a test sample with a random > forests object. Format or options(digits=) do nothing. Any ideas? > > Thank you, > Nagu > > __ > 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. > > > -- Notice: This e-mail message, together with any attachme...{{dropped:15}} __ 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] SPSS import problem
I had a similar problem when read one of my spss.sav with long variable label. But when I read another spss.sav with short label the same way, I don't have problem. Seems like R only allows variable labels of lengths 1...255 as your error message showed. WZ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prof Brian Ripley Sent: Wednesday, March 12, 2008 5:01 AM To: K. Elo Cc: r-help@r-project.org Subject: Re: [R] SPSS import problem We need to be able to reproduce this, so can you please make the file available? Please follow up to R-devel. On Wed, 12 Mar 2008, K. Elo wrote: > Dear all, > > I have tried to import a SPSS file in R, but always get the following > message: > --- cut here --- > Error in read.spss("spss-data.sav", : > error reading system-file header > In addition: Warning message: > In read.spss("spss-data.sav", : > spss-data.sav: Variable Y6B_A indicates variable label of invalid > length 256 > --- cut here --- > > SPSS (ver 14) has no problems with this file. read.spss() is not targetted at such a recent version of SPSS, and only allows variable labels of lengths 1...255. > Any ideas? > > Kind regards, > Kimmo > > --- > University of Turku, Finland > Department of Political Science > > __ > 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. > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] Problem when calling FORTRAN subroutine (dll)
G'day Krishna, On Wed, 12 Mar 2008 08:59:30 -0700 (PDT) "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > output<-.C("smooth_",as.integer(NROW),as.integer(NCOL),as.integer(NDIM),as.real(X),as.real(W),as.real(A),as.real(B),as.integer(NCYCLE),as.integer(ICYCLE),as.real(G),as.real(EPS),as.integer(IFAULT)) 1) You are calling FORTRAN code and not C code, so why are you using .C instead of .Fortran? 2) Why do you append an underscore to the name of the routine that you are using? 3) According to the FORTRAN source, the variables are defined as REALs, not as DOUBLE PRECISION. R, by default expects to interface to DOUBLE PRECISION. If you want to interface to REALs, you have to use as.single or set the storage mode to single. Details regarding all these points are in the "Writing R Extensions" manual which I would strongly recommend you to study. Cheers, Berwin === Full address = Berwin A TurlachTel.: +65 6516 4416 (secr) Dept of Statistics and Applied Probability+65 6516 6650 (self) Faculty of Science FAX : +65 6872 3919 National University of Singapore 6 Science Drive 2, Blk S16, Level 7 e-mail: [EMAIL PROTECTED] Singapore 117546http://www.stat.nus.edu.sg/~statba __ 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] Problem when calling FORTRAN subroutine (dll)
Hello, I am trying to call a FORTRAN subroutine from R. The Fortran code is @: http://lib.stat.cmu.edu/apstat/206 It performs a bivariate isotonic regression on a rectangular grid (m X n) matrix. I used the g77 compiler and successfully created a dll file and it also loads successfully from R. But somehow the programs fails to run properly. (I do get the correct result when I compile the FORTRAN code). Please see below and note that since my input matrix X is monotonically increasing in both directions, input should be equal to output since the weights are set to 1 for all elements. (also verified this in FORTRAN to make sure that the subroutine works). Output[[10]] is supposed to be the monotonically regressed output, but it does not come out correctly. I don't know if its something to do with the way I am feeding the parameters to the DLL. Thanks in advance for any help I can receive. I am not god with FORTRAN - very very infrequent FORTRAN user. I am using R 2.4.0. Regards Krishna. > rm(list=ls(all=TRUE)) > dyn.load("c:/smooth.dll") > is.loaded("smooth") [1] TRUE > NROW<-4 > NCOL<-4 > NDIM<-4 > NCYCLE<-5 > X<-array(c(0.05,0.2,0.35,0.43,0.09,0.29,0.41,0.55,0.2,0.33,0.55,0.7,0.33,0.48,0.6,0.8)) > W<-array(rep(1.0,length(X))) > X<-matrix(X,nrow=4,ncol=4) > X<-t(X) > W<-matrix(W,nrow=4,ncol=4) > A<-array(0,dim=c(NROW,NCOL,4)) > B<-array(0,dim=c(NDIM,5)) > NCYCLE<-5 > ICYCLE<-5 > G<-(X*0)+0.0 > EPS=0.001 > IFAULT<-5 # Here is how the subroutine says to input the parameters; #SUBROUTINE SMOOTH(NROW, NCOL, NDIM, X, W, A, B, NCYCLE, ICYCLE, G, EPS, IFAULT) # Definitions of each of these input parameters are below; #REAL X(NROW,NCOL), W(NROW,NCOL), A(NROW,NCOL,4), B(NDIM,5), G(NROW,NCOL), EPS, ZERO, DELTA, DELC, DELR, ORD, WW, FRACT DATA ZERO/0.0/, DELTA/0.1/, FRACT/0.5/ # Here is my R output; > output<-.C("smooth_",as.integer(NROW),as.integer(NCOL),as.integer(NDIM),as.real(X),as.real(W),as.real(A),as.real(B),as.integer(NCYCLE),as.integer(ICYCLE),as.real(G),as.real(EPS),as.integer(IFAULT)) > > output [[1]] [1] 4 [[2]] [1] 4 [[3]] [1] 4 [[4]] [1] 0.05 0.09 0.20 0.33 0.20 0.29 0.33 0.48 0.35 0.41 0.55 0.60 0.43 0.55 0.70 [16] 0.80 [[5]] [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [[6]] [1] 0.00e+00 0.00e+00 0.00e+00 -5.377600e-19 0.00e+00 [6] 5.377600e-19 0.00e+00 0.00e+00 1.290268e-11 1.803836e-13 [11] 1.333175e-27 0.00e+00 1.333175e-27 0.00e+00 -3.434319e-15 [16] 5.092237e-315 1.00e+00 1.00e+00 1.00e+00 1.00e+00 [21] 1.00e+00 1.00e+00 1.00e+00 1.00e+00 4.99e-02 [26] 8.99e-02 2.00e-01 3.30e-01 2.00e-01 2.90e-01 [31] 3.30e-01 4.78e-01 0.00e+00 0.00e+00 0.00e+00 [36] 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 [41] 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 [46] 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 [51] 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 [56] 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 [61] 0.00e+00 0.00e+00 0.00e+00 0.00e+00 [[7]] [1] 0.330 0.478 1.002 1.002 0.271 0.478 0.000 [8] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15] 0.000 0.000 0.000 0.000 0.000 0.000 [[8]] [1] 5 [[9]] [1] 5 [[10]] [1] 0.0795833 0.1145833 0.2008331 0.310 0.2008331 0.310 0.271 [8] 0.478 0.000 0.000 0.000 0.000 0.000 0.000 [15] 0.000 0.000 [[11]] [1] 0.001 [[12]] [1] 5 > > > Be a better friend, newshound, and __ 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] Specifying relative position of text in a plot
See ?par, entry "usr". Either set a new coordinate system and use it, or convert 1/10 to user coordinates. In R-devel (2.7.0 to be) this is easier: text(grconvertX(0.1,"npc"), grconvertY(0.5, "npc"), "some text") cnvrt.coords() in package TeachingDemos does something similar (although it doesn't use the standard R names for coordinate systems, and there are more than 5). On Wed, 12 Mar 2008, Tom La Bone wrote: > > What is the simplest way to specify the location of text in a scatter plot > (created using the plot function) in relative terms rather than specific x-y > coordinates? For example, rather than putting text at (300,49) on a plot, > how do I put it 1/10 of the way over from the y axis and 1/2 of the way up > from the x axis? Thanks. > > Tom -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] Specifying relative position of text in a plot
Try this: plot(rnorm(100)) text(diff(par("usr")[1:2])/10, sum(par("usr")[3:4])/2, labels="Test") On 12/03/2008, Tom La Bone <[EMAIL PROTECTED]> wrote: > > What is the simplest way to specify the location of text in a scatter plot > (created using the plot function) in relative terms rather than specific x-y > coordinates? For example, rather than putting text at (300,49) on a plot, > how do I put it 1/10 of the way over from the y axis and 1/2 of the way up > from the x axis? Thanks. > > Tom > -- > View this message in context: > http://www.nabble.com/Specifying-relative-position-of-text-in-a-plot-tp16002549p16002549.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] [follow-up] "Longitudinal" with binary covariates and outcome
Ted, What you have can be rendered as a 2^5 (X1 by X2 by X3 by X4 by Y) table of counts, right? Why isn't this a vanilla log-linear modelling (as in loglin() ) problem? It seems to me that the temporal aspect you describe suggests a sequence of margins that could be studied, viz list( 1:4, c(4,5) ) list( 1:4, c(3,5), c(4,5) ) list( 1:4, c(2,5), c(3,5), (4,5) ) list( 1:4, c(1,5, c(2,5), c(3,5), (4,5) ) (taking X1 is the first and Y as the last slice in the table) and perhaps intercalating higher order effects involving slice 5 amongst those. ?? Chuck On Wed, 12 Mar 2008, [EMAIL PROTECTED] wrote: > Hi again! > Following up my previous posting below (to which no response > as yet), I have located a report which situates this type > of question in a longitudinal modelling context. > > http://www4.stat.ncsu.edu/~dzhang2/paper/glm.ps > Generalized Linear Models with Longitudinal Covariates > Daowen Zhang & Xihong Lin > > (This work seems to originally date from around 1999). > > They consider an outcome Y, with a fixed covariate [vector] Z > and a longitudinal covariate [vector] X observed at n time > points t1,...,tn; the outcome Y is observed only at the end > of the sequence. They model Y with a GLM in which Z and > subject-specific random effects U are predictors in the GLM, > where U satisfies a linear mixed model X = T'*U + error > and is normally distributed. > > However, in view of the fact that the longitudinal covariates > X in my query below are binary, there cannot be a linear > mixed model for them; there would have to be a generalised > linear mixed model. > > I have had a good poke around in the R resources, and have > failed to find anything which directly addresses this question > (nor which addresses Zhang & Lin's original question). > > So, if anyone has done R work in this kind of context, > I'd be most grateful for any suggestions (including worked > examples of datasets) arising from it! > > With thanks again, and best wishes to all, > Ted. > > > -FW: <[EMAIL PROTECTED]>- > Date: Tue, 11 Mar 2008 00:17:18 - (GMT) > From: (Ted Harding) <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: "Longitudinal" with binary covariates and outcome > > Hi Folks, > I'd be grateful for suggestions about approaching the > following kind of data. I'm not sure what general class of > models it is best situated in (that's just my ignorance), > and in particular if anyone could point me to case studies > associated with an R approach that would be most useful. > > Suppose I have data of the following kind. Each "subject" > is observed at say 4 time-points T2, T2, T3, T4, yielding > values of binary (0/1) variables X1, X2, X3, X4. At time T4 > is also observed a binary variable Y. The objective is to > study the predictive power of (X1, X2, X3, X4) for the > outcome "Y=1". > > A useful model should take account of the possibility > that more "recent" X's are likely to be better predictors > than less "recent" so that, say, P(Y=1|X4=1) is likely to > be larger than P(Y=1|X1=1), and also that the more X's > are 1, the more likely it is that Y=1. > > Any suggestions or comments and, as I say, pointers to > an R treatment of similar problems would be most welcome. > > With thanks, > Ted. > --End of forwarded message- > > > E-Mail: (Ted Harding) <[EMAIL PROTECTED]> > Fax-to-email: +44 (0)870 094 0861 > Date: 12-Mar-08 Time: 14:35:59 > -- XFMail -- > > __ > 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. > Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ 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 in estimating HURST parameter
Hi, Can u please tell me which all packages do i need to install to estimate the hurst parameter in R. I have tried installing all the possible options but still it doesnt work. basically i want to use 9 functions to estimate hurst parameter like aggvarfit, rsfit, etc. i will be very thankful if u could be of some help. -- Regards, Deepak Jadhav. [[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] ftable and xtabs
Please see the footer of email: > 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. try this cbind(write.ftable(camel, quote=F), write.ftable(dunhill, quote=F))[-(1:length(c(camel, dunhill)))] On 12/03/2008, Amnon Melzer <[EMAIL PROTECTED]> wrote: > Hoping someone can help me with xtabs and ftable. I'm trying to get a pair > of ftables (possibly more) next to each other. For example: > > > > > dunhill_lights_xtab<-ftable(xtabs(grossedupobs ~ gender+age_group + > dunhill_lights, data = ciggs)) > > > dunhill_lights_xtab > > dunhill_lights No Yes > > gender age_group > > Female 16-244013099.665 11182.244 > >25-343563054.240 11378.064 > >35-494195272.6295857.494 > >50+ 3799539.4778433.474 > > Male 16-244173320.528 16692.498 > >25-343873070.488 23458.505 > >35-494113760.574 17419.423 > >50+0.000 0.000 > > > > . this gives me my first table, and then . > > > > > camel_filters_xtab<-ftable(xtabs(grossedupobs ~ gender+age_group + > camel_filters, data = ciggs)) > > > camel_filters_xtab > > camel_filters No Yes > > gender age_group > > Female 16-24 4017419.0386862.871 > >25-34 3570648.4293783.875 > >35-49 4196824.0334306.090 > >50+ 3792671.966 15300.985 > > Male 16-24 4152031.616 37981.410 > >25-34 3837536.726 58992.267 > >35-49 4066210.315 64969.682 > >50+ 0.000 0.000 > > > > I'd like to create one table, essentially both these tables stuck together, > something like > > > > > cbind(dunhill_lights_xtab, camel_filters_xtab) > > [,1] [,2][,3] [,4] > > [1,] 4013100 11182.244 4017419 6862.871 > > [2,] 3563054 11378.064 3570648 3783.875 > > [3,] 4195273 5857.494 4196824 4306.090 > > [4,] 3799539 8433.474 3792672 15300.985 > > [5,] 4173321 16692.498 4152032 37981.410 > > [6,] 3873070 23458.505 3837537 58992.267 > > [7,] 4113761 17419.423 4066210 64969.682 > > [8,] 0 0.000 0 0.000 > > > > . which does the trick, I just loose all the labels. So my question is, can > I create the full combined table, with the labels, from the start (i.e. one > ftable & xtabs command), without the interim steps? > > > > Thanks > > > > Amnon > > > [[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] [follow-up] "Longitudinal" with binary covariates and outcome
Hi again! Following up my previous posting below (to which no response as yet), I have located a report which situates this type of question in a longitudinal modelling context. http://www4.stat.ncsu.edu/~dzhang2/paper/glm.ps Generalized Linear Models with Longitudinal Covariates Daowen Zhang & Xihong Lin (This work seems to originally date from around 1999). They consider an outcome Y, with a fixed covariate [vector] Z and a longitudinal covariate [vector] X observed at n time points t1,...,tn; the outcome Y is observed only at the end of the sequence. They model Y with a GLM in which Z and subject-specific random effects U are predictors in the GLM, where U satisfies a linear mixed model X = T'*U + error and is normally distributed. However, in view of the fact that the longitudinal covariates X in my query below are binary, there cannot be a linear mixed model for them; there would have to be a generalised linear mixed model. I have had a good poke around in the R resources, and have failed to find anything which directly addresses this question (nor which addresses Zhang & Lin's original question). So, if anyone has done R work in this kind of context, I'd be most grateful for any suggestions (including worked examples of datasets) arising from it! With thanks again, and best wishes to all, Ted. -FW: <[EMAIL PROTECTED]>- Date: Tue, 11 Mar 2008 00:17:18 - (GMT) From: (Ted Harding) <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: "Longitudinal" with binary covariates and outcome Hi Folks, I'd be grateful for suggestions about approaching the following kind of data. I'm not sure what general class of models it is best situated in (that's just my ignorance), and in particular if anyone could point me to case studies associated with an R approach that would be most useful. Suppose I have data of the following kind. Each "subject" is observed at say 4 time-points T2, T2, T3, T4, yielding values of binary (0/1) variables X1, X2, X3, X4. At time T4 is also observed a binary variable Y. The objective is to study the predictive power of (X1, X2, X3, X4) for the outcome "Y=1". A useful model should take account of the possibility that more "recent" X's are likely to be better predictors than less "recent" so that, say, P(Y=1|X4=1) is likely to be larger than P(Y=1|X1=1), and also that the more X's are 1, the more likely it is that Y=1. Any suggestions or comments and, as I say, pointers to an R treatment of similar problems would be most welcome. With thanks, Ted. --End of forwarded message- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 12-Mar-08 Time: 14:35:59 -- XFMail -- __ 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] Specifying relative position of text in a plot
What is the simplest way to specify the location of text in a scatter plot (created using the plot function) in relative terms rather than specific x-y coordinates? For example, rather than putting text at (300,49) on a plot, how do I put it 1/10 of the way over from the y axis and 1/2 of the way up from the x axis? Thanks. Tom -- View this message in context: http://www.nabble.com/Specifying-relative-position-of-text-in-a-plot-tp16002549p16002549.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] hello! i need help for a specific graphic issue
quick (and dirty) solution: y.up<- means+stand.error y.dwn<- means-stand.error plot(means,ylim=c(3.5,10)) for (i in 1:length(means)) arrows(i,means[i],i,y.up[i],length=0.1) for (i in 1:length(means)) arrows(i,means[i],i,y.dwn[i],length=0.1) Giacomo Prodi wrote: > > hello, ladyes and gentlemans. > > check this: > > means<-c(4,6,8) > stand.error<-c(0.1,0.3,0.5) > > now i've strongly tryed to scatterplot the > means(y-axis),by showing their sd with the > arrow(..,code=3,angle=90) function. > The problem is that my x-axis has categorical values > (say, factor(x)), and the arrows() can't recognize > them as right coordinates. > ? > thank you all in advance > B.F. insubria university (varese) > > > > La web mail più usata al mondo. > http://it.docs.yahoo.com/mail/overview/index.html > > __ > 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://www.nabble.com/hello%21-i-need-help-for-a-specific-graphic-issue-tp16002183p16002532.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] hello! i need help for a specific graphic issue
I don't think that you're actually creating a scatterplot if the x-axis is a factor. You're getting a boxplot. If you want a scatterplot then something like this might work. == means<-c(4,6,8) stand.error<-c(0.1,0.3,0.5) aa <- factor(c("A","B","C","A", "C", "C")) dd <- 1:length(levels(aa)) plot(dd, means, xaxt="n") arrows(dd, means + stand.error, dd, means-stand.error, code=3, angle=90) axis(1, at=dd, labels=levels(aa)) === --- Giacomo Prodi <[EMAIL PROTECTED]> wrote: > hello, ladyes and gentlemans. > > check this: > > means<-c(4,6,8) > stand.error<-c(0.1,0.3,0.5) > > now i've strongly tryed to scatterplot the > means(y-axis),by showing their sd with the > arrow(..,code=3,angle=90) function. > The problem is that my x-axis has categorical values > (say, factor(x)), and the arrows() can't recognize > them as right coordinates. > ? > thank you all in advance > B.F. insubria university (varese) > > > > La web mail più usata al mondo. > http://it.docs.yahoo.com/mail/overview/index.html > > __ > 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] hello! i need help for a specific graphic issue
On Wed, Mar 12, 2008 at 5:37 AM, Giacomo Prodi <[EMAIL PROTECTED]> wrote: > hello, ladyes and gentlemans. > > check this: > > means<-c(4,6,8) > stand.error<-c(0.1,0.3,0.5) > > now i've strongly tryed to scatterplot the > means(y-axis),by showing their sd with the > arrow(..,code=3,angle=90) function. > The problem is that my x-axis has categorical values > (say, factor(x)), and the arrows() can't recognize > them as right coordinates. > ? > thank you all in advance > B.F. insubria university (varese) This is a bit easier to do with ggplot2: df <- data.frame( trt = factor(c("a", "b", "c")), mean = c(4,6,8), se = c(0.1,0.3,0.5) ) install.packages("ggplot2") library(ggplot2) qplot(trt, mean, data=df) qplot(trt, mean, data=df, min=mean - se, max = mean + se, geom="pointrange") Hadley -- http://had.co.nz/ __ 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] ftable and xtabs
Hoping someone can help me with xtabs and ftable. I'm trying to get a pair of ftables (possibly more) next to each other. For example: > dunhill_lights_xtab<-ftable(xtabs(grossedupobs ~ gender+age_group + dunhill_lights, data = ciggs)) > dunhill_lights_xtab dunhill_lights No Yes gender age_group Female 16-244013099.665 11182.244 25-343563054.240 11378.064 35-494195272.6295857.494 50+ 3799539.4778433.474 Male 16-244173320.528 16692.498 25-343873070.488 23458.505 35-494113760.574 17419.423 50+0.000 0.000 . this gives me my first table, and then . > camel_filters_xtab<-ftable(xtabs(grossedupobs ~ gender+age_group + camel_filters, data = ciggs)) > camel_filters_xtab camel_filters No Yes gender age_group Female 16-24 4017419.0386862.871 25-34 3570648.4293783.875 35-49 4196824.0334306.090 50+ 3792671.966 15300.985 Male 16-24 4152031.616 37981.410 25-34 3837536.726 58992.267 35-49 4066210.315 64969.682 50+ 0.000 0.000 I'd like to create one table, essentially both these tables stuck together, something like > cbind(dunhill_lights_xtab, camel_filters_xtab) [,1] [,2][,3] [,4] [1,] 4013100 11182.244 4017419 6862.871 [2,] 3563054 11378.064 3570648 3783.875 [3,] 4195273 5857.494 4196824 4306.090 [4,] 3799539 8433.474 3792672 15300.985 [5,] 4173321 16692.498 4152032 37981.410 [6,] 3873070 23458.505 3837537 58992.267 [7,] 4113761 17419.423 4066210 64969.682 [8,] 0 0.000 0 0.000 . which does the trick, I just loose all the labels. So my question is, can I create the full combined table, with the labels, from the start (i.e. one ftable & xtabs command), without the interim steps? Thanks Amnon [[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] Spatially Lagged Predictor Variable Models
Hi Everyone, I am doing a project based on "Spatially Lagged Predictor Variable Models", I would like to know which package in R would execute this model. Also, I am new to this field of spatial statistics. Any suggestions for a good book on spatial regression analysis would be appreciated. Thanks Again. Cheers Arun -- View this message in context: http://www.nabble.com/Spatially-Lagged-Predictor-Variable-Models-tp16002454p16002454.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] error window
Hi, I guess this problem is super-trivial but I dont even know where to start looking. After I installed R on my new computer, R has a strange new feature. It shows any error messages not only on the promt (as usual), but also in a little pop up window which I need to click away before I can proceed (see: http://www.lifesciences.at/download.asp?id=1577&lid=1 ) How can I turn this behaviour off? I couldnt find anything in ?options and dont know where else to look cheers Klemens winXP on Dell latitude R 2.6.1 __ 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] Error opening SHP file (maptools)
Don MacQueen llnl.gov> writes: > > The help page for readShapePoints says that the file name that you > supply should not include the extension. > > The "system.file" part of the example in the help page is only to use > the example file that came with the package. Since you want to open > your own file you omit the system.file() bit. > > Do something like: > > readShapePoints( 'C:/path_to_my_file/filename') You may also - for safety's sake - say: list.files(path="C:/path_to_my_file", pattern="filename") to make sure that at least the minimum three files that make up a "shapefile" are present: filename.dbf, filename.shp, and filename.shx. Note that in Windows you can also use the file chooser, by saying: readShapePoints(file.choose()) which will let you navigate to, and "see" the file name for yourself. Roger PS. As Paul mentioned, the R-sig-geo list is well suited to this kind of question. > > Hope this helps. > -Don > > __ 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] hello! i need help for a specific graphic issue
hi Giacomo, consider this: means<-c(4,6,8) stand.error<-c(0.1,0.3,0.5) lowlim<-means-stand.error uplim<-means+stand.error plot(as.factor(c("a","b","c")),means,ylim=c(min(lowlim),max(uplim))) arrows(c(1:3),lowlim,c(1:3),uplim,code=3,angle=90) Still, its just a workaround and I don't think you can get rid of the horizontal mean-lines because this is actually a box-plot. Otherwise you could try the 'errbar()' from the Hmisc package. I never used that, but maybe it works. Generally, if you have problems with plot-dimensions, you can get instant information with 'locator()', which returns coordinates of mouse clicked locations in plots. cheers, /rené > -Ursprüngliche Nachricht- > Von: "Giacomo Prodi" <[EMAIL PROTECTED]> > Gesendet: 12.03.08 11:56:45 > An: r-help@r-project.org > Betreff: [R] hello! i need help for a specific graphic issue > > hello, ladyes and gentlemans. > > check this: > > means<-c(4,6,8) > stand.error<-c(0.1,0.3,0.5) > > now i've strongly tryed to scatterplot the > means(y-axis),by showing their sd with the > arrow(..,code=3,angle=90) function. > The problem is that my x-axis has categorical values > (say, factor(x)), and the arrows() can't recognize > them as right coordinates. > ? > thank you all in advance > B.F. insubria university (varese) > > > > La web mail più usata al mondo. > http://it.docs.yahoo.com/mail/overview/index.html > > __ > 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. > ___ Schon gehört? Der neue WEB.DE MultiMessenger kann`s mit allen: http://www.produkte.web.de/messenger/?did=3015 __ 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] Mimicking SPSS weighted least squares
Dear Peter, Actually, I'm aware of these distinctions. In my experience, identical replicates are relatively rare, but do occur, e.g., when one inputs a contingency table from a secondary source. On the other hand, I can't count the times (including two days ago) that I've seen people do the following using SPSS: Rescale weights that are proportional to inverse probability of selection (often originally scaled to produce estimates of population totals) so that they sum to the sample size, and then use the standard errors, p-values, etc., produced by SPSS. Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org] On Behalf Of Peter Dalgaard > Sent: March-11-08 11:27 AM > To: John Fox > Cc: r-help@r-project.org; 'Ben Domingue' > Subject: Re: [R] Mimicking SPSS weighted least squares > > John Fox wrote: > > Dear JRG, Rolf, Ben, and Peter, > > > > "Frequency" weights, possibly even non-integer weights, are useful > for > > surveys where observations are sampled with unequal probabilities of > > selection. The approach in SPSS gives correct point estimates in this > > situation but incorrect standard errors. The survey package, for > example, > > provides a better solution. > > > > Regards, > > John > > > Actually, I count this as a 3rd variant of weighting. I believe that > SPSS 's standard errors are actually OK for the case where one data > line > actually represents a number of identical replicates. To my mind, there > are three (main) kinds of weighting: > > (1) Variance weighting (weights proportional to inverse variances) > (2) Case weights (weights identical to number of replicates) > (3) Inverse probability weights (weights inversely proportional to > sampling freq.) > > All three give the same point estimates, beta=inv(X'WX)X'WY but the SEs > and DF are different (W is the diagonal matrix of weights). I think the > formulas are as follows (please correct if I goofed): > > in (1) you get sigma^2=Y'(W-WX' inv(X'WX)X'W)Y/(n-rank(X)) , > VCOV= sigma^2 inv(X'WX), > > in (3) it is sigma^2=Y'(I-WX inv(X'WX)X') (I- X inv(X'WX)X'W)Y/(n- > rank(X)), >VCOV=sigma^2 inv(X'WX) X'WWX inv(X'WX) > > in both these cases, the DF are n-rank(X) (glossing over complications > that arise when the weights become zero) and the VCOV are stable to > proportional scaling of W. > > in (2) you get sigma^2=Y'(W-WX' inv(X'WX)X'W)Y/(tr(W)-rank(X)), > VCOV= sigma^2 inv(X'WX), > > This is deceptively similar to (1), but notice the denominator of > sigma^2. In this case, multiplying the weights by, say, 2 will roughly > halve the VCOV, which is fair enough since it means that you have twice > as much data. > > > > John Fox, Professor > > Department of Sociology > > McMaster University > > Hamilton, Ontario, Canada L8S 4M4 > > 905-525-9140x23604 > > http://socserv.mcmaster.ca/jfox > > > > > > > >> -Original Message- > >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > >> project.org] On Behalf Of JRG > >> Sent: March-10-08 10:27 PM > >> To: Rolf Turner; r-help@r-project.org; Ben Domingue > >> Cc: r-help@r-project.org > >> Subject: Re: [R] Mimicking SPSS weighted least squares > >> > >> On 11 Mar 2008 at 14:09, Rolf Turner wrote: > >> > >> > >>> It would appear that the SPSS procedure would then give exactly the > >>> > >> same > >> > >>> point estimates of the parameters, and change the inference > structure > >>> > >> by > >> > >>> changing the ``denominator degrees of freedom'' from n-p to sum(w) > - > >>> > >> p. > >> > >> Well, if that IS what SPSS does, then it sounds like what Stata > calls > >> frequency weights, the > >> general idea being that each "observation" in fact represents some > non- > >> negative number (w) of > >> actual observations that have identical values. Not much more than > a > >> glorified version of a > >> frequency distribution table. > >> > >> I don't see anything fundamentally wrong with frequency weights, > given > >> an appropriate situation. > >> > >> ---JRG > >> > >> John R. Gleason > >> > >> > >> > >> > >>> This seems to me to make little sense ... But then, it ***is*** > >>> SPSS. :-) > >>> > >>> cheers, > >>> > >>> Rolf > >>> > >>> On 11/03/2008, at 11:35 AM, Peter Dalgaard wrote: > >>> > >>> > Rolf Turner wrote: > > > On 11/03/2008, at 4:04 AM, Ben Domingue wrote: > > > > > > > >> Howdy, > >> In SPSS, there are 2 ways to weight a least squares regression: > >> 1. You can do it from the regression menu. > >> 2. You can set a global weight switch from the data menu. > >> These two options have no, in my experience, been equivalent. > >> Now, when I run lm in R with the wei
[R] constrained optimisation
Hi, i have to optimise a function f(a,b), with a, b vectors in R^d such that a and b are orthogonal, that is a'b=0. Anybody has a suggestion? Thanks, in advance, for your help, Giovanna _ [[elided Hotmail spam]] [[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] Graphing question (multiple line graphs arranged spatially)
stephen sefick wrote: station month bas 190 5 0.000 190 7 1.563 190 10 0.000 190 11 0.000 202 4 18.750 202 5 18.750 202 7 6.250 202 10 4.800 202 11 3.125 198 4 18.750 198 5 31.250 198 7 3.125 198 10 3.200 198 11 12.500 205 4 0.000 205 5 0.000 205 7 0.000 205 10 0.000 205 11 0.000 c<-read.table("foo.txt", header=TRUE) x<-subset(c, station=="190") plot(x$bas~x$month, type="b") y<-subset(c, station=="198") plot(y$bas~y$month, type="b") z<-subset(c, station=="202") plot(z$bas~z$month, type="b") zz<-subset(c, station=="205") plot(zz$bas~zz$month, type="b") I would like to put all of the all of these individual line graphs into one 3d graph organized by descending station (205-190). Does anyone know how to do this? Hi Stephen, One way may be with brkdn.plot (slightly modified and this isn't 3D): library(plotrix) # get the modification for one observation per point # this will be in the next version of brkdn.plot source("brkdn.plot.R") brkdn.plot("bas","station","month",ss.df,xaxlab=c(4,5,7,10,11), dispbar=FALSE,md=NA,pch=1:5,lty=1:5,xlab="Month") legend(8,25,unique(ss.df$station),pch=1:5,lty=1:5) Thanks for this - I hadn't thought about using this function with one datum per point. The modified function follows. Jim dispbars<-function(x,y,ulim,llim=ulim,arrow.cap=0.01,arrow.gap=NA,...) { length<-arrow.cap*par("pin")[1] npoints<-length(x) if(is.na(arrow.gap)) arrow.gap<-strheight("O")/1.5 for(i in 1:npoints) { if(!is.na(ulim[i])) { if(arrow.gap >= ulim[i] * 0.9 || arrow.gap >= llim[i] * 0.9) { x0<-rep(x[i]-length,2) x1<-rep(x[i]+length,2) y0<-rep(c(y[i]-llim[i],y[i]+ulim[i]),2) y1<-rep(c(y[i]-llim[i],y[i]+ulim[i]),2) segments(x0,y0,x1,y1,...) } else { x0<-x1<-rep(x[i],2) y0<-c(y[i]+arrow.gap,y[i]-arrow.gap) y1<-c(y[i]+ulim[i],y[i]-llim[i]) arrows(x0,y0,x1,y1,length=length,angle=90,...) } } } } brkdn.plot<-function(vars,groups=NA,obs=NA,data,mct="mean",md="std.error", stagger=NA,dispbar=TRUE,main="Breakdown plot",xlab=NA,ylab=NA,xaxlab=NA, ylim=NA,type="b",pch=1,lty=1,col=par("fg"),staxx=FALSE,...) { if(is.na(obs)) { if(is.na(groups)) stop("Must have at least one factor to subset data") bygroup<-as.factor(data[[groups]]) grouplevels<-levels(bygroup) ngroups<-length(grouplevels) nobs<-length(vars) obs.pos<-1:nobs obslevels<-1:nobs } else { if(is.numeric(data[[obs]])) obs.pos<-obslevels<-sort(unique(data[[obs]])) else { byobs<-as.factor(data[[obs]]) obslevels<-levels(byobs) obs.pos<-1:nobs } nobs<-length(obslevels) if(is.na(groups)) { ngroups<-length(vars) grouplevels<-1:ngroups } else { bygroup<-as.factor(data[[groups]]) grouplevels<-levels(bygroup) ngroups<-length(grouplevels) if(length(vars) > 1) { warning("Group and observation factors are present, only vars[1] is plotted") vars<-vars[1] } } } brkdn<-list(matrix(NA,nrow=ngroups,ncol=nobs), matrix(NA,nrow=ngroups,ncol=nobs)) if(is.na(groups)) { if(is.na(xlab)) xlab<-"Observation" xat<-1:nobs if(is.na(xaxlab[1])) xaxlab<-obslevels for(group in 1:ngroups) { for(ob in 1:nobs) { thisbit<-unlist(subset(data[[vars[group]]], data[[obs]] == obslevels[ob],vars[[group]])) if(length(thisbit)) { if(length(thisbit) > 1) { brkdn[[1]][group,ob]<-do.call(mct,list(thisbit,na.rm=TRUE)) if(!is.na(md)) brkdn[[2]][group,ob]<-do.call(md,list(thisbit,na.rm=TRUE)) } else brkdn[[1]][group.ob]<-thisbit } } } } else { if(is.na(obs)) { if(is.na(xlab)) xlab<-"Variable" xat<-1:length(vars) if(is.na(xaxlab[1])) xaxlab<-vars for(group in 1:ngroups) { for(ob in 1:nobs) { thisbit<-unlist(subset(data[[vars[ob]]], data[[groups]] == grouplevels[group],vars[ob])) if(length(thisbit)) { if(length(thisbit) > 1) { brkdn[[1]][group,ob]<-do.call(mct,list(thisbit,na.rm=TRUE)) if(!is.na(md)) brkdn[[2]][group,ob]<-do.call(md,list(thisbit,na.rm=TRUE)) } else brkdn[[1]][group.ob]<-thisbit } } } } else { if(is.na(xlab)) xlab<-"Observation" xat<-obs.pos if(is.na(xaxlab[1])) xaxlab<-obslevels for(group in 1:ngroups) { for(ob in 1:nobs) { thisbit<-unlist(subset(data,data[[groups]] == grouplevels[group] & data[[obs]] == obslevels[ob],vars)) if(length(thisbit)) { if(length(thisbit) > 1) { brkdn[[1]][group,ob]<-do.call(mct,list(thisbit,na.rm=TRUE)) if(!is.na(md)) brkdn[[2]][group,ob]<-do.call(md,list(thisbit,na.rm=TRUE)) } else brkdn[[1]][group,ob]<-thisbit } } } } } if(is.na(ylim[1])) { ylim<-range(brkdn[[1]],na.rm=TRUE) if(!is.na(md)) { dlim<-c(min(brkdn[[1]]-brkdn[[2]],na.rm=TRUE), max(brkdn[[1]]+brkdn[[2]],na.rm=TRUE)) yli
[R] hello! i need help for a specific graphic issue
hello, ladyes and gentlemans. check this: means<-c(4,6,8) stand.error<-c(0.1,0.3,0.5) now i've strongly tryed to scatterplot the means(y-axis),by showing their sd with the arrow(..,code=3,angle=90) function. The problem is that my x-axis has categorical values (say, factor(x)), and the arrows() can't recognize them as right coordinates. ? thank you all in advance B.F. insubria university (varese) La web mail più usata al mondo. http://it.docs.yahoo.com/mail/overview/index.html __ 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] persp question
On 11/03/2008 2:40 PM, [EMAIL PROTECTED] wrote: > someone sent in a question earlier about doing > something in 3D so i took a stab at it purely > for educational purposes ( i'm not even sure that I understood the question > actually ). > > Unfortunately, persp gives me an error that I don't understand because it > says "object y not found". I'm sending y in as a parameter to persp similar > to what ?persp shows in one of oits examples so I must not be understanding > something. the code is below. thanks. > > DF <- read.table(textConnection("station month bas > 190 5 0.00 > 190 7 1.563 > 190 10 0.000 > 190 11 0.000 > 202 4 18.750 > 202 5 18.750 > 202 7 6.250 > 202 10 4.80 > 202 11 3.125 > 198 4 18.750 > 198 10 3.20 > 198 11 12.500 > 205 4 0.000 > 205 5 0.000 > 205 10 0.000 > 205 11 0.00"),header=TRUE,stringsAsFactors=FALSE) > > #print(DF) > #print(str(DF)) > > temp1 <- seq(1,max(DF$month),length.out=max(DF$month)) > temp2 <- seq(min(DF$station),max(DF$station),by=1) > print(temp1) > print(temp2) > > persp(x = seq(1,max(DF$month),length.out=max(DF$month)), > y = seq(min(DF$station),max(DF$station),by=1), > z = DF$bas, > xlim=range(x), ylim=range(y), zlim=range(z)) The values you pass to persp() are expressions to be evaluated in your workspace. Since you don't have variables x, y or z defined, you can't specify range(x), range(y) or range(z) as arguments. (Things are different for the defaults for the parameters: those are evaluated in the local frame set up for the call.) Duncan Murdoch __ 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] internet proxy settings (win)
Thanks Liviu, I am trying out what is proposed in the mentioned thread. I start R by "C:\Program Files\R\R-2.6.2\bin\Rgui.exe" http_proxy="http://proxy.haifis.org:8080"; Then I do the following (selecting "Austria" as mirror) > install.packages("package", method="wget") --- Please select a CRAN mirror for use in this session --- Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen Zusätzlich: Warning message: In gzfile(file, "r") : cannot open compressed file 'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file678418be', probable reason 'No such file or directory' > setwd('C:\\DOCUME~1\\n301545\\LOCALS~1\\Temp\\RtmpnsKQdi') > install.packages("package", method="wget") Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen Zusätzlich: Warning message: In gzfile(file, "r") : cannot open compressed file 'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file3d6c4ae1', probable reason 'No such file or directory' > update.packages(ask='graphics') Fehler: Indizierung außerhalb der Grenzen Zusätzlich: Warning messages: 1: In read.dcf(file = tmpf) : Line starting ' ...' is malformed! 2: In read.dcf(file = tmpf) : Line starting '...' is malformed! 3: In read.dcf(file = tmpf) : Line starting ' ...' is malformed! > options(download.file.method="wget") > update.packages(ask='graphics') Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen Zusätzlich: Warning message: In gzfile(file, "r") : cannot open compressed file 'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file5f906952', probable reason 'No such file or directory' Obviously the update.packages does have access to internet, but has problems with the html tag. Who can help? Thomas __ 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] Trellis plots with two regression lines
Thanks a lot Thierry and Frede!!! Thats great- I made it much more complicated!!! -- View this message in context: http://www.nabble.com/Trellis-plots-with-two-regression-lines-tp15976467p16000637.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] odfWeave examples not working
Hi, I'm currently taking a look at possibilities to report my results, produced by R. After looking at LaTex, I'm now considering the odf format, as most people at my company work with MS Word. So using odfWeave would be my best bet probably. But if I run some examples from the odfWeave package, I cant open the output in Open Office: demoFile <- system.file("examples", "simple.odt", package = "odfWeave") outputFile <- gsub("simple.odt", "output.odt", demoFile) library(odfWeave) odfWeave(demoFile, outputFile) This will produce output.odt, which should be opened with OpenOfficeWriter I think. But if I run the code above, I get a warning message: In strsplit(x, ".", extend = FALSE, fixed = TRUE) : argument 'extended = FALSE' will be ignored If I open output.odt, I get a message box from open office to select a filter used to open the file. When I choose "open office 1.0 text document" I get: The file is damaged, should Oo try to repair? But after repair, I get a blank work sheet. I'm working on windows XP, session info: R version 2.6.2 (2008-02-08) i386-pc-mingw32 locale: LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium.1252;LC_MONETARY=Dutch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] MASS_7.2-40odfWeave_0.7.3 XML_1.93-2.2 lattice_0.17-4 loaded via a namespace (and not attached): [1] tools_2.6.2 Kind regards Bart -- View this message in context: http://www.nabble.com/odfWeave-examples-not-working-tp16000639p16000639.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] Trellis plots with two regression lines
Try xyplot(abund ~ bif | experiment, data=graphs, groups=stage, type = c("p", "r")) See the help page for panel.xyplot(). Best regards Frede Aakmann Tøgersen Scientist UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1878 E-mail: [EMAIL PROTECTED] Web: http://www.agrsci.org This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. > -Oprindelig meddelelse- > Fra: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] På vegne af yvo > Sendt: 11. marts 2008 13:18 > Til: r-help@r-project.org > Emne: [R] Trellis plots with two regression lines > > > http://www.nabble.com/file/p15976467/table.pdf table.pdf > > I want to create 8 trellis (|experiment) scatterplots with > regression lines for prey and pred in each plot with > different colouring. So far i am creating trellis plots- but > the separation in these groups is never possible. > > library(lattice) > graphs<- read.table("table.txt", header=T) > attach(graphs) > names(graphs) > str(graphs) > xyplot(abund ~ bif | experiment, data=graphs, groups=stage, > panel=function(x,y){panel.xyplot(x,y, pch=16) > panel.abline(lm(y~x))}) > > Thanks a lot for your help!! > Yvonne Fabian > University of Fribourg > > > -- > View this message in context: > http://www.nabble.com/Trellis-plots-with-two-regression-lines- > tp15976467p15976467.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.
Re: [R] SPSS import problem
We need to be able to reproduce this, so can you please make the file available? Please follow up to R-devel. On Wed, 12 Mar 2008, K. Elo wrote: > Dear all, > > I have tried to import a SPSS file in R, but always get the following > message: > --- cut here --- > Error in read.spss("spss-data.sav", : > error reading system-file header > In addition: Warning message: > In read.spss("spss-data.sav", : > spss-data.sav: Variable Y6B_A indicates variable label of invalid > length 256 > --- cut here --- > > SPSS (ver 14) has no problems with this file. read.spss() is not targetted at such a recent version of SPSS, and only allows variable labels of lengths 1...255. > Any ideas? > > Kind regards, > Kimmo > > --- > University of Turku, Finland > Department of Political Science > > __ > 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. > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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 to let R support Chinese fonts in charts?
You need to tell us your OS: see the request in the posting guide for 'at a minimum' the result of sessionInfo(). We also need to know what graphics device(s) you are intending to use. For postscript or PDF, see the article by Paul Murrell and myself in R News 2006-2. Note too that 'Chinese' isn't one language (most OSes have two separate ones for 'traditional' and 'simplified') and several encodings are used for each of those languages. Some devices have separate 'Chinese Fonts' for the two languages. On Wed, 12 Mar 2008, Samuel wrote: Hi everyone, I plotted a chart this morning, which should have Chinese lables for the points. I made the chart via: coordinates: angel77wq360.615019.278135 cngdsthuang1220 -278.74068 91.556843 c国际米兰c 125.47369 -66.589461 fszym2007 -174.86150 346.672588 john_azyb_lee-59.76965 -13.806237 limu0089-135.18684 -147.573071 new枪手 -147.53176 -130.237810 ouyangye1215 103.64392 -154.077046 poleland 20.42025 -190.509781 一声不哭-324.70414 300.982933 一脚抽射 6.99539 -102.055952 三天两句 674.25244 106.671916 九头斑马-282.92130 -38.153908 伯纳乌南斗星-115.72405 -263.611178 健哥傲视天下-165.43261 -174.308852 八零后的天堂-224.57776 332.793277 加泰的灵魂 139.53463 93.483387 劳尔冈萨累斯 -77.28240 -301.935448 四眉水手 627.93457 125.001091 国米露露 -72.13721 176.418576 label: [1] "angel77wq" "cngdsthuang1220" "c国际米兰c" "fszym2007" [5] "john_azyb_lee" "limu0089""new枪手" "ouyangye1215" [9] "poleland""一声不哭""一脚抽射""三天两句" [13] "九头斑马""伯纳乌南斗星""健哥傲视天下""八零后的天堂" [17] "加泰的灵魂" "劳尔冈萨累斯""四眉水手""国米露露" plot(coordinates,type='n') text(coordinates,labels) and then I got the chart looks like the attached one. No attachment appeared -- see the posting guide for details of what might be accepted. I know should be the encoding problem,but I don't know where I can change it. any ideas on this will be greatly appreciated. Thanks in advance. -- Samuel Wu http://webclipping.com.cn -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595__ 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] how to let R support Chinese fonts in charts?
Hi everyone, I plotted a chart this morning, which should have Chinese lables for the points. I made the chart via: coordinates: angel77wq360.615019.278135 cngdsthuang1220 -278.74068 91.556843 c国际米兰c 125.47369 -66.589461 fszym2007 -174.86150 346.672588 john_azyb_lee-59.76965 -13.806237 limu0089-135.18684 -147.573071 new枪手 -147.53176 -130.237810 ouyangye1215 103.64392 -154.077046 poleland 20.42025 -190.509781 一声不哭-324.70414 300.982933 一脚抽射 6.99539 -102.055952 三天两句 674.25244 106.671916 九头斑马-282.92130 -38.153908 伯纳乌南斗星-115.72405 -263.611178 健哥傲视天下-165.43261 -174.308852 八零后的天堂-224.57776 332.793277 加泰的灵魂 139.53463 93.483387 劳尔冈萨累斯 -77.28240 -301.935448 四眉水手 627.93457 125.001091 国米露露 -72.13721 176.418576 label: [1] "angel77wq" "cngdsthuang1220" "c国际米兰c" "fszym2007" [5] "john_azyb_lee" "limu0089""new枪手" "ouyangye1215" [9] "poleland""一声不哭""一脚抽射""三天两句" [13] "九头斑马""伯纳乌南斗星""健哥傲视天下""八零后的天堂" [17] "加泰的灵魂" "劳尔冈萨累斯""四眉水手""国米露露" plot(coordinates,type='n') text(coordinates,labels) and then I got the chart looks like the attached one. I know should be the encoding problem,but I don't know where I can change it. any ideas on this will be greatly appreciated. Thanks in advance. -- Samuel Wu http://webclipping.com.cn __ 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] gracefully handing a library load error
This is not a graceful error, and it needs to be corrected by the package (not 'library') maintainer. R's own devices which need X11 do fail gracefully if the session is headless. Meanwhile, there are other graphics devices which create SVGs and do not do this. E.g. R-devel (to be 2.7.0) has an svg() device that does not require an X11 server, and there is a devSVG() in two packages, RSvgDevice and RSVGTipsDevice. There are lots of ways to catch non-fatal errors (see ?options, ?stop, ?try) but it was a deliberate decision not to allow continuation after a segfault (just wrap-up in interactive use). On Wed, 12 Mar 2008, Will Holcomb wrote: > I have an R program I am attempting to use to generate some SVGs. I've been > using the cairoDevice library. When running a session not connected to an X > session (like if I'm sshed in), attempting "library(cairoDevice)" causes: > > *** caught segfault *** > address 0x8, cause 'memory not mapped' > > Traceback: > 1: .C("R_gtk_setEventHandler", PACKAGE = "cairoDevice") > 2: firstlib(which.lib.loc, package) > 3: doTryCatch(return(expr), name, parentenv, handler) > 4: tryCatchOne(expr, names, parentenv, handlers[[1]]) > 5: tryCatchList(expr, classes, parentenv, handlers) > 6: tryCatch(expr, error = function(e) {call <- conditionCall(e)if > (!is.null(call)) {if (identical(call[[1]], > quote(doTryCatch))) call <- sys.call(-4)dcall <- > deparse(call)[1]prefix <- paste("Error in", dcall, ": ") > LONGCALL <- 30if (nchar(dcall) > LONGCALL) prefix <- > paste(prefix, "\n\t", sep = "")}else prefix <- "Error : "msg <- > paste(prefix, conditionMessage(e), "\n", sep = "") > .Internal(seterrmessage(msg[1]))if (!silent && identical(getOption(" > show.error.messages"), TRUE)) {cat(msg, file = > stderr()).Internal(printDeferredWarnings())} > invisible(structure(msg, class = "try-error"))}) > 7: try(firstlib(which.lib.loc, package)) > 8: library(cairoDevice) > aborting ... > Segmentation fault (core dumped) > > I'm fine with the idea that Cairo somehow needs the X server to do its > business. I would like to not have the program segfault however and instead > just skip the SVG if it can't load the library. I've been hunting to see how > to do error handling in R and I'm not really finding a good resource. Can > anyone suggest one? > > Will > > [[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. > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] SPSS import problem
Dear all, I have tried to import a SPSS file in R, but always get the following message: --- cut here --- Error in read.spss("spss-data.sav", : error reading system-file header In addition: Warning message: In read.spss("spss-data.sav", : spss-data.sav: Variable Y6B_A indicates variable label of invalid length 256 --- cut here --- SPSS (ver 14) has no problems with this file. Any ideas? Kind regards, Kimmo --- University of Turku, Finland Department of Political Science __ 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.