Re: [R] LAT/LON to UTM in R

2014-11-19 Thread Adams, Jean
Zilefac, Those do look different. I called that data frame "arc", and ran this code to look at all three versions of the coordinates. par(mfrow=c(2, 2)) map("world", type="n", xlim=range(xy$X), ylim=range(xy$Y), mar=c(1, 1, 2, 1)) points(xy[, c("X", "Y")]) mtext("xy lat long", side=3, font=2, li

Re: [R] LAT/LON to UTM in R

2014-11-19 Thread Adams, Jean
Zilefac, When I try library(rgdal) utm <- project(as.matrix(xy[,c("X","Y")]), "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") plot(utm) the points look fine. Similar to map("world", xlim=range(xy$X), ylim=range(xy$Y)) points(xy[, c("X", "Y")]) What's wrong with them? Jean On Wed, Nov 19

Re: [R] LAT/LON to UTM in R

2014-11-19 Thread Adams, Jean
Zilefac, I tried to run your "reproducible" code, but you didn't provide an object "xy". Jean On Tue, Nov 18, 2014 at 10:20 AM, Zilefac Elvis wrote: > Hi, > I am trying to convert lat/lon to UTM but my results are extremely flawed. > Is it because of wrong UTM zone or my lon points are negativ

Re: [R] Small vector into large data frame

2014-11-14 Thread Adams, Jean
Use the p_f numbers as an "index" of spot$pxlast. Suppose your data frame is called mydata, mydata$newvar <- spot$pxlast[mydata$p_f] Jean On Fri, Nov 14, 2014 at 8:48 AM, Francesca Pancotto < francesca.panco...@unimore.it> wrote: > Dear Contributors > I seem not to get the general rule applyin

Re: [R] Putting R script in a function.

2014-10-28 Thread Adams, Jean
Frederic, You can simplify your code somewhat using vectorization and the cumsum() function instead of a for loop. Since you focus in on a single year, perhaps you could do the calculations for all the years, and store the result in an array, instead. Then you could grab any day*month matrix fro

Re: [R] Generate sequence of date based on a group ID

2014-10-08 Thread Adams, Jean
Does this work for you? df$in1 <- 0 df$in1[match(unique(df$id), df$id)] <- 1 df$date <- as.Date("2000-01-01") + cumsum(df$in1) - 1 Jean On Wed, Oct 8, 2014 at 2:57 AM, Kuma Raj wrote: > I want to generate a sequence of date based on a group id(similar IDs > should have same date). The id varia

Re: [R] help with subscript on axis lables

2014-10-03 Thread Adams, Jean
Andras, There may be an easier way to do this, but this works. vals <- 1:5 names(vals) <- paste0("ke",1:length(vals)) mp <- barplot(vals, ylim = c(0, 6), ylab=expression(Hour^-10), names.arg="") sapply(vals, function(i) axis(1, at=mp[i], substitute(list(ke[x]), list(x=i)), tick=FALSE)) Jean On

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-02 Thread Adams, Jean
ot only exactly > at 10:00 (as taken from official data) but also 5 min before and after). > > I hope that is more understandable, if not ask again. Thanks for trying > to help, > Dagmar > > Am 02.10.2014 um 23:01 schrieb Adams, Jean: > > Dagmar, > > > > Can you

Re: [R] Problem using predict() to draw lines() if predictor variable is logged on the fly

2014-10-02 Thread Adams, Jean
You will have better luck getting replies to your post if you provide code that we can run. In other words, provide some small example data instead of referring to your data frame that we have no access to. You can use the output from dput() to provide a subset of your data frame to the list. dp

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-02 Thread Adams, Jean
Dagmar, Can you explain more fully why rows 1, 2, and 5 in your result are "low" and rows 3 and 4 are "high"? It is not clear to me from the information you have provided. > result[c(1, 2, 5), ] Timestamp location Event 1 24.09.2012 09:05:011 low 2 24.09.2012 09:49:50

Re: [R] optimization question

2014-10-02 Thread Adams, Jean
Andras, Is there an error in your post or am I missing something? df[, 9] is made up of the last (9th) element of each of a, b, c, and d. The minimum value for sum(df[, 9]) is 0. Given your conditions, there are many, many ways to get this result. Here is just one example: a <-c(1,1,1,1,1,0,0,0,0

Re: [R] error in rownames

2014-09-29 Thread Adams, Jean
stions are painfully naive. I am hoping to get this project > going but just can't get past this stumbling block. Thanks again for the > help thus far. > > Chris > > On Thu, Sep 25, 2014 at 11:06 AM, Adams, Jean wrote: > >> Chris, >> >> You a

Re: [R] error in rownames

2014-09-25 Thread Adams, Jean
Chris, You are not making it easy for R help folks to help you. You need to supply *** reproducible *** code, so that folks can simply copy and paste directly from your e-mail to R and reproduce the error that you are getting. Do you need a guide to follow? See the first 60-some lines of code p

Re: [R] Error in rownames

2014-09-19 Thread Adams, Jean
Chris, It's hard to troubleshoot without reproducible code. I suggest you post a simple example of code that we can run. For example, use dput(training[1:20, ]) to spit out the first 20 lines of the training data. Then simplify the rest of the code as much as possible. library(yaImpute) t

Re: [R] Help with regression

2014-09-04 Thread Adams, Jean
You will find lots of examples if you do an internet search for R quadratic regression Here's just one ... http://www.theanalysisfactor.com/r-tutorial-4/ Jean On Thu, Sep 4, 2014 at 10:40 AM, Basilius Sapientia wrote: > I have this code: > Vm <- c(6.2208, 4.9736, 4.1423, 3.1031, 2.4795, 1

[R] ASA Conf. on Stats Practice - deadline TUESDAY

2014-08-28 Thread Adams, Jean
R users, Abstracts are now being accepted for electronic poster presentations at the 2015 ASA Conference on Statistical Practice, February 19-21, New Orleans, Louisiana, USA. If you are interested, you may submit your abstract on the website, http://www.amstat.org/meetings/csp/2015/abstracts.cfm

Re: [R] Count number of change in a specified time interval

2014-07-30 Thread Adams, Jean
I may not understand exactly what you want, because when I try to follow your instructions, I get a different result. But, perhaps you can use this code and modify it to suit your needs. # number of rows L <- dim(df)[1] # determine for each row if it is within the first 3 months mins <- aggregat

Re: [R] Weight, weight - do tell me

2014-07-22 Thread Adams, Jean
This seems like a more general statistics question rather than an R question. You might have more luck getting a response by posting your question to Cross Validated, http://stats.stackexchange.com/ Jean On Mon, Jul 21, 2014 at 10:13 AM, Lenth, Russell V wrote: > This is a question only about

Re: [R] List of Lists in For Loop

2014-07-15 Thread Adams, Jean
Munjal, Something like this should work: Digits = c(20, 30, 40, 50, 60) result = vector(length(Digits), mode="list") names(result) = Digits for(j in seq(Digits)) { a = vector(Digits[j], mode="list") b = vector(Digits[j], mode="list") for(i in 1:Digits[j]) { #Do Calculation a[[i]] = data.frame(#

Re: [R] Decision Tree

2014-07-10 Thread Adams, Jean
The function fancyRpartPlot() is actually in the rattle package, and it is a wrapper for the prp() function in the rpart.plot package. If you look at the help for prp(), you should be able to see how to change the color. library(rpart.plot) ?prp Jean On Thu, Jul 10, 2014 at 12:34 AM, Abhinaba

Re: [R] How to install Vennerable

2014-07-03 Thread Adams, Jean
"Important note for package binaries: R-Forge provides these binaries only for the *most recent version of R*, but not for older versions. In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R or, alternatively, install from the packag

Re: [R] matrix

2014-06-30 Thread Adams, Jean
t[1, 1] <- 50 t[3, 2] <- 90 t[5, 3] <- 100 Jean On Mon, Jun 30, 2014 at 10:27 AM, IZHAK shabsogh wrote: > > > kindly guide me on how i can delete and replace an element from a matrix t > below > > for example delete first element in column one and replace it with 50, > third element in column

Re: [R] Stringr / Regular Expressions advice

2014-06-26 Thread Adams, Jean
You could define a simple function to detect whether a value is within a given range. For example, inrange <- function(vec, range) { !is.na(vec) & vec >= range[1] & vec <= range[2] } x <- 1:30 inrange(x, c(5, 20)) If you wanted to apply this function to all three columns at once, you could use

[R] ASA Conf. on Stats Practice - deadline THURSDAY

2014-06-24 Thread Adams, Jean
R users, Abstracts are now being accepted for the 2015 ASA Conference on Statistical Practice, February 19-21, New Orleans, Louisiana, USA. Each presentation will have a 45-minute time slot. If you are interested, you may submit your abstract on the website, http://www.amstat.org/meetings/c

Re: [R] CoDA DataFrame: Change Column to Row Name

2014-06-19 Thread Adams, Jean
Rich, If your data frame is called df, try row.names(df) <- df$sampdate Jean On Thu, Jun 19, 2014 at 5:07 PM, Rich Shepard wrote: > I recall reading how to do this somewhere, but I cannot find just where I > read it. I have compositional data frames of this format: > > sampdate filter

[R] ASA Conference on Statistical Practice

2014-06-17 Thread Adams, Jean
R users, Abstracts are now being accepted for the 2015 ASA Conference on Statistical Practice, February 19-21, New Orleans, Louisiana, USA. Each presentation will have a 45-minute time slot. If you are interested, you may submit your abstract on the website, http://www.amstat.org/meetings/c

Re: [R] Power graph for two Proportion

2014-06-17 Thread Adams, Jean
Suga, Perhaps something like this ... library(pwr) n <- 50:100 power <- pwr.2p.test(h=ES.h(0.4,0.2), n=n, sig.level=0.05, alternative="greater")$power plot(n, power) Jean On Mon, Jun 16, 2014 at 10:44 AM, Suganthie Jeyaganth wrote: > Dear R mailing listers, > I am try to find the different p

Re: [R] Extracting data from density plots

2014-06-13 Thread Adams, Jean
I don't know if you can get the information from the plot, but you can certainly get it from the density() function directly. For example, # fake data TestVar <- rnorm(60) type <- rep(c("Bottom", "Other", "Top"), 20) # density of TestVar for each type, estimated at 100 points along range of Test

Re: [R] Legend having lines with different types

2014-05-28 Thread Adams, Jean
IOanna, If you are trying to distinguish between the type="b" and the type="o" in the legend, there does not appear to be a way to do this with the legend() function in base. I found a similar question posted on stackoverflow, and they suggested a work around for something similar (but not quite

Re: [R] Size of win.metafile

2014-05-27 Thread Adams, Jean
Jinsong, When I use your code to create the abcd.emf file, and then copy and paste it into Word, I end up with a 4" x 4" plot with 12 pt font, just as you intended. I'm using R version 3.1.0, and Word 2010 version 14.0.7116.5000. Not sure why it works differently for you. Jean On Mon, May 26,

Re: [R] Problem Creating Partial Dependence Plot

2014-05-27 Thread Adams, Jean
Jane, Page 9 of the reference manual, http://cran.r-project.org/web/packages/plotmo/plotmo.pdf, discusses this error. 'The work-around is to simplify or standardize the way the model function is called. Use a formula and a data frame, or at least explicitly name the variables rather than passing

Re: [R] Error message when fitting a binomial response model using glm

2014-05-23 Thread Adams, Jean
Roland, I did a google search for R Error: inner loop 2; cannot correct step size and found an old R-help message that suggests the glm() algorithm cannot converge. https://stat.ethz.ch/pipermail/r-help/2009-December/223142.html I get the same error message as you when I fit glm(cb

Re: [R] empty density plot for point pattern in spatstat

2014-05-20 Thread Adams, Jean
It works just fine for me ... using R-3.1.0 on Windows 7 and spatstat version 1.37-0. Jean On Tue, May 20, 2014 at 3:31 PM, Christopher W Ryan wrote: > I'm running R-3.0.3 on Windows XP Professional on an institutional PC. > (My freedom to update to a more recent version of R is limited, > alth

Re: [R] cumulative frequency distribution combined with histogram in one plot at two different scales

2014-05-20 Thread Adams, Jean
Shane, Do you have code to create each plot separately? If so, you can use par(new=TRUE) to overlay a second plot over the first with a different y-axis scale. See, for example, http://robjhyndman.com/hyndsight/r-graph-with-two-y-axes/ Jean On Tue, May 20, 2014 at 8:39 AM, Shane Carey wrote:

Re: [R] how di I write a for loop in which i is in POSIX?

2014-05-12 Thread Adams, Jean
Christiane, You will get replies to your queries more quickly if you include reproducible code in your question. For example, it would have been helpful if you had posted the result returned by dput(head(treat)) rather than just copying and pasting the first few rows of treat. treat <- structure

[R] ASA CSP - call for short courses - deadline May 13

2014-05-12 Thread Adams, Jean
Reposting of an earlier announcement, with a reminder of the deadline which is *Tuesday May 13*. === R users, The 2015 American Statistical Association Conference on Statistical Practice is currently accepting proposals for short courses and tutorials. The conference will be held February 19-21

Re: [R] How to store interim print results

2014-04-03 Thread Adams, Jean
Katherine, One easy way to do this for small data is by using the append() function (see code below). But, if you have a lot of data, it may be too slow for you. In that case, you can gain some efficiency if you determine in advance how long the vectors will be, then use indexing to fill in the

[R] ASA Conference on Statistical Practice - call for short courses

2014-04-02 Thread Adams, Jean
R users, The 2015 American Statistical Association Conference on Statistical Practice is currently accepting proposals for short courses and tutorials. The conference will be held February 19-21 in New Orleans, Louisiana, USA. Two R-related short courses were offered at the last conference, both

Re: [R] Which analysis for a set of dummy variables alone ?

2014-02-04 Thread Adams, Jean
This sounds more like a statistics question than an R question. You may have better luck posting to a different forum, e.g., Cross Validated, http://stats.stackexchange.com/. Jean On Tue, Feb 4, 2014 at 3:19 AM, sylvain willart wrote: > Dear R-users, > > I have a dataset I would like to analyz

Re: [R] MCPMod method

2014-02-04 Thread Adams, Jean
I can't answer your question, but I did notice the CRAN page for the MCPMod package states, "The MCPMod package will not be further developed, all future development of the MCP-Mod methodology will be done in the DoseFinding R-package." http://cran.r-project.org/web/packages/MCPMod/index.html Jean

Re: [R] Doubt in simple merge

2014-01-16 Thread Adams, Jean
You are telling it to merge by ID only. But it sounds like you would like it to merge by both ID and age. merge(Elder, Younger, all=TRUE) Jean On Thu, Jan 16, 2014 at 6:25 AM, kingsly wrote: > Dear R community > > I have a two data set called "Elder" and "Younger". > This is my code for simp

Re: [R] About Assigning Missing Values

2014-01-14 Thread Adams, Jean
Your assignment of NAs is fine. When you extract, you have to remember to specify whether you want to include or exclude those NA values. Try this: data1.long[data1.long$time==9 & !is.na(data1.long$time), "time"] Jean On Tue, Jan 14, 2014 at 7:22 AM, Chia-Chieh Lin wrote: > Hi all, > >

Re: [R] Levelplots with non-continuous x-axis breaks

2014-01-09 Thread Adams, Jean
6, 0, 2), runif(6, 0, 2), runif(6, 0, 2)) > > > However, the color doesn’t correspond to that in the key (it is red-ish in > the plot while the 1 corresponds to yellow-ish in the key), so I’m not sure > whether it is the key or the colors that are messed up. Sorry for all these > qu

Re: [R] Levelplots with non-continuous x-axis breaks

2014-01-08 Thread Adams, Jean
mymatrix[,-(1:2)], > extremes=lut)) > plot(c(mymatrix[1,1],mymatrix[length(mymatrix[,1]),2]), c(0,1), > col="White", xlab="", ylab="", main=title, axes=F) > ycenter <- seq(from=0, to=1, length=(length(mymatrix[1,])+2)) > yheight <- 1/length(ycenter) &

Re: [R] Levelplots with non-continuous x-axis breaks

2014-01-07 Thread Adams, Jean
r.scale() above) so that the colors go from blue to red? > Thanks again for the help. > Patrick > > On Jan 7, 2014, at 15:04, Adams, Jean wrote: > > Patrick, > > You were pretty close. > To fix the code you have, just change "matrix" to "mymatrix" in

Re: [R] Levelplots with non-continuous x-axis breaks

2014-01-07 Thread Adams, Jean
Patrick, You were pretty close. To fix the code you have, just change "matrix" to "mymatrix" in two places, and either specify the argument data= or place the heat.colors bit first in the matrix function. Or ... you could use the array() function instead, to shorten up the code a little. myc

Re: [R] howto join matrices produced by rcorr()

2013-12-31 Thread Adams, Jean
Alex, Here's one way to do it, using for() loops. Jean library(Hmisc) # using Swiss Fertility and Socioeconomic Indicators (1888) Data m <- data.matrix(swiss) output <- rcorr(m) varnames <- dimnames(m)[[2]] nvar <- length(varnames) # for loops through all possible pairs for(i in 1:(nvar-1)) {

Re: [R] Trying to optimize a graph

2013-12-30 Thread Adams, Jean
Here's one approach. I changed to the graph a bit to include the extremes of all of the curves, which may or may not be what you want. Jean a <- 0.05 b <- 1 kr <- c(70, 60, 50) K <- kr/a colz <- c("blue","green","red") # determine the limits of the graph maxatx <- kr*b/(2*a) maxaty <- kr*maxatx

Re: [R] Problem of scope

2013-12-27 Thread Adams, Jean
You didn't save the output from the call to funb() within funa(). Try this. funa <- function(x) { # here is some code that defines the variables aa, bb, cc aa <- 11 bb <- 21 cc <- 31 myabc <- c(aa, bb, cc) # fun b uses some input variable of funa to modify aa, bb, and cc myabc <- funb(x) cat(sp

Re: [R] Averaging specified array indices

2013-12-27 Thread Adams, Jean
This does the trick. apply(sapply(xyz_indices, function(xyz) edm[xyz[1], xyz[2], xyz[3], ]), 1, mean) Jean On Fri, Dec 27, 2013 at 7:28 AM, Morway, Eric wrote: > In the larger problem I'm attempting to solve, I read a 2Gb file > into a 4D array, where the first 3 dimensions are related to spa

Re: [R] Erroneous Column Removing Result From User-Defined Function.....

2013-12-26 Thread Adams, Jean
Levent, I would suggest that you get your data the way you want it first, then use the assign() function at the very end of your for() loop. I also think you could simplify the arguments in your assign() function. myfun <- function(dyolu, dadi, dsayi) { for(i in 1:dsayi) { ad <- paste(dadi, i, s

Re: [R] 3D Surface Plot

2013-12-19 Thread Adams, Jean
Check out the wireframe() function in the R package lattice ... library(lattice) ?wireframe Jean On Wed, Dec 18, 2013 at 9:30 AM, Simon Delay-Fortier < simon.delay-fort...@mail.mcgill.ca> wrote: > Hi everyone,I am a very new user of r. I am now mandated to draw a 3-d > surface (and possibly ro

Re: [R] How to plug in characters as object names in a formula (recast from package reshape2 specifically)

2013-12-17 Thread Adams, Jean
Try this (untested code): recast(df, formula(paste(xvar, "~", yvar)), id.var=1:2, measure.var=3) Jean On Mon, Dec 16, 2013 at 9:11 AM, Jun Shen wrote: > Hi everyone, > > This may be very simple but I couldn't figure it out. I have this function > > rsm.lm<-function(data,xvar='xCmin',yvar='yCm

Re: [R] model selection with step()

2013-12-06 Thread Adams, Jean
Karen, Look at the help for the drop1() function. ?drop1 There you will see, "The hierarchy is respected when considering terms to be added or dropped: all main effects contained in a second-order interaction must remain, and so on." So, for fit2, the step() function will only consider dropp

Re: [R] Generating restricted numbers

2013-12-06 Thread Adams, Jean
What value do you want d to take on if it is outside that interval? Here is an example where if d is outside the interval, it is assigned to be one of the interval endpoints. minx <- 0 for(i in 2:T) { x <- alpha * d[i-1] + e[i] maxx <- a*(T-i) if(x < minx) { d[i] <- minx } else { if(x > maxx)

Re: [R] overlaying 2D grid on randomly distributed points

2013-11-21 Thread Adams, Jean
Gonçalo, Interesting question. You can use the optim() function to optimize a function over two dimensions. Here's an example. # some clumpy "cloud" data myx <- c(0.3 + rnorm(50, 0, 0.05), 0.7 + rnorm(50, 0, 0.05)) myy <- c(0.45 + rnorm(50, 0, 0.05), 0.65 + rnorm(50, 0, 0.05)) # size of the fi

Re: [R] Percentiles for unequal probability sample

2013-11-20 Thread Adams, Jean
Rather than "exploding", I suggest you order your data according to tree diameter, then calculate the cumulative sum of the tree densities, and use linear interpolation to estimate the percentiles. For example ... library(plotrix) attach(trees.df) ord <- order(Diameter) CumDensOrdScaled <- resc

Re: [R] Overlay boxplot and scatter.smooth line

2013-11-19 Thread Adams, Jean
Use lines() with loess.smooth() instead of scatter.smooth() to add to the already existing boxplot. For example, boxplot(y~x) lines(loess.smooth(x, y)) Jean On Tue, Nov 19, 2013 at 4:43 AM, Johannes Radinger < johannesradin...@gmail.com> wrote: > Hi, > > I'd like to plot a boxplot and use a s

Re: [R] Providing a Title for a Write.Table - Thinking of Titles in SPSS CTABLES

2013-11-19 Thread Adams, Jean
One way to do it, is just to insert another write.table() command giving the text you want to write. Here's a simple example: myfile <- "c:/temp/junk.csv" for(i in 1:5) { df <- data.frame(x=rnorm(3), y=rnorm(3)) write.table(paste0("Run #", i), myfile, sep="\t", append=(i!=1), col.names=FALSE, row

Re: [R] How to sum a function over a specific range in R?

2013-11-14 Thread Adams, Jean
You should cc r-help on all correspondence, so others can follow the thread. Here is a very simple example of a home-made smooth function. Perhaps you can modify it to suit your needs. Jean # simple smooth function, using a weighted mean smoothfunction <- function(allxs, allys, centerindex, ha

Re: [R] How to sum a function over a specific range in R?

2013-11-13 Thread Adams, Jean
On Tue, Nov 12, 2013 at 11:45 AM, umair durrani wrote: > I am new to R and have already posted this question on stack overflow. The > problem is that I did not understand the answers as the R documentation > about the discussed functions (e.g. 'convolve') is quite complicated for a > newbie like m

Re: [R] Having a relative x-axis in a plot

2013-11-12 Thread Adams, Jean
You could use a slider to move along the x-axis looking at your data in the specified window width. Below is an example with some fake data. library(rpanel) # some fake data myx <- 623+1:1000 myy <- 0.01*myx + rnorm(1000) # width of viewing window mywindow <- 256 # plot the data with a slider

Re: [R] multi

2013-11-05 Thread Adams, Jean
It's easier for folks to help you if you make your data available by reproducible code. You can do this using the dput() function. So, for example, you could share your hessianList with us using dput(hessianList) and then including this code in your post hessianList <- list(structure(c(0.00

Re: [R] Reading data from Excel file in r

2013-11-04 Thread Adams, Jean
em: my Excel file is very big and > I get this error, which says: > > Error: OutOfMemoryError (Java): Java heap space > > Is there any way to read each value one by one and save them in an array? > > > On Mon, Nov 4, 2013 at 6:13 AM, Adams, Jean wrote: > >> You can

Re: [R] Reading data from Excel file in r

2013-11-04 Thread Adams, Jean
You can use the XLConnect package to read in a range of rows and columns, then define a function to subset the odd rows. For example, library(XLConnect) wb <- loadWorkbook("C:/temp/MyData.xls") dat <- readWorksheet(wb, sheet=getSheets(wb)[1], startRow=1, endRow=139, startCol=5, endCol=5) dat <- r

Re: [R] Download CSV Files from EUROSTAT Website

2013-11-04 Thread Adams, Jean
r modifications, s/he > will make my life much easier. > Cheers > > Lorenzo > > > On Fri, 01 Nov 2013 14:25:49 +0100, Adams, Jean wrote: > > Lorenzo, > > I may be able to help you get started. You can use the XML package to > grab the information off the i

Re: [R] mapping data to a geographic map of Europe

2013-11-01 Thread Adams, Jean
") > I get another error message because "eurMapDf" is unknown. > > So I supposed it should be: > eurEduMapDf <- merge(eurMap, eurEdu, by.x="id", by.y="GEO") > > But this doesn't work either.The error message this time is: undefined &g

Re: [R] aggregate function output

2013-11-01 Thread Adams, Jean
Daniel, You can see better what is going on if you look at as.list(x) There you can see that cyl and gear are vectors but mpg and hp are matrices. You can rearrange them using the do.call() function x2 <- do.call(cbind, x) dim(x2) Jean On Fri, Nov 1, 2013 at 7:08 AM, Daniel Fernandes wrote:

Re: [R] Download CSV Files from EUROSTAT Website

2013-11-01 Thread Adams, Jean
Lorenzo, I may be able to help you get started. You can use the XML package to grab the information off the internet. library(XML) mylines <- readLines(url("http://bit.ly/1coCohq";)) closeAllConnections() mylist <- readHTMLTable(mylines, asText=TRUE) mytable <- mylist1$xTable However, when I l

Re: [R] help me align the legend bar

2013-10-30 Thread Adams, Jean
You could use the mar= argument of the par() function to define a wider plot margin on the right, then change the first and third arguments of color.legend() to make the legend fit in the margin. For example, par(mar=c(3, 1, 3, 7)) color2D.matplot(test, axes="F", xlab="", ylab="", main="color.sca

Re: [R] mapping data to a geographic map of Europe

2013-10-30 Thread Adams, Jean
> > eurMap <- readShapePoly(fn="NUTS_2010_**60M_SH/Shape/data/NUTS_RG_60M_** > 2010") > I get the following error message: > > Error in getinfo.shape(filen) : Error opening SHP file > > To you have an idea what I did wrong? > > Thanks a lot and best rega

Re: [R] (no subject)

2013-10-30 Thread Adams, Jean
at 10:34 AM, Stevan Lauriault < stevan.lauria...@gmail.com> wrote: > It would depend on the algorithm. Which is why I'm writing. I'm asking > if anyone knows of a preexisting algorithm that would calculate a score > based on the co-localization of names. > > S > &

Re: [R] (no subject)

2013-10-30 Thread Adams, Jean
What would the calculated score be for the example you give? Jean On Wed, Oct 30, 2013 at 7:03 AM, Stevan Lauriault < stevan.lauria...@gmail.com> wrote: > Hi, > > I'm looking for a function that takes a list and calculates a score based > on > how well "like attracts like". > For example: > > l

Re: [R] R function to locate Excel sheet?

2013-10-29 Thread Adams, Jean
You could use the XLConnect package to do this. For example, something like this might do the trick ... library(XLConnect) mysheet <- "Sheet4" wb <- loadWorkbook("C:/temp/MyData.xlsx") wbsheets <- getSheets(wb) mysheet %in% wbsheets Jean On Tue, Oct 29, 2013 at 3:26 PM, Ron Michael wrote: > H

Re: [R] How to save very large matrix?

2013-10-29 Thread Adams, Jean
Have you tried write.csv() or write.matrix()? I really don't know, but they may be more efficient than write.table() with large matrices. Jean On Tue, Oct 29, 2013 at 2:27 PM, Petar Milin wrote: > Hello! > I have a very large matrix of results: 5x10. I saved it as RDS, > but I would a

Re: [R] mapping data to a geographic map of Europe

2013-10-29 Thread Adams, Jean
Check out this link for some examples http://www.r-bloggers.com/maps-in-r-choropleth-maps/ Jean On Tue, Oct 29, 2013 at 12:02 PM, wrote: > Hello, > I would like to draw a map of Europe. Each country should be colored > depending on how it scores in an index called GPIndex. > Say a dark red

Re: [R] linear line in x, y plot

2013-10-28 Thread Adams, Jean
A few problems ... This statement doesn't make sense. seq(-0.08, -0.02, len = -0.02) Perhaps you meant seq(-0.08, -0.02, by = 0.02) The xlim= and ylim= are arguments to higher level plot functions, like plot(), and won't work for functions lines() or abline(). Are you trying to limit the range o

Re: [R] How to extract residuals from multiple regressions from a loop

2013-10-28 Thread Adams, Jean
Ben, It helps us help you if you provide a simple example with code that anyone can run. When I created a simplified version of you situation, the NAs in the response variable yielded NAs in the residuals just as the help for na.exclude indicates. ?na.exclude Can you replicate the problem (and

Re: [R] Problem with coordinates when trying to draw lines into a raster (image) file

2013-10-28 Thread Adams, Jean
Rick, I see a couple errors in my code ... you will need to attach the MASS package for the eqscplot() function and that function's first arguments should be any coordinates, I use (1, 1) library(jpeg) library(MASS) # download image from internet for use in example # http://www.tootsie.com/wallpa

Re: [R] Error in heatmap

2013-10-24 Thread Adams, Jean
and without "row.names=1" > > Both give me error. > > ** ** > > Regards > > ** ** > > David > > ** ** > > *De:* Adams, Jean [mailto:jvad...@usgs.gov] > *Enviado el:* 24 de octubre de 2013 11:52 > *Para:* David Romero > *CC

Re: [R] Problem with coordinates when trying to draw lines into a raster (image) file

2013-10-24 Thread Adams, Jean
Rick, This uses a different approach than what you propose, but it gets the job done and perhaps you will find it helpful. Jean library(jpeg) # download image from internet for use in example # http://www.tootsie.com/wallpaper/wp_concord2_1344x1008.jpg img <- readJPEG("c:/temp/wp_concord2_1344x1

Re: [R] Error in heatmap

2013-10-24 Thread Adams, Jean
e: > Hi Jean > > ** ** > > Thank you for helping. > > No, there is no empty column or row. I join the data base. > > ** ** > > Regards > > ** ** > > David > > ** ** > > ** ** > > ** ** > > *De:* Adams, Jean [ma

Re: [R] track on boats

2013-10-24 Thread Adams, Jean
It is difficult to advise you when you don't provide reproducible data. For example, you could include the first 6 lines of your data using dput(head(mydata)) If you have GPS points stored as easting, northing, and if you have a variable that identifies the vessel, and if your data are sorte

Re: [R] Error in heatmap

2013-10-22 Thread Adams, Jean
Do you have a row or column that is all missing? sum(apply(is.na(as.matrix(SPIV2)), 1, all)) > 0 sum(apply(is.na(as.matrix(SPIV2)), 2, all)) > 0 For example, this code m <- as.matrix(mtcars) m[8, ] <- NA heatmap(m, na.rm=TRUE) throws this error Error in hclustfun(dist

Re: [R] Apply function to do pairwise calculation

2013-09-30 Thread Adams, Jean
Amanda, If I understand what you're trying to do, this example might help you. M <- structure(c(0.66, 0.05, -0.93, -0.61, 0.65, -0.25, 0.23, -0.89, 0.37, 0.38, -0.91, 0.91, -0.05, -0.65, -0.94, 0.73, -0.88, 0.25, 0.04, -0.89, -0.47, -0.46, 0.86, -0.29, 0.92, 0.22, 0.77, -0.98, -0.56, 0.11, 0.35

Re: [R] barplot - easy for experienced, difficult for me

2013-09-30 Thread Adams, Jean
Look at the example for grouped bar plots here, http://www.statmethods.net/graphs/bar.html Jean On Mon, Sep 30, 2013 at 8:05 AM, happyR wrote: > hey guys, > > I wanna make a simple barplot, looking like this excel graph: >

Re: [R] Permuting friendship nominations in a social network

2013-09-04 Thread Adams, Jean
Holly, I don't know of a clever way to do this, but I can think of a brute force way, which might only be feasible if you have a small data set (as in your example). You could permute every possible set of connections, then choose from that collection only the ones that meet your criteria. Using

[R] ASA Conference on Statistical Practice

2013-08-28 Thread Adams, Jean
R users, The deadline for poster abstracts is tomorrow, August 29, for the 2014 ASA Conference on Statistical Practice, February 20-24, Tampa, Florida, USA. Based on a survey of the 2013 CSP attendees there was particular interest in R. It would be nice to see contributions from the R community

Re: [R] plot categorical variable with percentage infomation

2013-08-26 Thread Adams, Jean
Jie, I'm not exactly sure what you're after. Perhaps this will help you get started. count <- table(a) prop <- count/length(a) b <- plot(a) text(b, count, prop, pos=1) Jean On Mon, Aug 26, 2013 at 11:27 AM, Jie wrote: > Dear All, > > Suppose I have a categorical variable > a=as.factor(sampl

Re: [R] Get Index of variables from stepAIC

2013-08-26 Thread Adams, Jean
Here's one way to do it ... # create example data frame y <- rnorm(30) gene_subset <- data.frame(y, x1=rnorm(30), x2=rnorm(30), x3=100*y+rnorm(30)) # fit a full linear model fit <- lm(y ~ ., df) # reduce the model reduced_model <- stepAIC(fit, trace=FALSE) # NON-omitted variables (excluding the

Re: [R] Selection of regressors

2013-08-25 Thread Adams, Jean
Note that this message is cross-posted in cross-validated ... http://stats.stackexchange.com/questions/68250/selection-of-regressors Jean On Sat, Aug 24, 2013 at 11:48 AM, beginner wrote: > I have a question about the package leaps which I am using for model > selection. > > I would like to co

Re: [R] lasso cross-validation

2013-08-20 Thread Adams, Jean
Samuel, Typically when someone specifies 10-fold cross validation, it implies that a single series of 10 validations are run. No repeats. You can read more about cross-validation here ... http://en.wikipedia.org/wiki/Cross-validation_(statistics)#K-fold_cross-validation . Jean On Mon, Aug 19,

[R] ASA Conference on Statistical Practice

2013-08-15 Thread Adams, Jean
R users, Poster abstracts are now being accepted for the 2014 ASA Conference on Statistical Practice, February 20-24, Tampa, Florida, USA. Presenters are required to host their posters during their assigned 90-minute session. Based on a survey of the 2013 attendees there was particular interest

Re: [R] Data corruption with big numbers.

2013-08-09 Thread Adams, Jean
The link to FAQ 7.31 is http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f Jean On Fri, Aug 9, 2013 at 8:16 AM, jim holtman wrote: > FAQ 7.31 is a start. > > Understand the "precision" of floating point numbers. You probably only > have about 15

Re: [R] Stuck in size when looping

2013-08-07 Thread Adams, Jean
Rolf, It's great that you provided example data and code. It's helpful if you provide data in a way that's easy for others to run. For example, you can use the output from the call to the dput() function. dput(dtot) dput(newtot) Then you could share the example data like this: # TRAINING data..

Re: [R] breaks argument in heatmap.2 doesn't do what it should I think

2013-08-06 Thread Adams, Jean
If you look at the help for heatmap.2 (in the gplots package) you will see the following explanation for breaks # mapping data to colors breaks, symbreaks=min(x < 0, na.rm=TRUE) || scale!="none", If you run your code with the second call to the heatmap.2() functio

Re: [R] obtain triplets from Data Frame columns

2013-08-05 Thread Adams, Jean
ause I wanted indeed triplets but also > groups of 4, 5 and so on. This is why the nbElements is defined in my code. > > My problem I think is that I am using the scripting languages logic in R > !!! I should > Thanks, > > > > > On 5Aug, 2013, at 21:01 , Adams, Jean wrote

Re: [R] obtain triplets from Data Frame columns

2013-08-05 Thread Adams, Jean
Hmmm. I'm not sure why you prefer 20-30 lines of looping code over a simpler 1 line solution, but, as you wish. merge(df, df, by.x="V.2", by.y="V.1")[, c(2, 1, 3)] Jean On Mon, Aug 5, 2013 at 12:37 PM, PQuery wrote: > Hello Jean, > > Thanks for the reply. However, you solution doesn't reprod

Re: [R] Avoiding slow for-loops (once again)

2013-08-05 Thread Adams, Jean
Thomas, Here's a little bit of code to get you started. You can use the dist() function to calculate the absolute differences between all pairs of rows, then divide by 2 (as you requested), then convert the distance matrix to a vector. Do this for both groups of columns, and use cbind() to combi

Re: [R] obtain triplets from Data Frame columns

2013-08-05 Thread Adams, Jean
Try this: merge(df, df, by.x="V2", by.y="V1") Jean On Mon, Aug 5, 2013 at 1:26 AM, PQuery wrote: > Hi Guys, > > I have a list elements in two columns of a data frame. I want first to > subselect on V1 and then to form and count all possible and unique triplets > of V1 with the corresponding

<    1   2   3   >