Re: [R] Book Recommendation

2023-08-28 Thread William Michels via R-help
I'm a big fan of the sqldf package by Gabor Grothendieck: "sqldf: Manipulate R Data Frames Using SQL" https://CRAN.R-project.org/package=sqldf The sqldf "README.html" converts to a 42 page PDF: https://cran.r-project.org/web/packages/sqldf/readme/README.html You can also find favorable blog post

Re: [R] Connect R with Ensemble Rest API to fetch variations

2022-01-03 Thread William Michels via R-help
Hello Anas, You can find courses and/or training materials on the Ensembl/EBI websites, including R code: https://www.ebi.ac.uk/training/online/courses/ensembl-rest-api/ http://training.ensembl.org/ You can also click on individual 'Ensembl REST API Endpoints', and find sample R code there: htt

Re: [R] how to install npsm package

2021-09-01 Thread William Michels via R-help
Hi, I found package "npsm" at the links below: https://mran.microsoft.com/snapshot/2017-02-04/web/packages/npsm/index.html https://cran.r-project.org/src/contrib/Archive/npsm/ HTH, Bill. W. Michels, Ph.D. On Wed, Sep 1, 2021 at 8:27 AM wrote: > > I need to install the package "npsm" to follo

Re: [R] How to solve this?

2021-08-31 Thread William Michels via R-help
Hello, You may have more luck posting your question to the R-SIG-Geo mailing-list: https://stat.ethz.ch/mailman/listinfo/R-SIG-Geo/ Be sure to use an appropriate "Subject" line, for example, the particular package/function that seems problematic. HTH, Bill. W. Michels, Ph.D. On Mon, Aug 30,

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread William Michels via R-help
Hi Phillips, Maybe these examples will be useful: > vec <- c("a","b","c","d","e") > vec[c(1,1,1,0,0)] [1] "a" "a" "a" > vec[c(1,1,1,2,2)] [1] "a" "a" "a" "b" "b" > vec[c(5,5,5,5,5)] [1] "e" "e" "e" "e" "e" > vec[c(NA,NA,NA,0,0,0,0)] [1] NA NA NA > vec[c(NA,NA,NA,1,1,1,1)] [1] NA NA NA "a" "a"

Re: [R] Need to compare two columns in two data.frames and return all rows from df where rows values are missing

2021-06-13 Thread William Michels via R-help
Maybe something like this? > df_A <- data.frame(names=LETTERS[1:10], values_A=1:10) > df_B <- data.frame(names=LETTERS[6:15], values_B=11:20) > df_AB <- merge(df_A, df_B, by="names") > df_AAB <- merge(df_A, df_AB, all.x=TRUE) > df_BAB <- merge(df_B, df_AB, all.x=TRUE) > df_C <- df_AAB[is.na(df_AAB

Re: [R] Beginner problem - using mod function to print odd numbers

2021-06-06 Thread William Michels via R-help
try to work within the paradigms that are the > language's strengths when possible, R's vectorization and indexing in this > example. > > Cheers, > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things

Re: [R] Beginner problem - using mod function to print odd numbers

2021-06-05 Thread William Michels via R-help
> i <- 1L; span <- 1:100; result <- NA; > for (i in span){ + ifelse(i %% 2 != 0, result[i] <- TRUE, result[i] <- FALSE) + } > span[result] [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 [30] 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99

Re: [R] series of densities

2021-05-17 Thread William Michels via R-help
Hi Troels, Have you considered using Lattice graphics? Adapting from examples on the help page: > ?histogram() > histogram( ~ BC | pH, data = ddd, type = "density", xlab = "BC", layout = c(1, 3), aspect = 0.618, strip = strip.custom(strip.levels=c(TRUE,TRUE)), panel = function(x, ...) {

Re: [R] Stata/Rstudio evil attributes

2021-04-10 Thread William Michels via R-help
Hi Roger, You could look at the attributes() function in base-R. See: > ?attributes >From the help-page: > ## strip an object's attributes: > attributes(x) <- NULL HTH, Bill. W. Michels, Ph.D. On Sat, Apr 10, 2021 at 4:20 AM Koenker, Roger W wrote: > > Wolfgang, > > Thanks, this is _extre

Re: [R] Calculating column differences

2021-03-24 Thread William Michels via R-help
64 5 4204 6 5244 > HTH, Bill. On Wed, Mar 24, 2021 at 10:59 AM William Michels wrote: > > Dear Jeff, > > Rather than diff-ing a linear vector you're trying to diff values from > two different rows. Also you indicate that you want to place the > diff-ed

Re: [R] Calculating column differences

2021-03-24 Thread William Michels via R-help
Dear Jeff, Rather than diff-ing a linear vector you're trying to diff values from two different rows. Also you indicate that you want to place the diff-ed value in the 'lower' row of a new column. Try this (note insertion of an initial "zero" row): > df <- data.frame(ID=1:5,Score=4*2:6) > df1 <-

Re: [R] Installing Perl For Use in R

2020-10-08 Thread William Michels via R-help
Hi Philip, "Perl Download" https://www.perl.org/get.html The above link gives you the option to install from source or from ActiveState. The first link below (source) proudly proclaims, "Perl compiles on over 100 platforms..." and the second link below (binary) similarly proclaims, "Perl supports

Re: [R] Lahman Baseball Data Using R DBI Package

2020-10-07 Thread William Michels via R-help
Hi Philip, You've probably realized by now that R doesn't like column names that start with a number. If you try to access an R-dataframe column named 2B or 3B with the familiar "$" notation, you'll get an error: > library(DBI) > library(RSQLite) > con2 <- dbConnect(SQLite(), "~/R_Dir/lahmansbase

Re: [R] Unnesting JSON using R

2020-09-17 Thread William Michels via R-help
Hi Fred, I believe the preferred package is jsonlite: https://cran.r-project.org/package=jsonlite https://jeroen.cran.dev/jsonlite/index.html HTH, Bill. W. Michels, Ph.D. On Tue, Sep 15, 2020 at 1:48 PM Fred Kwebiha wrote: > > Source=https://jsonformatter.org/e038ec > > The above is nested jso

Re: [R] PROBLEM: quickly downloading 10,000 articles to sift through

2020-08-30 Thread William Michels via R-help
Hello John, Does this help? https://cran.r-project.org/web/packages/bibliometrix/vignettes/bibliometrix-vignette.html https://bibliometrix.org/ Best, Bill. W. Michels, Ph.D. On Fri, Aug 28, 2020 at 11:04 PM Fraedrich, John wrote: > > > > To analyze 10,000+ articles within several journals to

Re: [R] [External] Re: help with web scraping

2020-07-25 Thread William Michels via R-help
Dear Spencer Graves (and Rasmus Liland), I've had some luck just using gsub() to alter the offending "" characters, appending a "___" tag at each instance of "" (first I checked the text to make sure it didn't contain any pre-existing instances of "___"). See the output snippet below: > library(R

Re: [R] help with web scraping

2020-07-23 Thread William Michels via R-help
Hi Spencer, I tried the code below on an older R-installation, and it works fine. Not a full solution, but it's a start: > library(RCurl) Loading required package: bitops > url <- > "https://s1.sos.mo.gov/CandidatesOnWeb/DisplayCandidatesPlacement.aspx?ElectionCode=750004975"; > M_sos <- getURL(

Re: [R] Help with read.csv.sql()

2020-07-18 Thread William Michels via R-help
Do either of the postings/threads below help? https://r.789695.n4.nabble.com/read-csv-sql-to-select-from-a-large-csv-file-td4650565.html#a4651534 https://r.789695.n4.nabble.com/using-sqldf-s-read-csv-sql-to-read-a-file-with-quot-NA-quot-for-missing-td4642327.html Otherwise you can try reading thr

Re: [R] Character (1a, 1b) to numeric

2020-07-11 Thread William Michels via R-help
st wishes, JL > > On Sat, Jul 11, 2020, at 8:25 AM, William Michels wrote: > > Hello Jean-Louis, > > > > Noting the subject line of your post I thought the first answer would > > have been encoding histology stages as factors, and "unclass-ing" them > > to

Re: [R] Character (1a, 1b) to numeric

2020-07-10 Thread William Michels via R-help
Hello Jean-Louis, Noting the subject line of your post I thought the first answer would have been encoding histology stages as factors, and "unclass-ing" them to obtain integers that then can be mathematically manipulated. You can get a lot of work done with all the commands listed on the "factor"

Re: [R] R Compied for Mac OS X

2020-06-25 Thread William Michels via R-help
Hi, you can try starting at the link below: https://stat.ethz.ch/R-manual/R-patched/doc/html/packages.html Or type any of following commands into your R-Console (for starters): > library() > library(help="base") > library(help="stats") > library(help="graphics") > library(help="grDevices") > lib

Re: [R] how to filter variables which appear in any row but do not include

2020-06-03 Thread William Michels via R-help
#Below returns long list of TRUE/FALSE values, #Note: "IDs" is a column name, #Wrap with head() to shorten: df$IDs %in% c("ident_1", "ident_2"); #Below returns index of IDs that are TRUE, #Wrap with head() to shorten: which(df$IDs %in% c("ident_1", "ident_2")); #Below returns short TRUE/FALSE tab

Re: [R] iterators : checkFunc with ireadLines

2020-05-27 Thread William Michels via R-help
( / ^^N053 | ^^N163 /, :p );' > Laurents.txt works fine when I write it in the bash command but when I > use the pipe command in R as you say there is nothing in lines with > lines <- read.table(i) > > There is the same problem with Ivan's solution the command grep -E >

Re: [R] iterators : checkFunc with ireadLines

2020-05-24 Thread William Michels via R-help
Strike that one sentence in brackets: "[In point of fact, the R Data Import/Export Manual suggests using perl]", to pre-process data before loading into R. The manual's recommendation only pertains to large fixed width formatted files [see #1], whereas Laurent's data is whitespace-delimited: > rea

Re: [R] iterators : checkFunc with ireadLines

2020-05-23 Thread William Michels via R-help
Hi Laurent, Seeking to give you an "R-only" solution, I thought the read.fwf() function might be useful (to read-in your first column of data, only). However Jeff is correct that this is a poor strategy, since read.fwf() reads the entire file into R (documented in "Fixed-width-format files", Secti

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread William Michels via R-help
Dear Laurent, I'm going through your code quickly, and the first question I have is whether you loaded the "gmp" library? > library(gmp) Attaching package: ‘gmp’ The following objects are masked from ‘package:base’: %*%, apply, crossprod, matrix, tcrossprod > library(iterators) > iter(1

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread William Michels via R-help
Apologies, Laurent, for this two-part answer. I misunderstood your post where you stated you wanted to "filter(ing) some selected lines according to the line name... ." I thought that meant you had a separate index (like a series of primes) that you wanted to use to only read-in selected line num

Re: [R] iterators : checkFunc with ireadLines

2020-05-18 Thread William Michels via R-help
eted the first "hash" character from each line of your test file for clarity). HTH, Bill. W. Michels, Ph.D. On Mon, May 18, 2020 at 3:35 AM Laurent Rhelp wrote: > > Dear William, > Thank you for your answer > My file is very large so I cannot read it in my memory

Re: [R] Subtracting Data Frame With a Different Number of Rows

2020-04-21 Thread William Michels via R-help
Hi Phillip, You have two choices here: 1. Manually enter the missing rows into your individual.df using rbind(), and cbind() the overall.df and individual.df dataframes together (assuming the rows line up properly), or 2. Use merge() to perform an SQL-like "Left Join", and copy values from the "ov

Re: [R] ncol() vs. length() on data.frames

2020-03-31 Thread William Michels via R-help
Hi Ivan, Like Ivan Krylov, I'm not aware of circumstances for simple dataframes where ncol(DF) does not equal length(DF). As I understand it, using ncol() versus length() is important when you're examining an object returned from a function like sapply(), since sapply() will simplify one-column d

Re: [R] Tidyverse Question

2020-03-27 Thread William Michels via R-help
Dear Ista (and Phillip), Ista, that's the exact same advice I gave Phillip over a week ago: https://stat.ethz.ch/pipermail/r-help/2020-March/465994.html Phillip, it doesn't make sense to post the same question under different subject headings. While I'm convinced you're making a sincere effort t

Re: [R] Analyzing Baseball Data With R

2020-03-16 Thread William Michels via R-help
Hi Phillip, Generally these problems come down to knowing/setting your working directory. The first question is whether you have a directory named "data" inside your "C:/Users/Owner/Documents" directory? You may need to create this directory first, outside of R and/or RStudio (using your Windows O

Re: [R] File names for mac newby

2020-01-21 Thread William Michels via R-help
Hi David, Often on a Mac you can "right click" (or on a laptop--press down with two fingers), and a pop-up will give you the option to "Copy File Path". (You can also find this option in a Finder window under the "Finder -> Services" menu bar) .This is the path you should use to import your file i

Re: [R] Data Carpentry - Creating a New SQLite Database

2020-01-10 Thread William Michels via R-help
Hi Phillip, Skipping to the last few lines of your email, did you download a program to look at Sqlite databases (independent of R) as listed below? Maybe that program ("DB Browser for SQLite") and/or the instructions below can help you locate your database directory: https://datacarpentry.org/se

Re: [R] rnoaa library

2019-12-30 Thread William Michels via R-help
Hi Jeff, You might have better luck posting your question on the R-SIG-Geo mailing list, or perusing their archive. I've found a thread pertaining to the rnoaa package from August 2016, along with a particularly informative reply (reply link below): https://stat.ethz.ch/mailman/listinfo/R-SIG-Geo

Re: [R] Converting Decimal numbers into Binary

2019-12-27 Thread William Michels via R-help
Hi Paul, Since you start from strings, it's not clear to me where ASCII enters the picture. If you really need ASCII, you can use the charToInt() function in the "R.oo" package. Also there's the AsciiToInt() function in the "sfsmisc" package. If you just want to use R's native as.numeric() conver

Re: [R] package MCMCpack

2019-12-04 Thread William Michels via R-help
x27; > In R CMD INSTALL > Warning in install.packages : > installation of package > 'C:/Users/prophetw/AppData/Local/Temp/RtmpykZoRh/downloaded_packages/MCMCpack_1.4-3.tar.gz' > had non-zero exit status > > > > > > -Original Message- > From: William

Re: [R] package MCMCpack

2019-12-04 Thread William Michels via R-help
Hi William, It's not clear to me why you need this particular older version of MCMCpack. From the archive I find MCMCpack_1.2-4 dates back to 2012-06-14, and MCMCpack_1.2-4.1 dates back to 2013-04-07: MCMCpack_1.2-4.1.tar.gz 2013-04-07 00:05 481K MCMCpack_1.2-4.tar.gz 2012-06-14 12:36 482K Have

Re: [R] How to use preProcess in Caret?

2019-12-04 Thread William Michels via R-help
Hello, Have you tried alternative methods of pre-processing your data, such as simply calling scale()? What is the effect on convergence, for both the caret package and and the neuralnet package? There's an example using scale() with the neuralnet package at the link below: https://datascienceplu

Re: [R] Conditions

2019-11-26 Thread William Michels via R-help
Hi Val, Here's an answer using a series of ifelse() statements. Because the d4 column is created initially using NA as a placeholder, you can check your conditional logic at the end using table(!is.na(dat2$d4)): > dat2 <-read.table(text="ID d1 d2 d3 + A 0 25 35 + B 12 22 0 + C 0 0 31 + E 10 2

Re: [R] If Loop I Think

2019-10-27 Thread William Michels via R-help
lambj001goldp001 0 1 1 11 111 lambj001goldp001 0 1 1 12 122 lambj001 0 0 1 13 13 0 0 0 0 14 141 0 0 0 > HTH, Bill. W. Michels, Ph.D. On Thu, Oct 24, 2019 at 12:44

Re: [R] If Loop I Think

2019-10-24 Thread William Michels via R-help
Hi Phillip, Jim and David and Petr all wrote you good code, but you have major problems in data formatting. Your data uses spaces both as a column separator and also to denote "blank fields". Because of problems with your input data structure, it's doubtful whether the good code you've received wi

Re: [R] Change colour ggiNEXT plot package iNEXT

2019-10-23 Thread William Michels via R-help
Apparently, the iNEXT package was first described in an academic paper published in 2016, although CRAN archives go back to 2015. http://chao.stat.nthu.edu.tw/wordpress/paper/120_pdf_appendix.pdf https://cran.r-project.org/src/contrib/Archive/iNEXT/ The vignette below has a section entitled "Gener

Re: [R] can not extract rows which match a string

2019-10-04 Thread William Michels via R-help
Apologies Ana, Of course Rui and Herve (and Richard) are correct here in stating that NA values get 'carried through' when selecting using the "==" operator. To give an illustration of what (I believe) Herve means by "NAs propagating", here's a small 11 x 8 dataframe ("zakaria") posted to R-Help l

Re: [R] can not extract rows which match a string

2019-10-03 Thread William Michels via R-help
Hello, I expected the code you posted to work just as you presumed it would, but without a reproducible example--I can only speculate as to why it didn't. In the t1 dataframe, if indeed you only want to remove rows of the t1$sex_chromosome_aneuploidy_f22019_0_0 column which are undefined, you cou

Re: [R] The "--slave" option ==> will become "--no-echo"

2019-09-27 Thread William Michels via R-help
Apologies, Duncan and Martin. I didn't check "R --help" first. You're quite right, lots of embedded hyphens. Best Regards, Bill. W. Michels, Ph.D. On Fri, Sep 27, 2019 at 2:42 PM Duncan Murdoch wrote: > > On 27/09/2019 5:36 p.m., William Michels via R-help wrote: &g

Re: [R] The "--slave" option ==> will become "--no-echo"

2019-09-27 Thread William Michels via R-help
Hi Martin, '--no-echo' or '--no_echo' Obviously you may prefer the first, but I hope you might consider the second. Best Regards, W. Michels, Ph.D. On Fri, Sep 27, 2019 at 9:04 AM Martin Maechler wrote: > > > Martin Maechler > > on Mon, 23 Sep 2019 16:14:36 +0200 writes

Re: [R] static vs. lexical scope

2019-09-26 Thread William Michels via R-help
The best summary I've read on the subject of R's scoping rules (in particular how they compare to scoping rules in S-PLUS) is Dr. John Fox's "Frames, Environments, and Scope in R and S-PLUS", written as an Appendix to the first edition of his book, An R and S-PLUS Companion to Applied Regression (2

[R] Fwd: new_index

2019-09-07 Thread William Michels via R-help
Hi Val, see below: > dat1 <-read.table(text="ID, x, y, z + A, 10, 34, 12 + B, 25, 42, 18 + C, 14, 20, 8 ",sep=",",header=TRUE,stringsAsFactors=F) > > dat2 <-read.table(text="ID, weight + A, 0.25 + B, 0.42 + C, 0.65 ",sep=",",header=TRUE,stringsAsFactors=F) > > dat3 <- data.frame(ID = dat1[,

Re: [R] Help with R coding

2019-05-22 Thread William Michels via R-help
Morning Bill, I take it this is dplyr? You might try: tmp1 <- HCPC %>% group_by(HCPCSCode) %>% summarise(Avg_AllowByLimit = mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0 & AllowByLimitFlag == TRUE)])) The code above gives "NaN" for cases where AllowByLimitFlag == FALSE. Maybe this is the answer

Re: [R] Trying to understand the magic of lm

2019-05-09 Thread William Michels via R-help
Hello John, Others have commented on the first half of your question, but the second half of your question looks very much like R's built-in predict() functions: >?predict >?predict.lm Best Regards, Bill. W. Michels, Ph.D. On Wed, May 8, 2019 at 6:23 PM Sorkin, John wrote: > > Can someone

Re: [R] Creating a mean line plot

2019-04-14 Thread William Michels via R-help
So you're saying rowMeans(cbind(matrix_a, matrix_b)) worked to obtain your X-axis values? Wild guess here, are you simply looking for: colMeans(rbind(matrix_a, matrix_b)) to obtain your Y-axis values? [Above assuming matrix_a and matrix_b have identical dimensions (nrow, ncol)]. --Bill Wi

Re: [R] loading the xlsx library

2019-01-14 Thread William Michels via R-help
Hello Bernard, You might consider using the "readxl" package, which (from the package description), "Works on Windows, Mac and Linux without external dependencies." https://CRAN.R-project.org/package=readxl HTH, Bill. William Michels, Ph.D.

Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread William Michels via R-help
; 0] TTT TTA gene1 0 0 gene2 1 1 gene3 0 1 gene4 0 0 > Best Regards, Bill. William Michels, Ph.D. On Thu, Nov 1, 2018 at 9:07 PM, Bogdan Tanasa wrote: > Dear Bill, and Bill, > > many thanks for taking the time to advice, and for your suggestions. I > beli

Re: [R] selecting the COLUMNS in a dataframe function of the numerical values in a ROW

2018-11-01 Thread William Michels via R-help
ot;gene3", "gene4")) > > ygene[ , colSums(ygene[,1:3]) > 0 ] TTT TTA gene 1 0 0 gene1 2 1 1 gene2 3 0 1 gene3 4 0 0 gene4 HTH, Bill. William Michels, Ph.D. On Thu, Nov 1, 2018 at 5:45 PM, Bogdan Tanasa wrote: > Dear all, please may I ask fo

Re: [R] Suggestions for scatter plot of many data

2018-07-19 Thread William Michels via R-help
Hello, In addition to Duncan Mackay's excellent suggestion, I would recommend Bert Gunter's "stripless" package, for high-density Trellis-type conditioning plots. See the vignette for examples, and try out the code for "earthquake" and "barley" plots from the reference manual. https://CRAN.R-proje

Re: [R] R examples in Agronomy

2018-06-13 Thread William Michels via R-help
. https://CRAN.R-project.org/package=agridat https://cran.r-project.org/web/packages/agridat/vignettes/agridat_examples.pdf HTH, Bill. William Michels, Ph.D. On Wed, Jun 13, 2018 at 5:56 AM, Khaled Ibrahimi wrote: > Dear all, > Are there good R stat examples in the fie

Re: [R] drc, ggplot2, and gridExtra

2018-05-22 Thread William Michels via R-help
Hi, I was able to get Eivind's code to work by slight modification of the "grab" function: grab <- function() { grid.echo() grid.grab() } Best Regards, W. Michels, Ph.D. On Fri, May 18, 2018 at 9:56 AM, Eivind K. Dovik wrote: > On Fri, 18 May 2018, Ed Siefker wrote: > >> I have dose r

Re: [R] Add vectors of unequal length without recycling?

2017-12-13 Thread William Michels via R-help
Maingo, See previous discussion below on rbind.na() and cbind.na() scripts: https://stat.ethz.ch/pipermail/r-help/2016-December/443790.html You might consider binding first then adding orthogonally. So rbind.na() then colSums(), OR cbind.na() then rowSums(). Best of luck, W Michels, Ph.D. O

Re: [R] Pass Parameters to RScript?

2017-10-31 Thread William Michels via R-help
Hello Morcus, Is your question really about language inter-operability? If so, have you checked out rJava? "rJava: Low-Level R to Java Interface" https://CRAN.R-project.org/package=rJava http://www.rforge.net/rJava/ Regards, Bill. W. Michels, Ph.D. On Mon, Oct 30, 2017 at 8:10 AM, Morkus vi

Re: [R] write.dna command

2017-06-19 Thread William Michels via R-help
Hi Mogjib, Does the following solve your issue? > setwd(WD) On Sat, Jun 17, 2017 at 7:26 AM, Mogjib Salek wrote: > Hi all, > > I am learning R by "doing". And this is my first post. > > I want to use R: 1- to fetch a DNA sequence from a databank (see bellow) > and 2- store it as FASTA file.

Re: [R] write.dna command

2017-06-17 Thread William Michels via R-help
We'll need more information on the packages you're using. Can you post the output of: > sessionInfo() Finally, is this a Bioconductor question? They have their own support site: https://support.bioconductor.org HTH, William Michels, Ph.D. On Sat, Jun 17, 2017 at 11:05 AM, J

Re: [R] About change columns and specific rows in R

2017-05-23 Thread William Michels via R-help
ou have to > specify the data.frame you want to look into. > > And last, learn to use dput() to provide a nice reproducible example. > > HTH, > Ivan > > > -- > Dr. Ivan Calandra > TraCEr, Laboratory for Traceology and Controlled Experiments > MONREPOS Archaeolog

Re: [R] About change columns and specific rows in R

2017-05-22 Thread William Michels via R-help
n the right hand side of the assignment operator to get the index of the rows you want. Example below for "product1": > DF$product1_1 <- NA > DF[DF$month == 1, "product1_1"] <- DF[which(DF$month == 1), "product1"]*3.1 > HTH, Bill. William Michels,

Re: [R] [FORGED] Logical Operators' inconsistent Behavior

2017-05-22 Thread William Michels via R-help
---++ | NULL OR NULL | FALSE OR NULL | FALSE OR FALSE | +--+---++ | NULL | NULL | 0 | +--+-------+----+ 1 row in set (0.00 sec) mysql> HTH, Bill William Michels, Ph.D. On Sun, May 21, 2017 at 7:00 AM, Hadl

Re: [R] [FORGED] Logical Operators' inconsistent Behavior

2017-05-21 Thread William Michels via R-help
t;- c("False", "na", "True") > colnames(ttOR) <- c("False", "na", "True") > ttOR False na True False FALSE NA TRUE na NA NA TRUE True TRUE TRUE TRUE > > The bottom section of the same Wikipedia page (secti

Re: [R] About calculating average values from several matrices

2017-05-09 Thread William Michels via R-help
Dear Lily, Harold is telling you to type "?round" at the R command prompt to pull up the "round" help page. >?round >help("round") AFAIK, the above two commands are equivalent, in general. Best, Bill. W. Michels, Ph.D. On Tue, May 9, 2017 at 8:11 AM, Doran, Harold wrote: > ?round > > > Fro

Re: [R] install lapack for mac

2017-05-02 Thread William Michels via R-help
Have you tried R-GUI, in the R-distribution available below? https://cran.r-project.org/bin/macosx/ Here's a similar question on SO: http://stackoverflow.com/questions/13476736/r-lapack-routines-cannot-be-loaded HTH, Bill. William Michels, Ph.D. On Tue, May 2, 2017 at 11:51 AM,

Re: [R] Creating interactive graphs and exporting to Intranet site

2017-04-23 Thread William Michels via R-help
PU JavaScript client library. HTH, Bill William Michels, Ph.D. On Sun, Apr 23, 2017 at 2:26 PM, Sarah Goslee wrote: > HI Chris, > > You can use the R plotly library on your own computer to create the > interactive graph, then upload the code to the server. > > I have a setup like

Re: [R] Too strange that I cannot install several packages

2017-04-10 Thread William Michels via R-help
For a base-R installation, you can print out multiple help pages (function indices) like so: > for(i in 1:length(sessionInfo()$basePkgs)) { print(library(help = sessionInfo()$basePkgs[i], character.only = TRUE)) } HTH, Bill. William Michels, Ph.D. On Mon, Apr 10, 2017 at 11:15 AM, Do

Re: [R] Is there a way to get R script line number

2017-04-07 Thread William Michels via R-help
Hi Brad, Some of the debugging functions may be of use. You can look at trace() or setBreakpoint(). But I believe Bert is correct in saying your concept of a "Line Number" and R's concept of a "Line Number" will differ. Finally, you can look at the function findLineNum(), which can be called exte

Re: [R] problems in vectors of dates_times

2017-04-07 Thread William Michels via R-help
I believe the lubridate package does a good job with time zones. > install.packages("lubridate") > library(lubridate) Look at the supplied functions with_tz() and force_tz(). HTH, Bill. William J. Michels, Ph.D. On Fri, Apr 7, 2017 at 12:52 AM, Jeff Newmiller wrote: > R does a poor job

Re: [R] Taking the sum of only some columns of a data frame

2017-03-31 Thread William Michels via R-help
e to chime in. Finally, thank you Bert for your most informative post on adding attributes to dataframes. I really learned a lot! Best Regards, Bill. William Michels, Ph.D. On Fri, Mar 31, 2017 at 4:59 PM, Bert Gunter wrote: > All: > > 1. I agree wholeheartedly with prior response

Re: [R] Taking the sum of only some columns of a data frame

2017-03-31 Thread William Michels via R-help
ME.html Finally, please review the Introductory PDF, available here: https://cran.r-project.org/doc/manuals/R-intro.pdf HTH, Bill. William Michels, Ph.D. On Fri, Mar 31, 2017 at 11:21 AM, BR_email wrote: > William: > How can I replace the "NAs" with blanks? > Bruce &

Re: [R] Taking the sum of only some columns of a data frame

2017-03-31 Thread William Michels via R-help
I'm sure there are more efficient ways, but this works: > test1 <- matrix(runif(50), nrow=10, ncol=5) > ## test1 <- as.data.frame(test1) > test1 <- rbind(test1, NA) > test1[11, c(1,3)] <- colSums(test1[1:10,c(1,3)]) > test1 HTH, Bill. William Michels, Ph.D.

Re: [R] How to select one value per row (different columns) from array

2017-03-01 Thread William Michels via R-help
Hello Wolfgang, Building on Peter Dalgaard's code, are you just trying to take a sample of a random column from each row? You don't need to use apply: > array[cbind(1:nrow(array), sample.int(ncol(array), nrow(array), replace=TRUE ))] Just a general note, since you're sampling one-column-per-row

Re: [R] [FORGED] function for remove white space

2017-02-21 Thread William Michels via R-help
Hi José (and Rolf), It's not entirely clear what type of 'whitespace' you're referring to, but if you're using read.table() or read.csv() to create your dataframe in the first place, setting 'strip.white = TRUE' will remove leading and trailing whitespace 'from unquoted character fields (numeric f

Re: [R] \n and italic() in legend()

2016-12-29 Thread William Michels via R-help
smaller script plot(1, 1) v1 <- expression(scriptscriptstyle(bold(italic("p")*"-value based on "*italic("t")*"-test"))) v2 <- expression(scriptscriptstyle(bold(italic("w")*"-value for A and B identical models"))) legend("topright&quo

Re: [R] Export R output in Excel

2016-12-29 Thread William Michels via R-help
LSE, fileEncoding = > "UTF-8" ) > close(clip) > gc() > ?write.table > ?connections Adding an extra call to gc() (garbage collection) after writing to clipboard will close all unused connections (useful if a connection has been entered incorrectly). HTH, Bill William Mi

Re: [R] \n and italic() in legend()

2016-12-29 Thread William Michels via R-help
Hi Marc, I can't seem to get "\n" to work, but simply using c() and "y.intersp = 1" looks fine: > plot(1, 1) > v1 <- c(expression(italic("p")*"-value"), expression("based on > "*italic("t")*"-test")) >

Re: [R] creating possible cominations of a vector's elements

2016-12-22 Thread William Michels via R-help
are you today" [[4]] [1] "how are you today" > It was unclear if you wanted combinations (per your subject line), or consecutive-word substrings (per your example). The code above returns combinations. If you actually want a third output--permutations--you'll have to l

Re: [R] Merging two columns of unequal length

2016-12-13 Thread William Michels via R-help
You should review "The Recycling Rule in R" before attempting to perform functions on 2 or more vectors of unequal lengths: https://cran.r-project.org/doc/manuals/R-intro.html#The-recycling-rule Most often, the "Recycling Rule" does exactly what the researcher intends (automatically). And in many

Re: [R] pairs: adjusting margins and labeling axes

2016-07-20 Thread William Michels via R-help
Hi Michael, is this the direction you'd like to go (simplified)? ?pairs pairs(iris, log="xy", asp=1, gap=0.1) --Bill. On Tue, Jul 19, 2016 at 2:37 PM, Michael Young wrote: > I want to make this as easy as possible. The extra space could just go > around the plot in the margin area. I could

Re: [R] Issue replacing dataset values from read data

2016-05-07 Thread William Michels via R-help
1. It's not immediately clear why you need the line "temp <- subset(df, id == myid)" 2. The objects described by "temp$age", temp$agesmoke, and temp$yrsquit are all vectors. So temp.yrssmoke is also a vector. This means that when you replace, it should be with "<- temp.yrssmoke[i]", where "i" is t

Re: [R] Documentation: Was -- identical() versus sapply()

2016-04-12 Thread William Michels via R-help
copying to the Console? We'd get a lot more people working through examples that way, and contributors might come up with their own examples to illustrate a particular function. A Dokuwiki site might be a place where people could post and vote on new examples to be included in pre-existing doc

Re: [R] R editor for Mac

2016-01-21 Thread William Michels via R-help
Run Atom with the language-r and r-exec packages: "A language description and snippets for R" https://atom.io/packages/language-r "Send R code to various consoles" https://atom.io/packages/r-exec On Thu, Jan 21, 2016 at 9:54 AM, boB Rudis wrote: > Here you go Ista: https://atom.io/packages/rep

Re: [R] R editor for Mac

2016-01-20 Thread William Michels via R-help
Hello Christofer! For text-editing the R.app GUI has always been fabulous. An old mainstay on the Mac (after Apple's TextEdit) has been TextWrangler, and its big-brother, BBEdit. For development RStudio is quite nice, and--based partly on RStudio's offering of a Vim-compatibility mode--Vim has bec

Re: [R] Split Strings

2016-01-17 Thread William Michels via R-help
ength<-", max.length) > str_3 See: http://stackoverflow.com/questions/27995639/i-have-a-numeric-list-where-id-like-to-add-0-or-na-to-extend-the-length-of-the Hope this helps, Bill William Michels, Ph.D. On Sun, Jan 17, 2016 at 12:56 PM, Miluji Sb wrote: > I

Re: [R] Problem merging data frames and duplicates

2015-05-27 Thread William Michels
abetical order, but row numbers are not sequential. Best, Bill William Michels, Ph.D. On Wed, May 27, 2015 at 6:42 AM, Frank Burbrink wrote: > Interesting solutions. Thanks guys! > > On Wed, May 27, 2015 at 9:27 AM, William Michels > wrote: __

Re: [R] Problem merging data frames and duplicates

2015-05-27 Thread William Michels
ot;, "locus") > by.state1(a,b) state locus state locus 1 AR 5 AR 2 2 AR 6AR 3 3 IL 1IL 1 4 IL 1IL 1 5 LA 2 NA 6 LA 2 NA 7 MS 3 NA 8 MS 4 NA 9 NATN 3

Re: [R] Problem merging data frames and duplicates

2015-05-27 Thread William Michels
Hi Frank, It looks like you're very close. I think you want: unique(merge(x, y, by = 1, all=T)) Gabor Grothendieck's sqldf package is very useful if you're more comfortable with SQL-type syntax, see: https://github.com/ggrothendieck/sqldf Best Regards, William (Bill) Michels, Ph.D. On Tue,