Re: [R] R Sig-Geo group - loop for creating spatial matrix
You may handle that as a list of "nb" objects. library(spdep) example(columbus) coord <- coordinates(columbus) z <- c(1,2,3,4,5,6,7,8,9) neighbors.knn <- list() for (val in z) { neighbors.knn <- c(neighbors.knn, list(knn2nb(knearneigh(coord, val, longlat=F), sym=F))) } class(neighbours.knn) class(neighbors.knn[[1]]) plot(neighbors.knn[[1]], coord) class(neighbors.knn[[2]]) plot(neighbors.knn[[2]], coord) and so on. Best, -- GG [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Plotting Dates Time Series Data
This tutorial may help: http://faculty.washington.edu/ezivot/econ424/Working%20with%20Time%20Series%20Data%20in%20R.pdf See pages 20 and 27 for your specific issue. Best, -- GG [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Modelling non-Negative Time Series
https://cran.r-project.org/web/packages/tsintermittent/tsintermittent.pdf Best, -- GG [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 Sig-Geo group - loop for creating spatial matrix
Dear all,I want to create a routine to generate an object for different value of val: z <- c(1,2,3,4,5,6,7,8,9) for (val in z) { neighbors.knn <- knn2nb(knearneigh(coord, val, longlat=F), row.names=cod_pro,sym=F) } However, it seems it does not work. How to store the neighbors.knn created matrix befoire being overwritten. In other words, I want to create multiple spatial matrix, say, for different k neighbours. Thanks a lot for any help. francper [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Efficient way to create new column based on comparison with another dataframe
Hi Gaius, On 01/29/2016 10:52 AM, Gaius Augustus wrote: I have two dataframes. One has chromosome arm information, and the other has SNP position information. I am trying to assign each SNP an arm identity. I'd like to create this new column based on comparing it to the reference file. *1) Mapfile (has millions of rows)* NameChr Position S1 1 3000 S2 1 6000 S3 1 1000 *2) Chr.Arms file (has 39 rows)* ChrArmStart End 1 p 0 5000 1 q 50011 *R Script that works, but slow:* Arms <- c() for (line in 1:nrow(Mapfile)){ Arms[line] <- Chr.Arms$Arm[ Mapfile$Chr[line] == Chr.Arms$Chr & Mapfile$Position[line] > Chr.Arms$Start & Mapfile$Position[line] < Chr.Arms$End]} } Mapfile$Arm <- Arms *Output Table:* Name Chr Position Arm S1 1 3000 p S2 1 6000 q S3 1 1000 p In words: I want each line to look up the location ( 1) find the right Chr, 2) find the line where the START < POSITION < END), then get the ARM information and place it in a new column. This R script works, but surely there is a more time/processing efficient way to do it. You could use the GenomicRanges package for this: 1) Turn 'Mapfile' and 'Chr.Arms' into GRanges objects: library(GenomicRanges) query <- makeGRangesFromDataFrame(Mapfile, start.field="Position", end.field="Position") subject <- makeGRangesFromDataFrame(Chr.Arms) 2) Call findOverlaps() on them: Mapfile2Chr.Arms <- findOverlaps(query, subject, select="arbitrary") 3) Use the result of findOverlaps() to create the column to add to 'Mapfile': Mapfile$Arm <- Chr.Arms$Arm[Mapfile2Chr.Arms] Mapfile # Name Chr Position Arm # 1 S1 1 3000 p # 2 S2 1 6000 q # 3 S3 1 1000 p Should be very fast. Note that GenomicRanges is a Bioconductor package: http://bioconductor.org/packages/GenomicRanges Make sure you follow the Installation instructions on that page. Cheers, H. Thanks in advance for any help, Gaius [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpa...@fredhutch.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] as(, "numeric") vs as.numeric()
On 02/01/2016 07:33 AM, Duncan Murdoch wrote: On 01/02/2016 10:00 AM, Erik Wright wrote: Dear Frank, Thank you for the quick response. I am familiar with the tradeoffs between integers and doubles. However, I do not believe this answers my question. If you look at the help information for the as() function it says: "as(x, "numeric") uses the existing as.numeric function." But clearly the result is different in each case. Since is.numeric(1:10) and is(1:10, "numeric") are both true, the as() function eventually bails out and does nothing. But it should. Because as() has an extra argument 'strict' that is TRUE by default. From the man page for as(): strict: logical flag. If ‘TRUE’, the returned object must be strictly from the target class (unless that class is a virtual class, in which case the object will be from the closest actual class, in particular the original object, if that class extends the virtual class directly). If ‘strict = FALSE’, any simple extension of the target class will be returned, without further change. A simple extension is, roughly, one that just adds slots to an existing class. So the current behavior is clearly a bug, has been reported several times, and is known from the R-core folks: https://stat.ethz.ch/pipermail/r-devel/2015-December/072079.html FWIW this bug is actually related to this other bug: x <- 1:10 class(x) # [1] "integer" class(x) <- "numeric" class(x) # [1] "integer" Cheers, H. So yes, as(x, "numeric") uses as.numeric() when it needs to coerce, but not when no coercion is necessary. The docs could perhaps add this condition. Duncan Murdovh If the help for as() is correct, then as(1:10, "numeric") should also return doubles, and the second argument is not ignored. Erik > On Feb 1, 2016, at 8:16 AM, Franklin Bretschneiderwrote: > > Dear Erik Wright, > > > Re: > >> Could someone please explain this R behavior to me: >> >>> typeof(as.numeric(1:10)) >> [1] "double" >>> typeof(as(1:10, "numeric")) >> [1] "integer" >> >> I expected "double" in both cases. In the help for the "as" function it says: >> >> "Methods are pre-defined for coercing any object to one of the basic datatypes. For example, as(x, "numeric") uses the existing as.numeric function." > > > This happens because 1:10 yields only integers, and so can be stored cheap, > whereas as.numeric() actually means: as.double. > The "numeric" in the second line is an unused argument. > > Best regards, > > Frank > --- > > > > > Franklin Bretschneider > Dept of Biology > Utrecht University > brets...@xs4all.nl > > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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. -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpa...@fredhutch.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 ./configure messages
I've installed R from the tgz file since about R-0.9.x following the INSTALL instructions and have always succeeded using rpm-based OSes. With each new OS, that involved installing various additional packages before the configure script would complete. Figuring out which packages were required usually involved searching for rpms that supplied missing .so or .h files, dev packages or something else I could figure out. I'm now trying to do the same with LinuxMint 17.2 but I got stuck when this message came up: checking for main in -ltermlib... no checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available Near the bottom of the log file it shows this: configure:6747: gcc -E -I/usr/local/include conftest.c configure:6747: $? = 0 configure:6761: gcc -E -I/usr/local/include conftest.c conftest.c:17:28: fatal error: ac_nonexistent.h: No such file or directory #include ^ compilation terminated. configure:6761: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "R" So I'm assuming that's behind the failure. Searching shows the same problem shows up in all sorts of places for decades, notably cygwin users. But I didn't see anything that would help to work out what is missing. Ideas greatly appreciated. best Patrick __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] String Matching
> On 1 Feb 2016, at 08:03, PIKAL Petrwrote: > > Hi > > Maybe I am completely wrong but do you really need regular expressions? > > You say you want to compare first nine characters of id? > >> substr(id, 1,9)==cusip > [1] TRUE >> > > or the last six? > >> substr(id, nchar(id)-6, nchar(id))=="432.rds" > [1] TRUE >> > > Cheers > Petr > > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Glenn >> Schultz >> Sent: Friday, January 29, 2016 6:02 PM >> To: R Help R >> Subject: [R] String Matching >> >> All, >> >> I have a file named as so 313929BL4FNMA2432.rds the user may pass >> either the first 9 character or the last six characters. I need to >> match the remainder of the file name using either the first nine or >> last six. I have read the help files for Regular Expression as used in >> R and I think what I want to use is glob2rx. >> >> I have worked a minimal example to test my code: >> >> id <- "313929BL4FNMA2432.rds" >> cusip <- "313929BL4" >> poolnumm <- "FNMA2432" >> paste(cusip, ".*", ".rds") >> glob2rx(paste(cusip, ".*", ".rds"), trim.head = TRUE, trim.tail = TRUE) >> >> This returns false which leads me to believe that it is not working >> glob2rx(paste(cusip, ".*", ".rds"), trim.head = TRUE, trim.tail = TRUE) >> == id >> >> I am going to use as follows in the function below - which returns the >> error file not found >> >> MBS_Test <- function(MBS.id = "character"){ MBS <- >> glob2rx(paste(MBS.id, ".*", "//.rds", sep = ""), trim.tail = TRUE) >> MBS.Conn <- gzfile(description = paste(system.file(package = >> "BondLab"), "/BondData/", MBS, sep = ""), open = "rb") MBS <- >> readRDS(MBS.Conn) >> on.exit(close.connection(MBS.Conn)) >> return(MBS) >> } >> I don't think you are using (glob) wild characters correctly; where you write .* you likely need *? In addition why not use paste0, which does not use as separator, instead of paste? Finally your poolnumm variable consists of 8 characters and not 6. If you change your minimal example to this: paste0(cusip, "*", ".rds") glob2rx(paste0(cusip, "*", ".rds")) grepl(glob2rx(paste0(cusip, "*", ".rds")), id) grepl(glob2rx(paste0("*", poolnumm, ".rds")), id) you get TRUE twice. But Petr's solution for the first 9 characters is much simpler. And for matching the last 6 (8) you'll have to remove the extension first and then use substr (if I understand your problem correctly). Berend __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] String Matching
Hi Maybe I am completely wrong but do you really need regular expressions? You say you want to compare first nine characters of id? > substr(id, 1,9)==cusip [1] TRUE > or the last six? > substr(id, nchar(id)-6, nchar(id))=="432.rds" [1] TRUE > Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Glenn > Schultz > Sent: Friday, January 29, 2016 6:02 PM > To: R Help R > Subject: [R] String Matching > > All, > > I have a file named as so 313929BL4FNMA2432.rds the user may pass > either the first 9 character or the last six characters. I need to > match the remainder of the file name using either the first nine or > last six. I have read the help files for Regular Expression as used in > R and I think what I want to use is glob2rx. > > I have worked a minimal example to test my code: > > id <- "313929BL4FNMA2432.rds" > cusip <- "313929BL4" > poolnumm <- "FNMA2432" > paste(cusip, ".*", ".rds") > glob2rx(paste(cusip, ".*", ".rds"), trim.head = TRUE, trim.tail = TRUE) > > This returns false which leads me to believe that it is not working > glob2rx(paste(cusip, ".*", ".rds"), trim.head = TRUE, trim.tail = TRUE) > == id > > I am going to use as follows in the function below - which returns the > error file not found > > MBS_Test <- function(MBS.id = "character"){ MBS <- > glob2rx(paste(MBS.id, ".*", "//.rds", sep = ""), trim.tail = TRUE) > MBS.Conn <- gzfile(description = paste(system.file(package = > "BondLab"), "/BondData/", MBS, sep = ""), open = "rb") MBS <- > readRDS(MBS.Conn) > on.exit(close.connection(MBS.Conn)) > return(MBS) > } > > Any help to get me in the right direction is appreciated - Glenn > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
Re: [R] Multilevel Modeling in R
Dear David, R-sig-mixedmodels is a better mailing list for this kind of question. 1) yes 2) use (Treatment | Random_Assignment_Block) instead of (1 | Random_Assignment_Block) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2016-01-29 7:10 GMT+01:00 David Roy: > I am conducting a multilevel regression analysis on the effect of an > intervention on student test results, and am not sure how to implement the > necessary R code to correctly capture the nested structure. > > > > The outcome measure for the study is whether a student passed or failed a > final exam. The structure of the data is students nested within schools, > and then schools nested within random assignment blocks. Treatment (i.e., > the intervention) was implemented at the school-level. The covariates that > I am planning to use are prior year test scores (this is also a binary > variable for pass or fail), race, and gender. > > > > My ideal output would show the impact of the treatment for each of the > random assignment blocks, and then the weighted average of the impact > across all of the random assignment blocks. > > > > Based on my research thus far, it seems like the **lmer** function from the > **lme4** package would be the best route to go. > > > > This is the code that I have tried: > > > > # Fit multilevel regression with random assignment blocks > > glmer2 <- glmer(Post_Test_Score ~ Treatment + > > Pre_Test_Score + > > (1 | School) + > > (1 | Random_Assignment_Block), > > data = StudyData, > > family = binomial("logit")) > > > > My two questions are the following: > > > > 1.) Given the nested structure of my data, would the above regression > output the correct coefficient for the impact of treatment across all > random assignment blocks? > > > > 2.) How would I code the interaction effect between Treatment and > Random_Assignment_Block in order to generate separate impact estimates for > each of the random assignment blocks? > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] as(, "numeric") vs as.numeric()
Hi everyone, Could someone please explain this R behavior to me: > typeof(as.numeric(1:10)) [1] "double" > typeof(as(1:10, "numeric")) [1] "integer" I expected "double" in both cases. In the help for the "as" function it says: "Methods are pre-defined for coercing any object to one of the basic datatypes. For example, as(x, "numeric") uses the existing as.numeric function." Thanks, Erik __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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-pkgs] New Package: backblazer
Dear R users, I'm pleased to announce that my first package has been accepted in CRAN. https://cran.r-project.org/web/packages/backblazer/ backblazer provides bindings to Backblaze's B2 cloud storage API. As it is my first package on CRAN, I would certainly appreciate feedback and suggestions from more experienced packagers. Regards, Phill [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] updating elements of a list of matrixes without 'for' cycles
A perhaps faster approach takes advantage of the column major ordering of arrays and the expand.grid() function. I say "perhaps" faster, because "apply" family functions are still actually loops at the R level. Anyway, try this (using your little example): ## create a data frame (which is also a list) of i,j,k,index combinations: z <- expand.grid(i=1:2, j= 1:2, k = 1:2) ## Use do.call() to feed the columns of z to mapply yourarray <- array(do.call(mapply,c(prod,z)),dim=c(2,2,2)) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Feb 1, 2016 at 6:29 AM, Jue Lin-Yewrote: >> >> Date: Sat, 30 Jan 2016 01:03:30 + >> From: Matteo Richiardi < >> >> matteo.richia...@maths.ox.ac.uk> >> To: r-help@r-project.org >> Subject: [R] updating elements of a list of matrixes without 'for' >> cycles >> Message-ID: >> < >> cabsru1lkohuz8m9jw1ju+nemksprirrtd_0wzotrlwi3z6d...@mail.gmail.com> >> Content-Type: text/plain; charset=UTF-8 >> >> Hi, following an earlier suggestion from the list, I am storing my >> data in a "cube", i.e. an array of matrixes. >> Is there any smarter way of updating the elements of the cube through >> a function, other than the three 'for' cycles in the example below? >> (please note that the example is simplistic; in particular, my >> function is more complicated). >> >> # parameters >> I <- 2L >> J <- 2L >> H <- 2L >> >> # data container: an array of matrixes >> mycube <- array(dim=c(I,J,H)) >> >> # initialisation >> for (h in 1:H) { >> init <- matrix(c(rep(0,J)),nrow=I,ncol=J) >> mycube[,,h] <- init >> } >> >> # function >> foo = function(i,j,h){ >> mycube[i,j,h] <<- i*j*h >> } >> >> # update >> >> for(h in 1:H){ >> # males: >> for(i in 1:I) >> for(j in 1:J) >> foo(i,j,h) >> } >> >> Thanks a lot for your help. Matteo >> >> >> > Greetings! Have you tried sapply() on this script? > > -- > Jue > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] open script from web
Well, two steps: download.file() and then file.edit(). Best, Uwe Ligges On 02.02.2016 06:16, Benn Fine wrote: Hello In R, is it possible to load a script file into the editor via a web address? That is, I have a script file I want people to grab located at http://www.foo.com/bar.R and want to do something like file.edit("http://www.foo.com/bar.R;). But that doesn't seem to work. thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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] open script from web
Hello In R, is it possible to load a script file into the editor via a web address? That is, I have a script file I want people to grab located at http://www.foo.com/bar.R and want to do something like file.edit("http://www.foo.com/bar.R;). But that doesn't seem to work. thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] amending R+dependencies
Install a recent version of R such as R-3.2.3. R-3.0.2 is unsupported. Best, Uwe Ligges On 02.02.2016 01:00, kle...@sxmail.de wrote: Dear all,[a] after I have virtually given up on gearing up my R (v. 3.0.2; GUI: rkward; on last Linux Kubuntu LTS) for properly installing useful packages containing functions that were not delivered with base R, amendment of R through getting packages from CRAN became the only viable way to obtain functionality in R for me so far.[b] By the time I used my GUI for supplementary packages' installation, dependencies were treated by that GUI's updater and it occurred that packages were uninstallable due to packages not suitable for that very R version.[c] Now I wonder whether there were any (massive?) impending problems when one would eventually proceed to extract corresponding package archives upon download into the corresponding file folder subsequently using R, say in its interactive mode via the GUI of choice. I am referring to that kind of problem(s) which the R console (interactive mode) could throw after me, I have to be sufficiently precise...Best regards,Markus Hofst! et! ter [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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] open script from web
In almost all cases the answer is No. Some Web servers support WebDAV, but standard HTTP does not work that way. Has nothing to do with R. -- Sent from my phone. Please excuse my brevity. On February 1, 2016 9:16:59 PM PST, Benn Finewrote: >Hello > >In R, is it possible to load a script file into the editor via a web >address? > >That is, I have a script file I want people to grab located at >http://www.foo.com/bar.R >and want to do something like file.edit("http://www.foo.com/bar.R;). >But >that doesn't seem to work. > >thanks > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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 -- To UNSUBSCRIBE and more, see 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 read ./configure messages
I am not overly familar with Mint, but you need the "development version" of the readline library. If you have a GUI package manager installed, open it and search for readline. You should see a version that ends with -dev or -devel; you need to install that. HTH, Peter On Mon, Feb 1, 2016 at 3:06 PM, p_connollywrote: > > I've installed R from the tgz file since about R-0.9.x following the > INSTALL instructions and have always succeeded using rpm-based OSes. > With each new OS, that involved installing various additional packages > before the configure script would complete. Figuring out which > packages were required usually involved searching for rpms that > supplied missing .so or .h files, dev packages or something else I > could figure out. > > I'm now trying to do the same with LinuxMint 17.2 but I got stuck when > this message came up: > >checking for main in -ltermlib... no >checking for rl_callback_read_char in -lreadline... no >checking for history_truncate_file... no >configure: error: --with-readline=yes (default) and headers/libs are not > available > > Near the bottom of the log file it shows this: > >configure:6747: gcc -E -I/usr/local/include conftest.c >configure:6747: $? = 0 >configure:6761: gcc -E -I/usr/local/include conftest.c >conftest.c:17:28: fatal error: ac_nonexistent.h: No such file or > directory > #include >^ >compilation terminated. >configure:6761: $? = 1 >configure: failed program was: >| /* confdefs.h */ >| #define PACKAGE_NAME "R" > > So I'm assuming that's behind the failure. Searching shows the same > problem shows up in all sorts of places for decades, notably cygwin > users. But I didn't see anything that would help to work out what is > missing. > > Ideas greatly appreciated. > > > best > Patrick > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Panel Data Help
I am going to go out on a limb and say that the answer to your question is "Yes". However, I cannot decipher specifics from your description. If you want a more useful answer you need to follow the advice in the Posting Guide mentioned in the footer (including posting in plain text rather than HTML, and providing some sample data). You will also benefit from reading [1], with particular attention to using the dput function. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example -- Sent from my phone. Please excuse my brevity. On February 1, 2016 12:36:36 PM PST, Daniel Dorchuckwrote: >Hi, > >I'm currently working on an econometrics project on banking and looking >to >merge a dataframe of bank specific data with dataframes of macro >variables. >I am then going to transform the data set into a plm dataframe using >the plm >package. The bank specific observations are indexed across time while >the >macro ones are indexed only across time. Is there a way to merge the >two so >I can use both in my panel regression? > >Best, >Dan > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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 -- To UNSUBSCRIBE and more, see 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] Panel Data Help
Hi, I'm currently working on an econometrics project on banking and looking to merge a dataframe of bank specific data with dataframes of macro variables. I am then going to transform the data set into a plm dataframe using the plm package. The bank specific observations are indexed across time while the macro ones are indexed only across time. Is there a way to merge the two so I can use both in my panel regression? Best, Dan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] on specifying an encoding for plot's main-argument
Duncan Murdochwrites: > On 29/01/2016 10:35 AM, Daniel Bastos wrote: >> Here's how I plot a graph. >> >>plot(c(1,2,3), main = "graph ç") >> >> The main-string has a UTF-8 character "ç". I believe I'm using the >> windows device. It opens up on my screen. (The window says ``R >> Graphics: Device 2 (ACTIVE)''.) How can I tell it to use my encoding of >> choice? > > As far as I know that's impossible. R uses the system encoding, and I > don't think any Windows versions use UTF-8 code pages. They use > UTF-16 for wide characters, and some 8 bit encoding for byte-sized > characters. R will use whatever 8 bit code page Windows chooses. You seem to be correct. Here's what Microsoft has to say. ``[...] UTF-16 [...] is the most common encoding of Unicode and the one used for native Unicode encoding on Windows operating systems.''[1] They also claim that ``[w]hile Unicode-enabled functions in Windows use UTF-16, it is also possible to work with data encoded in UTF-8 or UTF-7, which are supported in Windows as multibyte character set code pages.''[1] But I couldn't verify the claim. The documentation of setlocale[2] says the ``set of available locale names, languages, country/region codes, and code pages includes all those supported by the Windows NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8. If you provide a code page value of UTF-7 or UTF-8, setlocale will fail, returning NULL.''[2] That seems to be correct as per the following C code. printf("locale: %s\n", setlocale(LC_ALL, "UTF-8")); And [3] makes me think that _wsetlocale behaves the same way: ``_wsetlocale [...] is a wide-character version of setlocale; the arguments and return values of _wsetlocale are wide-character strings.'' The following program seems to confirm it. int main(int argc, char *argv[]) { printf("locale: %s\n", _wsetlocale(LC_ALL, (const wchar_t *) "UTF-8")); return 0; } [...] (*) A workaround Since R comes with iconv(), the following might be a safe way to translate UTF-8 into the current system locale, displaying correctly plot's titles on Windows systems. iconv("utf8-string", from="UTF-8", to=localeToCharset(Sys.getlocale("LC_CTYPE"))) (*) References [1] MSDN Unicode https://msdn.microsoft.com/en-us/library/windows/desktop/dd374081(v=vs.85).aspx [2] MSDN setlocale https://msdn.microsoft.com/en-us/library/x99tb11d.aspx [3] MSDN Locales and Code Pages https://msdn.microsoft.com/en-us/library/8w60z792.aspx __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] amending R+dependencies
Dear all,[a] after I have virtually given up on gearing up my R (v. 3.0.2; GUI: rkward; on last Linux Kubuntu LTS) for properly installing useful packages containing functions that were not delivered with base R, amendment of R through getting packages from CRAN became the only viable way to obtain functionality in R for me so far.[b] By the time I used my GUI for supplementary packages' installation, dependencies were treated by that GUI's updater and it occurred that packages were uninstallable due to packages not suitable for that very R version.[c] Now I wonder whether there were any (massive?) impending problems when one would eventually proceed to extract corresponding package archives upon download into the corresponding file folder subsequently using R, say in its interactive mode via the GUI of choice. I am referring to that kind of problem(s) which the R console (interactive mode) could throw after me, I have to be sufficiently precise...Best regards,Markus Hofstet! ter [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] as(, "numeric") vs as.numeric()
Dear Erik Wright, Re: > Could someone please explain this R behavior to me: > >> typeof(as.numeric(1:10)) > [1] "double" >> typeof(as(1:10, "numeric")) > [1] "integer" > > I expected "double" in both cases. In the help for the "as" function it says: > > "Methods are pre-defined for coercing any object to one of the basic > datatypes. For example, as(x, "numeric") uses the existing as.numeric > function." This happens because 1:10 yields only integers, and so can be stored cheap, whereas as.numeric() actually means: as.double. The "numeric" in the second line is an unused argument. Best regards, Frank --- Franklin Bretschneider Dept of Biology Utrecht University brets...@xs4all.nl __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] updating elements of a list of matrixes without 'for' cycles
> > Date: Sat, 30 Jan 2016 01:03:30 + > From: Matteo Richiardi < > > matteo.richia...@maths.ox.ac.uk> > To: r-help@r-project.org > Subject: [R] updating elements of a list of matrixes without 'for' > cycles > Message-ID: > < > cabsru1lkohuz8m9jw1ju+nemksprirrtd_0wzotrlwi3z6d...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > Hi, following an earlier suggestion from the list, I am storing my > data in a "cube", i.e. an array of matrixes. > Is there any smarter way of updating the elements of the cube through > a function, other than the three 'for' cycles in the example below? > (please note that the example is simplistic; in particular, my > function is more complicated). > > # parameters > I <- 2L > J <- 2L > H <- 2L > > # data container: an array of matrixes > mycube <- array(dim=c(I,J,H)) > > # initialisation > for (h in 1:H) { > init <- matrix(c(rep(0,J)),nrow=I,ncol=J) > mycube[,,h] <- init > } > > # function > foo = function(i,j,h){ > mycube[i,j,h] <<- i*j*h > } > > # update > > for(h in 1:H){ > # males: > for(i in 1:I) > for(j in 1:J) > foo(i,j,h) > } > > Thanks a lot for your help. Matteo > > > Greetings! Have you tried sapply() on this script? -- Jue [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] as(, "numeric") vs as.numeric()
On 01/02/2016 10:00 AM, Erik Wright wrote: Dear Frank, Thank you for the quick response. I am familiar with the tradeoffs between integers and doubles. However, I do not believe this answers my question. If you look at the help information for the as() function it says: "as(x, "numeric") uses the existing as.numeric function." But clearly the result is different in each case. Since is.numeric(1:10) and is(1:10, "numeric") are both true, the as() function eventually bails out and does nothing. So yes, as(x, "numeric") uses as.numeric() when it needs to coerce, but not when no coercion is necessary. The docs could perhaps add this condition. Duncan Murdovh If the help for as() is correct, then as(1:10, "numeric") should also return doubles, and the second argument is not ignored. Erik > On Feb 1, 2016, at 8:16 AM, Franklin Bretschneiderwrote: > > Dear Erik Wright, > > > Re: > >> Could someone please explain this R behavior to me: >> >>> typeof(as.numeric(1:10)) >> [1] "double" >>> typeof(as(1:10, "numeric")) >> [1] "integer" >> >> I expected "double" in both cases. In the help for the "as" function it says: >> >> "Methods are pre-defined for coercing any object to one of the basic datatypes. For example, as(x, "numeric") uses the existing as.numeric function." > > > This happens because 1:10 yields only integers, and so can be stored cheap, > whereas as.numeric() actually means: as.double. > The "numeric" in the second line is an unused argument. > > Best regards, > > Frank > --- > > > > > Franklin Bretschneider > Dept of Biology > Utrecht University > brets...@xs4all.nl > > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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] as(, "numeric") vs as.numeric()
Dear Frank, Thank you for the quick response. I am familiar with the tradeoffs between integers and doubles. However, I do not believe this answers my question. If you look at the help information for the as() function it says: "as(x, "numeric") uses the existing as.numeric function." But clearly the result is different in each case. If the help for as() is correct, then as(1:10, "numeric") should also return doubles, and the second argument is not ignored. Erik > On Feb 1, 2016, at 8:16 AM, Franklin Bretschneiderwrote: > > Dear Erik Wright, > > > Re: > >> Could someone please explain this R behavior to me: >> >>> typeof(as.numeric(1:10)) >> [1] "double" >>> typeof(as(1:10, "numeric")) >> [1] "integer" >> >> I expected "double" in both cases. In the help for the "as" function it >> says: >> >> "Methods are pre-defined for coercing any object to one of the basic >> datatypes. For example, as(x, "numeric") uses the existing as.numeric >> function." > > > This happens because 1:10 yields only integers, and so can be stored cheap, > whereas as.numeric() actually means: as.double. > The "numeric" in the second line is an unused argument. > > Best regards, > > Frank > --- > > > > > Franklin Bretschneider > Dept of Biology > Utrecht University > brets...@xs4all.nl > > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.