Re: [R] [EXTERNAL] Attribute Combinations

2020-05-21 Thread Dalthorp, Daniel via R-help
# assuming your data frame is named "x", you can get the counts of each combo: table(do.call(paste0, x)) # and to get the proportions: table(do.call(paste0, x))/nrow(x) -Original Message- From: R-help On Behalf Of Jeff Reichman Sent: Thursday, May 21, 2020 10:22 AM To: R-help@r-proje

Re: [R] [EXTERNAL] Re: "chi-square" | "chi-squared" | "chi squared" | "chi square" ?

2019-10-21 Thread Dalthorp, Daniel via R-help
igma^2 or x^2 or r^2. On Mon, Oct 21, 2019 at 9:46 AM Ivan Krylov wrote: > On Fri, 18 Oct 2019 15:25:59 -0700 > "Dalthorp, Daniel via R-help" wrote: > > > I'd like to see the statistics on it before jumping to a conclusion > > that the American preference is

Re: [R] [EXTERNAL] Re: "chi-square" | "chi-squared" | "chi squared" | "chi square" ?

2019-10-18 Thread Dalthorp, Daniel via R-help
oh my... I'd like to see the statistics on it before jumping to a conclusion that the American preference is "chi-square" and the British preference is "chi-squared". I don't see that at all. -- In keeping with the pronunciation of x^2 and 3^2, maybe "chi-squared" makes the most sense,. The

[R] cannot install gsl from source?

2019-06-18 Thread Dalthorp, Daniel via R-help
I've been working on a fairly extensive R package for a few years with ongoing testing with Travis CI. Today, though, I'm seeing an error in installing the gsl package both at Travis and from the Windows GUI: install.packages("gsl",repos = getOption("repos"), repo=NULL, type="source") # gives the

Re: [R] [EXTERNAL] Re: create

2019-04-13 Thread Dalthorp, Daniel via R-help
how about one of the following? vdat$xy <- 2 * (ifelse(is.na(vdat$x1), 0, vdat$x1)) + 5 * (ifelse(is.na(vdat$x2), 0, vdat$x2)) + 3 * (ifelse(is.na(vdat$x3), 0, vdat$x3)) vdat$xy <- ifelse(is.na(as.matrix(vdat[, paste0("x", 1:3)])), 0, as.matrix(vdat[, paste0("x", 1:3)])) %*% c(2, 5, 3) On Sat, A

Re: [R] Getting Started

2017-01-10 Thread Dalthorp, Daniel
By "contribute", do you mean you have a package (or potential package) that you'd like to share? Or do you have something else in mind? -Dan On Tue, Jan 10, 2017 at 9:33 AM, Lakshya Agrawal wrote: > Hello, > I would like to contribute to R i have gone over the development page but > could find

Re: [R] transpose rows and columns for large data

2016-11-29 Thread Dalthorp, Daniel
Try David's suggestion to spell the argument "stringsAsFactors" correctly. Then: data <- read.table("your_file_location", sep ="\t", comment.char = "", stringsAsFactors = F, header = T) transpose_data <- t(data) -Dan On Tue, Nov 29, 2016 at 9:56 AM, Elham - via R-help wrote: > yes you have rig

Re: [R] tcltk table "validateCommand"

2016-11-17 Thread Dalthorp, Daniel
function. > > > > As far as I remember, this only works at entry completion, though. That > does sort of make sense since not every prefix of a valid entry is valid > ("1e-2" is a double, "1e-" is not). If you want to actually disable certain > keys durin

Re: [R] Average every 4 columns

2016-11-09 Thread Dalthorp, Daniel
> > On Wed, Nov 9, 2016 at 5:45 PM, Dalthorp, Daniel > wrote: > >> Hi Milu, >> The following should work for an array x (provided dim(x)[2] is divisible >> by 4): >> >> colMeans(x[,0:(dim(x)[2]/4-1)*4+1]) >> >> -Dan >> >> On Wed, Nov

Re: [R] Average every 4 columns

2016-11-09 Thread Dalthorp, Daniel
, Nov 9, 2016 at 5:45 PM, Dalthorp, Daniel > wrote: > >> Hi Milu, >> The following should work for an array x (provided dim(x)[2] is divisible >> by 4): >> >> colMeans(x[,0:(dim(x)[2]/4-1)*4+1]) >> >> -Dan >> >> On Wed, Nov 9, 2016 at 8

Re: [R] Average every 4 columns

2016-11-09 Thread Dalthorp, Daniel
Hi Milu, The following should work for an array x (provided dim(x)[2] is divisible by 4): colMeans(x[,0:(dim(x)[2]/4-1)*4+1]) -Dan On Wed, Nov 9, 2016 at 8:29 AM, Miluji Sb wrote: > Dear all, > > I have a dataset with hundreds of columns, I am only providing only 12 > columns. Is it possible t

Re: [R] (no subject)

2016-10-06 Thread Dalthorp, Daniel
t; Jim > > On Fri, Oct 7, 2016 at 9:48 AM, Dalthorp, Daniel > wrote: > > Question and answer: > > > > 6*9 = (4)*13^1 + (2)*13^0 > > > > On Thu, Oct 6, 2016 at 3:26 PM, Jim Lemon wrote: > >> > >> It certainly does. As we are often confronted with

Re: [R] (no subject)

2016-10-06 Thread Dalthorp, Daniel
Question and answer: 6*9 = (4)*13^1 + (2)*13^0 On Thu, Oct 6, 2016 at 3:26 PM, Jim Lemon wrote: > It certainly does. As we are often confronted with requests for > solutions of problems so minimally defined as to challenge the most > eminent mindreader, this excels. We have a meta-problem as th

Re: [R] Rotating points, preferably in grid

2016-08-24 Thread Dalthorp, Daniel
Silly? Not really. It's simple. It works. You could jump into unicode for your text and make it look nicer, e.g., using '\u2191' or some other shape in place of 'T' http://unicode.org/charts/ http://unicode.org/charts/PDF/U2190.pdf -Dan On Wed, Aug 24, 2016 at 7:16 PM, Thomas Levine <_...@thom

Re: [R] I'm getting confused with notation and terminology in output from weibull parametric survival model from survreg()

2016-07-29 Thread Dalthorp, Daniel
The parameterization for Weibull in the 'survival' package corresponds to base R's dweibull, etc. suite as 1/scale --> shape and exp(coef[1]) --> scale On Fri, Jul 29, 2016 at 1:07 PM, Christopher W. Ryan wrote: > I'm trying to run a Weibull parametric survival model for recurrent event > data,

Re: [R] font size in graphs...can R read Windows settings?

2016-07-28 Thread Dalthorp, Daniel
; las = 1, > > mai = c(0.85, 0.85, 0.32, 0.12), > > font.main = 1, > > cex.main = 1.0, > > cex.lab = 1.0, > > cex.axis = 0.9) > > > > Duncan > > > > *From:* Dalthorp, Daniel [mailto:ddalth...@usgs.gov] > *Sent:* F

Re: [R] font size in graphs...can R read Windows settings?

2016-07-28 Thread Dalthorp, Daniel
ue"))), > type = "b") > > Regards > > Duncan > > Duncan Mackay > Department of Agronomy and Soil Science > University of New England > Armidale NSW 2351 > Email: home: mac...@northnet.com.au > > -Original Message- > From: R-

[R] font size in graphs...can R read Windows settings?

2016-07-27 Thread Dalthorp, Daniel
Hi All, I am putting together a package that (among other things) draws some nice graphs for users. I place some explanatory text on figs using "text" and "mtext". But the size of the text depends on the Windows display settings: Smaller (100%), medium (125%) or larger (150%) (In Windows 7... Contr

Re: [R] tclArray() --- "active"?!

2016-07-06 Thread Dalthorp, Daniel
cell, and that the widget needs to record > the fact that there is now no active cell.) > > -pd > > > > On 06 Jul 2016, at 16:18 , Dalthorp, Daniel wrote: > > > > Sometimes when working with tclArray's, an empty element called "active" > is >

[R] tclArray() --- "active"?!

2016-07-06 Thread Dalthorp, Daniel
Sometimes when working with tclArray's, an empty element called "active" is appended to the array. Does anyone know when (and why) this happens? And how to prevent it (or at least predict it so that it can be removed by hand)? E.g., library(tcltk); library(tcltk2) tt<-tktoplevel() dat<-tclArray()

Re: [R] better loop for simulation

2016-06-18 Thread Dalthorp, Daniel
try: n.questions <- 10 # or however many you want mult.choice <- 2 scores <- rbinom(1000, size = n.questions, prob = 1/mult.choice) On Sat, Jun 18, 2016 at 3:12 PM, Naresh Gurbuxani < naresh_gurbux...@hotmail.com> wrote: > I want to calculate a function many times over. My solution below work

[R] Fwd: tcltk: click and return table cell index

2016-05-06 Thread Dalthorp, Daniel
John Fox, Professor > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > Web: socserv.mcmaster.ca/jfox > > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > Dalthorp, > > Daniel > > Sent: April 29

Re: [R] tcltk: click and return table cell index

2016-05-02 Thread Dalthorp, Daniel
-- > John Fox, Professor > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > Web: socserv.mcmaster.ca/jfox > > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > Dalthorp, > > Daniel > >

[R] tcltk: click and return table cell index

2016-04-29 Thread Dalthorp, Daniel
I'm struggling mightily with what should be a simple task...when a user clicks on a cell in a tcltk table widget, I need to know which cell was clicked. One idea that gives a cryptic error: tkbind(table1, "", function(x, y){ tcl(table1, "index", x, y) } # x, y give pixel coordinates; "index" sh

Re: [R] how to use vectorization instead of for loop

2016-03-21 Thread Dalthorp, Daniel
or simpler and faster: dat[,4] <- sign(dat[,2])/dat[,3] # your original loop dat <- cbind(dat, dat[,2] == Inf) # append a new column with indicator for which rows have dat[,2] = Inf On Mon, Mar 21, 2016 at 2:45 PM, wrote: > Hello, > > Use combined ifelses, more or less like the following. >

Re: [R] Error in make.names(col.names, unique = TRUE) : invalid multibyte string at '14 <4a>ULY 2012'

2016-03-10 Thread Dalthorp, Daniel
Hi Ken, Without seeing your .csv file or how you are trying to read it, it's tough to diagnose the trouble. I inserted commas between the columns in your data snippet, pasted into Excel, saved as .csv file called "datesfile.csv" in the R working directory. Then, the following worked fine for me: j

Re: [R] extracting months from a data

2016-03-09 Thread Dalthorp, Daniel
bout the > existence of year information if it wasn't there to begin with. > -- > Sent from my phone. Please excuse my brevity. > > On March 9, 2016 4:49:18 PM PST, "Dalthorp, Daniel" > wrote: >> >> Good point about 29-Feb...fixed in the following: >&

Re: [R] extracting months from a data

2016-03-09 Thread Dalthorp, Daniel
my phone. Please excuse my brevity. > > On March 9, 2016 4:15:31 PM PST, "Dalthorp, Daniel" > wrote: >> >> Or: >> >> x <- c( "3-Oct", "10-Nov" ) >> format(as.Date(paste0(x,rep("-1970",length(x))),format='%d-%b-%Y')

Re: [R] extracting months from a data

2016-03-09 Thread Dalthorp, Daniel
Or: x <- c( "3-Oct", "10-Nov" ) format(as.Date(paste0(x,rep("-1970",length(x))),format='%d-%b-%Y'),'%b') # the 'paste0' appends a year to the text vector # the 'as.Date' interprets the strings as dates with format 10-Jun-2016 (e.g.) # the 'format' returns a string with date in format '%b' (which

Re: [R] extracting months from a data

2016-03-09 Thread Dalthorp, Daniel
?as.Date On Wed, Mar 9, 2016 at 10:14 AM, KMNanus wrote: > I have a series of dates in format 3-Oct, 10-Oct, 20-Oct, etc. > > I want to create a variable of just the month. If I convert the date to a > character string, substr is ineffective because some of the dates have 5 > characters (3-Oct

Re: [R] Ruofei Mo - How can I generate correlated data with non-normal distribution?

2016-03-03 Thread Dalthorp, Daniel
Ruofei, Ben's suggestion is simple and gets you close: require(MASS) nsim <- 100 rho <- -.9 Z <- mvrnorm(nsim, mu=c(0,0),Sigma = cbind(c(1,rho),c(rho, 1))) U <- pnorm(Z); a <- Z[,1] b <- qunif(U[,2]) cor(a,b) Pearson correlation characterizes the linear relationship between normal r.v.'s, bu

Re: [R] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
alue, not a data frame. However, I am not > sure. Any advice? > > > Thanks for your help. > > > Mike > > > -- > *From:* Dalthorp, Daniel > *Sent:* Wednesday, March 2, 2016 3:50 PM > *To:* Michael > *Cc:* r-help@r-project.org > *Sub

Re: [R] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Hi Michael, If you are working in Windows: # You can put the matrix directly into the clipboard write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F, col.names = F) The "sep" argument tells what character to use for separating columns. Default for Excel is tab (i.e. '\t') Default fo

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Dalthorp, Daniel
Or, if you want easy labels, you can play around with contour graphs. ?contour # will give you info on how to make contour plots The basic idea is to construct a matrix of z-values...one z for every combination of x and y contour(x,y,z) The x's would then be the x-values you want in (0.37273*log

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Dalthorp, Daniel
A simple solution that will give you an idea of some of the plot parameters: x<-seq(1,10,length=1000) # values for x-axis x0<-c(0.4,0.5,0.6,0.7) miny<-(log(min(x0))-(0.37273*log(max(x))-1.79389))/0.17941 # minimum y-value to show on graph maxy<-(log(max(x0))-(0.37273*log(min(x))-1.79389))/0.17941

Re: [R] Pairing and

2016-02-11 Thread Dalthorp, Daniel
Hi Val, There are probably more elegant ways to do it, but the following is fairly transparent: # input data arranged as an array: indat<-cbind(c(1,2,2,1),c(1,2,1,1),c(2,2,2,2),c(2,2,2,2),c(2,2,2,1),c(2,2,2,2),c(2,2,2,1),c(2,2,2,2),c(1,2,1,1),c(1,2,1,2)) indat outdat<-array(dim=c(dim(indat)[1],di

Re: [R] Angle between two points with coordinates

2016-01-28 Thread Dalthorp, Daniel
Gwennaƫl, Does the %% operator work for you? It gives x mod y (or the remainder after dividing x into y...result is guaranteed to be <=0 and >y) E.g. -150 %% 360 # 210 570 %% 360# 210 https://stat.ethz.ch/R-manual/R-devel/library/base/html/Arithmetic.html -Dan On Thu, Jan 28, 2

[R] tcltk table: get celltag value

2016-01-25 Thread Dalthorp, Daniel
I'm finding it very difficult to figure out how to read the value of "celltag" for a given cell in a tktable. I'm sure it's something like: tcl(classTable, "get", "celltag", row, column) but of the dozens of variations of names, options, args, and formats I've tried, nothing is working. Any sugg

[R] tcltk table "validateCommand"

2016-01-22 Thread Dalthorp, Daniel
I'd like to allow users to edit data in tcltk tables and to use vcmd to validate data entry, e.g., not allowing non-numbers to be entered in numeric cells and not allowing '\n' to be entered in text cells. The problem is that I can't figure out how to "see" their data entry before it is entered, a

Re: [R] tcltk tkwidget(..."table")

2016-01-22 Thread Dalthorp, Daniel
a good one. > > Greetings, > > Adrian > On Jan 21, 2016 10:36 PM, "Dalthorp, Daniel" wrote: > >> > Once you're up to speed on those issues... >> >> Any suggestions for getting up to speed on those issues? >> >> >> >&g

Re: [R] tcltk: write '[' and ']' in a table cell

2016-01-21 Thread Dalthorp, Daniel
ethz.ch/pipermail/r-help/2009-January/378558.html > > -pd > > > On 21 Jan 2016, at 02:12 , Dalthorp, Daniel wrote: > > > > I know it should not be difficult to write the string: > > > > i<-4 > > j<-17 > > lbl<-paste0("[", i, &quo

Re: [R] tcltk tkwidget(..."table")

2016-01-21 Thread Dalthorp, Daniel
> Once you're up to speed on those issues... Any suggestions for getting up to speed on those issues? On Thu, Jan 21, 2016 at 11:46 AM, peter dalgaard wrote: > > > On 21 Jan 2016, at 00:25 , Dalthorp, Daniel wrote: > > > > Thanks, Peter. > > > &g

[R] tcltk: write '[' and ']' in a table cell

2016-01-20 Thread Dalthorp, Daniel
I know it should not be difficult to write the string: i<-4 j<-17 lbl<-paste0("[", i, ", ", j, "]") # to a table, but I'm having a devil of a time trying to figure out how to do it. # the following gives lbl surrounded by braces. tt<-tktoplevel() tfr <- tkframe(tt) tkgrid(tfr) junk<-tclArray() j

Re: [R] tcltk tkwidget(..."table")

2016-01-20 Thread Dalthorp, Daniel
help. E.g. with a table (called table1) with 3 columns and want to set widths to 30, 5, and 5: colwidths<-c(30, 5, 5) for(i in 1:3) { tcl(table1, "width", i - 1, colwidths[i]) } On Wed, Jan 20, 2016 at 3:07 PM, peter dalgaard wrote: > > > On 19 Jan 2016, at 20:48 , Da

[R] tcltk tkwidget(..."table")

2016-01-19 Thread Dalthorp, Daniel
Does anyone know a simple way to create a tcltk table with columns of varying widths? -Dan -- Dan Dalthorp, PhD USGS Forest and Rangeland Ecosystem Science Center Forest Sciences Lab, Rm 189 3200 SW Jefferson Way Corvallis, OR 97331 ph: 541-750-0953 ddalth...@usgs.gov [[alternative HT

Re: [R] Use SQL in R environment

2016-01-15 Thread Dalthorp, Daniel
Very general question...try searching "R SQL" on google for a start. On Fri, Jan 15, 2016 at 9:59 AM, Amoy Yang via R-help wrote: > Hi All, > I am new here and a beginner for R. Can I use SQL procedure in R > environment as it can be done in SAS starting with PROC SQL; > Thanks for helps! > > A

[R] rjags loading error

2016-01-15 Thread Dalthorp, Daniel
What has happened?! I get the following error message when I try to load rjags package (w/ Windows 7)... > require(rjags) Loading required package: rjags Error in get(method, envir = home) : lazy-load database 'C:/Program Files/R/R-3.2.3/library/rjags/R/rjags.rdb' is corrupt In addition: Warni

Re: [R] creating cubes

2016-01-15 Thread Dalthorp, Daniel
populate the array with the > matrixes? Suppose I want to populate it with 10 matrixes > > matrix(NA,5,5) > > Matteo > > > On 15 January 2016 at 22:26, Dalthorp, Daniel wrote: > > How about: D<-array(dim=c(d1, d2, d3))? > > > > > > > > On Fri, Jan

Re: [R] creating cubes

2016-01-15 Thread Dalthorp, Daniel
How about: D<-array(dim=c(d1, d2, d3))? On Fri, Jan 15, 2016 at 2:20 PM, Matteo Richiardi < matteo.richia...@gmail.com> wrote: > What is the best way to store data in a cube? That is, I need to create a > data structure D with three indexes, say i,j,h, so that I can access each > data point D[i

Re: [R] different coloured axis title labels for different axes

2016-01-11 Thread Dalthorp, Daniel
How about this: plot(0,0,xlab='',ylab='') mtext(side=1,line=3,text='x axis',col=4) mtext(side=2,line=3,text='y axis',col=2) -Dan On Mon, Jan 11, 2016 at 7:44 AM, Evan Cooch wrote: > Consider a simple plot of X vs Y. There are elements on the plot that > represent X, or Y, that are presented i

[R] close specific graphics device

2015-12-15 Thread Dalthorp, Daniel
dev.off(which) can be used to close a specific graphics device where "which" is the index of the device, but is there a way to assign a custom number (or name) to a windows device so that specific window can be later closed via dev.off (or some other method) if it is open? The following does NOT w