Re: [R] ggplot2: Get the regression line with 95% confidence bands

2023-12-11 Thread Daniel Nordlund
x(ids, na.rm = TRUE) : no non-missing arguments to max; returning -Inf Hope this helps, Rui Barradas After playing with this for a little while, I realized that the problem with plotting the confidence limits is the addition of ylim(470, 500).  The confidence values are outside the y

Re: [R] free_port returning only one port...

2023-01-08 Thread Daniel Nordlund
nt port on each invocation free_port(random=TRUE) Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA -- This email has been checked for viruses by Avast antivirus software. www.avast.com __ R-help@r-project.org mailing list -- To U

Re: [R] Issues when trying to fit a curve when generating random deviates

2022-09-18 Thread Daniel Nordlund
27;t see the code you used to generate the curve. What kind of curve are you trying to plot, and why are you trying to plot that curve? As Rui suggested, it typically doesn't make sense to use line plots to represent discrete data.  If you explain what your end goal is, someone may be able t

Re: [R] Date and Time

2022-07-17 Thread Daniel Nordlund
01  7:28:10' > dt <- strptime(in_dt_str,'%Y-%m-%d %H:%M:%S') if the date and time are stored in different variables then paste them together before converting > in_dt <- '2022-01-01' > in_tm <- '7:28:10' > dtm <- strptime(paste(in_dt, in_tm

Re: [R] bootstrap CI of the difference between 2 Cramer's V

2022-06-05 Thread Daniel Nordlund
t;,"très important","pas important","pas important","important","important","très important","très important","pas important","pas important") statut2<-c("moyennement riche","pas riche&quo

Re: [R] Dates as headers causing confusion but needed to convert to Julian days for ANOVA

2021-10-25 Thread Daniel Nordlund
quot;date" functions to get what you want. For example # pivot your data data_long <- data %>% pivot_longer(starts_with("X"), names_to = "chr_date", values_to = "LST") # now you can use various data functions to get your month, day, and year # for exampl

Re: [R] How to plot dates

2021-03-16 Thread Daniel Nordlund
e, "1 day"), unit="secs")) # plot event date by time grouped by date ggplot(myDat, aes(x=tme, y = dte, group = dte)) + geom_line() + geom_point() +    expand_limits(y=as.Date(c('20210301', '20210331'),'%Y%m%d'

Re: [R] ggplot2 + coord_cartesian + automatic ylim

2020-12-13 Thread Daniel Nordlund
close)) AAPL %>%   ggplot(aes(x = date, y = close)) +   geom_line() +   labs(title = "AAPL", y = "Closing Price", x = "") +   coord_x_date(xlim=xminmax, ylim=yminmax) +   theme_tq() Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA ___

Re: [R] 回复: high-frequency data in R

2020-11-24 Thread Daniel Nordlund
-- 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. You have the wrong format for your date

Re: [R] Export R outputs to SAS dataset

2020-08-24 Thread Daniel Nordlund
es of con     observed   median   lower   upper Q25 0.054000 0.054000 0.01525 0.11275 Q50 0.139275 0.139275 0.06140 0.31000 Q75 0.315000 0.315000 0.17300 0.45250 Quartiles of vac     observed  median   lower    upper Q25  0.01250 0.01250 0.00125 0.026000 Q50  0.02675 0.02675 0.01665 0.144575

Re: [R] Export R outputs to SAS dataset

2020-08-22 Thread Daniel Nordlund
ut in your SAS log or listing. Dan -- Daniel Nordlund Port Townsend, WA USA __ 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/pos

Re: [R] read.csv fails in R console in Ubuntu terminal but works in RStudio after R 3.6.3 upgrade to R 4.0.2?

2020-07-16 Thread Daniel Nordlund
UBSCRIBE 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. Works fine in Windows 10 64-bit with R-4.0.2, so I would echo Bert Gunter's ad

Re: [R] Strange behavior when sampling rows of a data frame

2020-06-19 Thread Daniel Nordlund
for me. df[sample(nrow(df),3), 'treated'] <- TRUE Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLE

Re: [R] How to convert European short dates to ISO format?

2020-06-10 Thread Daniel Nordlund
On 6/10/2020 1:20 AM, Luigi Marongiu wrote: isoDates = as.Date(oriDates, format = "%m/%d/%y") You need to use the format for European short dates. isoDates = as.Date(oriDates, format = "%d/%m/%y") Hope this is helpful, Dan -- Daniel Nordlund Po

Re: [R] Add Gauss normal curve ?

2020-04-11 Thread Daniel Nordlund
-04-08","2020-04-09","2020-04-10")) nc<-c(1,1,2,7,3,6,6,20,17,46,67,71,56,70,85,93,301,339,325,226,608,546,1069,1264,1340,813,608) plot(as.Date(mydates),nc,pch=16,type="o",col="blue",ylim=c(1,1400), xlim=c(min(as.Date(mydates)),max(as.Date(mydates

Re: [R] Capturing positive and negative changes using R

2019-07-21 Thread Daniel Nordlund
Here is one more option using the ave() function. Using Jim's data and naming convention fkdf$X1_change <- ave(fkdf[,'X1'], fkdf$Country, FUN=function(x) c(0,diff(x))) fkdf$X2_change <- ave(fkdf[,'X2'], fkdf$Country, FUN=function(x) c(0,diff(x))) hope t

Re: [R] Nested structure data simulation

2019-05-18 Thread Daniel Nordlund
e sense to include both in your model. Dan -- Daniel Nordlund Port Townsend, WA USA __ 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

Re: [R] Downloading R Data

2019-04-14 Thread Daniel Nordlund
. If you wish to do something else, you will need to be more specific about what you want. Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.e

Re: [R] Newton-RaphsonMethod

2019-02-24 Thread Daniel Nordlund
h I will leave the solution of the problem to you. Dan -- Daniel Nordlund Port Townsend, WA USA __ 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 htt

Re: [R] seq() problem with chron

2018-09-06 Thread Daniel Nordlund
- strptime("02/20/13 00:00:00", "%m/%d/%y %H:%M:%S") dt2 <- strptime("07/03/18 15:30:00", "%m/%d/%y %H:%M:%S") dt <- seq(from=dt1, to=dt2, by=900) dt[length(dt)] There might also be some useful functions in the lubridate package. Hope this is helpful, D

Re: [R] Converting chr to num

2018-08-19 Thread Daniel Nordlund
rrences of '%'. The pattern is more strict, and that could cause the conversion to fail if the process that created the strings resulted in trailing spaces. Without the '$' the conversion succeeds. df <- data.frame(variable = c("12.6% ", "30.9%", &quo

Re: [R] Rendo and dataMultilevelIV

2018-08-02 Thread Daniel Nordlund
to above (which describes the dataMultilevelIV dataset)? Dan -- Daniel Nordlund Port Townsend, WA USA __ 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 gu

Re: [R] Help with transpose please.

2018-06-23 Thread Daniel Nordlund
x27;Dx',ave(rep(1, nrow(have)), have[,1:2], FUN = seq_along), sep='') # cast the data into wide format cast(cbind(have,dxnames), ClaimServiceID + ClaimID ~ dxnames, value='DiagnosisCode') Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __

Re: [R] Cannot Load A Package

2018-06-02 Thread Daniel Nordlund
ary(devtools) install_github("kasperwelbers/semnet") Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLE

Re: [R] Using tryCatch in a for loop

2018-05-22 Thread Daniel Nordlund
object does not have 3 rows, so you get an error and SlopeDiff is not created. You need to correct these problems, and any others, so that your code runs correctly when there are no data problems. Then you can worry about trapping errors in the case where there are data problems. Hope this i

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Daniel Nordlund
median squared error", shouldn't the final line of the function be median((y - ypred)^2) Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mai

Re: [R] Average of results coming from B=100 repetitions (looping)

2018-05-08 Thread Daniel Nordlund
(i in 1:10) lst[i] <- i mean(lst) # does not work The documentation for mean, ?mean, says that it is looking for a numeric or logical vector. To convert your list to a numeric vector you could unlist() it. mean(unlist(lst)) Hope this is helpful, Dan -- Daniel Nordlund Port Townsend,

Re: [R] Empirical density estimation

2018-03-11 Thread Daniel Nordlund
this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter wrote: You need to re-read ?density and perhaps think again -- or do some study -- about how a (kernel) density estimate works. The points at which the estimate is calculated are *not*

Re: [R] How to turn off warnings about class name conflicts

2018-02-14 Thread Daniel Nordlund
d not get the message you are getting. I suspect you have something in your workspace that is causing the problem. Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/m

Re: [R] command line fails

2018-02-02 Thread Daniel Nordlund
ading Tools/RV Tools/myfile.r" I don't know how rscript handles the '\' character (i.e. as an escape or not) so I changed the '\' to '/' just to be safe. And note, the program pathname and the file being passed need to

Re: [R] Simulation based on runif to get mean

2018-01-30 Thread Daniel Nordlund
at your real world task actually is. Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ 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 gui

Re: [R] Missing information in source()

2017-11-07 Thread Daniel Nordlund
On 11/7/2017 12:01 PM, Tom Backer Johnsen wrote: Dear R-help, I am running a Mac under Sierra, with R version 3.4.2 and RStudio 1.1.383. When running head () or tail () on an object in a script using source (

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Daniel Nordlund
minimal, self-contained, reproducible code. this looks like a good place for apply() apply(data,2,function(x) sum(x != 0, na.rm=TRUE)) Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSU

Re: [R] Help needed with aggregate or other solution

2017-10-26 Thread Daniel Nordlund
0:00", "2012-04-24 06:00:00", "2012-04-24 12:00:00", "2012-04-24 18:00:00", "2012-04-25 00:00:00", "2012-04-25 06:00:00", "2012-04-25 12:00:00", "2012-04-25 18:00:00", "2012-04-26 00:00:00", "2012-04-26 06:00:0

Re: [R] display double dot over character in plotmath?

2017-05-12 Thread Daniel Nordlund
y making sure the NUMLOCK key is on, hold down the alt key and press 0228 on the numeric keypad. Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.eth

Re: [R] Reverse the scoring of some Columns of a Data Set

2017-03-08 Thread Daniel Nordlund
):1]) Hope this helps, Dan -- Daniel Nordlund Port Townsend, WA USA __ 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/post

Re: [R] [FORGED] how to draw the confidence interval

2017-03-06 Thread Daniel Nordlund
o generate your random samples, and then describe what you want, e.g. "plot sample means and standard errors estimated from the samples," we can play along at home. Then you may get some usable help. You could also Google something like "R plot means and standard errors&qu

Re: [R] [FORGED] Export Forecasted output to a table (excel)

2017-02-01 Thread Daniel Nordlund
DON'T use Excel. Ever. See: http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf cheers, Rolf Turner Unfortunately, that link appears to be broken / does not exist anymore. Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mail

Re: [R] package ‘Rccp’ is not available (for R version 3.3.2)

2016-12-09 Thread Daniel Nordlund
at.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. Should that be the Rcpp package and not Rccp? Dan -- Daniel Nordlund Port Townsen

Re: [R] reshaping a large dataframe in R

2016-11-28 Thread Daniel Nordlund
n? Thanks in advance, best Jean-Philippe I don't know about efficiency, but it looks like you could do something like this: y <- t(matrix(t(dataGaus),4)) Maybe someone will come along with something better, Dan -- Daniel Nordlund Port

Re: [R] About reshape dataset

2016-10-22 Thread Daniel Nordlund
e along with a "better" answer, but I played with this a bit and this is what I came up with. After running your code I ran DF2$site <- substr(as.character(DF2$variable),1,5) DF2$var <- substr(as.character(DF2$variable),7,10) DF3 <- cast(DF2,year +

Re: [R] Cannot install package write.xls

2016-10-07 Thread Daniel Nordlund
sion 3.3.1) What can I do? As far as I know, write.xls and write.table are not packages, they are functions. There is a write.xls function in the xlsx (and also the openxlsx) package and write.table is a built-in R function that exists in the util package. Dan -- Daniel Nordlund Port Townsen

Re: [R] Bootstrapping in R

2016-10-01 Thread Daniel Nordlund
ing the same answer." Someone may then be able to do more than guess at what the problem is. Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r

Re: [R] Writing data onto xlsx file without cell formatting

2016-09-26 Thread Daniel Nordlund
d document will help: https://cran.r-project.org/web/packages/xlsx/xlsx.pdf Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] Help with strftime error "character string is not in a standard unambiguous format"

2016-09-12 Thread Daniel Nordlund
nd > strptime("Thu, 25 Aug 2016 6:34 PM",format="%a, %d %b %Y %I:%M %p") [1] "2016-08-25 18:34:00 PDT" works for me. Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org

Re: [R] R bug when started in Windows 10

2016-08-14 Thread Daniel Nordlund
producible exampole, I did notice one problem in the example you did give of a directory with spaces. It looks like you were using single quotes (') around the path/filename. Windows requires that there be double quotes (") around any path/filenam

Re: [R] SAS file

2016-08-07 Thread Daniel Nordlund
need to get an XPORT format file, or have SAS available, or get some 3rd party software that will read SAS datasets. Dan -- Daniel Nordlund Port Townsend, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz

Re: [R] how to expand the dataframe

2016-07-21 Thread Daniel Nordlund
ong at home" (i.e. give us a reproducible example). Dan Daniel Nordlund Port Townsend, WA -- Daniel Noredlund Bothell, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PL

Re: [R] Sampe numbers

2016-07-19 Thread Daniel Nordlund
Frederic, you need to be more clear about what you want to do. If you are sampling 100 numbers from 1:100 with replacement, the sum will always be greater than 50 (as has already been pointed out). In addition, you mention trying to eliminate zeros. If you are sampling from 1:100 there wil

Re: [R] dplyr's arrange function

2016-06-15 Thread Daniel Nordlund
t; (in descending order). If you want the character value of line 7 to sort last, it would need to be "06.1 (0.61)" or " 6.1 (0.61)" (notice the leading space). Hope this is helpful, Dan Daniel Nordlund Port Townsend, WA USA __ R

Re: [R] break string at specified possitions

2016-05-11 Thread Daniel Nordlund
ositions. begs <- function(x) c(0,x[-length(x)])+1 Then, then use that function in your call to str_sub str_sub(test_string,begs(ends),ends) %>% print Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.

[R] how to eliminate ggplot warning frrom "knitted" document

2015-11-16 Thread Daniel Nordlund
eate a pdf document and the warning is cluttering up my pdf document. Is there anyway to alter the plot statement to avoid the warning? If not, is there a way to get knitr not to print out the warning to the markdown document so that it doesn't end up in the pdf document? Thanks,

Re: [R] how to work with time of day (independent of date)

2015-10-30 Thread Daniel Nordlund
row.names = c(NA, -8L), class = "data.frame") print(f) f$dateandtimes <- as.chron(as.POSIXct(as.character(f$date),format = "%Y-%m-%d %H:%M:%S")) print(f) f$justtimes <- times(as.numeric(f$dateandtimes) %% 1)

[R] how to work with time of day (independent of date)

2015-10-30 Thread Daniel Nordlund
uot;2015-10-30 00:50:00", "2015-10-30 09:30:00", "2015-10-30 21:10:00", "2015-10-31 00:50:00", "2015-10-31 10:30:00"), class = "factor"), value = c(88L, 17L, 80L, 28L, 23L, 39L, 82L, 79L)), .Names = c("date", "value"), ro

Re: [R] retaining characters in a csv file

2015-09-23 Thread Daniel Nordlund
o convert strings to factors, so you can modify as needed. In addition, if your files aren't as regular as I inferred, you can increase the number of rows to read in the first line to ensure getting the classes right. Hope this is helpful, Dan -- Daniel Nordlund Bothell, WA USA ___

Re: [R] Connecting R to SAS SPDS through ODBC - no results.

2015-09-18 Thread Daniel Nordlund
x27;, believeNRows=FALSE, colQuote=NULL) Hope this is helpful, Dan -- Daniel Nordlund Bothell, WA USA __ 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

Re: [R] remove 0 and NA values

2015-07-13 Thread Daniel Nordlund
equal to zero! On Jul 13, 2015 5:31 PM, "Daniel Nordlund" mailto:djnordl...@frontier.com>> wrote: On 7/13/2015 3:01 PM, Lida Zeighami wrote: Hi there, I have a matrix which its elements are 0, 1,2,NA I want to remove the columns which the colsums are equ

Re: [R] sampling rows with values never sampled before

2015-06-22 Thread Daniel Nordlund
orld problem. There is no error checking, and for large samples it may not scale well. Hope this is helpful, Dan -- Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/l

Re: [R] Combining multiple probability weights for the sample() function.

2015-06-03 Thread Daniel Nordlund
m contain identical letters 1 and 3, AND ~50% again contain identical letters 2 and 3 (except in this example as it is not possible from the choices). Can multiple probability weightings be combined in such a manner? Ben, If I correctly understand your requirements, you can't do what you

Re: [R] Getting a cdf equal to 1 from a variable kernel density estimation

2015-05-27 Thread Daniel Nordlund
lowing: gaussianKernel <- function(u) exp(-u^2/2)/(2*pi)^.5 densityFunction <- function(x, df, ker, h){ difference = t(t(df) - x)/h W = sum(apply(difference, 1, ker)) / (nrow(df)*h) } If you are wanting to do density estimation for real world work, I would get help from someone i

Re: [R] Vincentizing Reaction Time data in R

2015-05-20 Thread Daniel Nordlund
;- rnorm(100,200,50) # create deciles for binning decile <- as.numeric(cut(rt, quantile(rt,0:10)/10),include.lowest=TRUE)) # collect into a dataframe (not really necessary) df <- data.frame(rt=rt, decile=decile) #compute the bin means aggregate(rt,list(decile),mean,data=df) This sho

Re: [R] dotplot

2015-05-16 Thread Daniel Nordlund
On 5/16/2015 1:19 PM, Daniel Nordlund wrote: On 5/16/2015 12:32 PM, li li wrote: Hi all, I wrote the following code and have two questions: (1) As you can see, I would like different colors for different types. It does not come out that way in the graph from this code. Anyone know how to

Re: [R] dotplot

2015-05-16 Thread Daniel Nordlund
over the colors chosen. I created a vector, color, specifying the colors and the order they will be applied. 2. the scales parameter is what you are looking for. The parameter is looking for a list which consists of name=value pairs. You can rotate the labels by a specified number of deg

Re: [R] BIG difficulties in Using boot.ci (bot package)

2015-04-13 Thread Daniel Nordlund
index=3) Error in boot.ci(results, type = "bca", index = 3) : object 'results' not found A reproducible example means that when I run your code on my machine, I get the same results / warnings / errors that you get. I got something different. Dan -- Daniel Nordl

Re: [R] generating phi using function()

2015-03-30 Thread Daniel Nordlund
e help says of the formula argument formula formula for restricted MIDAS regression or midas_r object. Formula must include fmls function your formula does not include the fmls() function, it uses mls(). So I think your problem may have to do with how you are calling the midas

Re: [R] Sampling

2015-03-29 Thread Daniel Nordlund
assuming you want to sample without replacement. Generalizing it to other data structures is left as an exercise for the reader. replicate(100,mean(sample(yourdata,30, replace=FALSE))) hope this is helpful, Dan -- Daniel Nordlund Bothell, WA USA __ R

Re: [R] generating phi using function()

2015-03-29 Thread Daniel Nordlund
-- 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. -- Daniel Nordlund Bothell, WA USA _

Re: [R] SAS equivalent for R's signif function?

2015-02-09 Thread Daniel Nordlund
AS you could use PROC FCMP to turn this into a function. If you are interested contact me offline and I will send you a PROC FCMP implementation. Dan -- Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and mor

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-09 Thread Daniel Nordlund
-04 2011-11-04 Pradip K. Muhuri, PhD SAMHSA/CBHSQ 1 Choke Cherry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Daniel Nordlund Sent: Sunday, November 09, 2

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-09 Thread Daniel Nordlund
rg/posting-guide.html and provide commented, minimal, self-contained, reproducible code. I am not familiar with the mutate() function from dplyr, but you can get your wanted results as follows: data2 <- within(data1, oidflag <- apply(data1[,-1], 1, max, na.rm=TRUE)) Hope this is h

Re: [R] loops in R

2014-11-05 Thread Daniel Nordlund
,list(Population), mean)) with(your_data_frame,aggregate(R,list(Population), var)) hope this is helpful, Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] Custom sampling method in R XXXX

2014-06-23 Thread Daniel Nordlund
, p=probs, replace=TRUE) } new_sample(x) Daniel Nordlund Bothell, WA USA > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Dan Abner > Sent: Monday, June 23, 2014 3:19 PM > To: Greg Snow > Cc: r-help@r-p

Re: [R] A combinatorial assignment problem

2014-05-01 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Daniel Nordlund > Sent: Thursday, May 01, 2014 1:10 AM > To: r-help@r-project.org > Subject: Re: [R] A combinatorial assignment problem > >

Re: [R] A combinatorial assignment problem

2014-05-01 Thread Daniel Nordlund
r,m,max_iter=120) { n <- 0 cmb <- combn(r,m) repeat { n <- n+1 tbl <- table(map<-cmb[,sample(1:choose(r,m),k)]) if(min(tbl) == max(tbl)-1) break if(n > max_iter) break } return(t(map)) } a <- assignment(10,7,3) Dan Daniel Nordlund

Re: [R] system()

2014-04-14 Thread Daniel Nordlund
freezes R on my Win 7 Pro x64 box using either 64-bit R-3.0.3 or R-3.1.0. You might try switching to shell() instead of system() > command <- paste(aa, fnm) > shell(command) However, it all depends on what programs you are trying to run and what behavior you expect. Dan Daniel

Re: [R] stratified sampling

2014-03-07 Thread Daniel Nordlund
sp3 = structure(c(1L, 1L, 1L, 1L), .Label = "mean", class = > "factor")), .Names = c("watershed", > "year", "sp1", "sp2", "sp3"), class = "data.frame", row.names = c(NA, > -4L)) > > Any s

Re: [R] ISwR Plotting Issue

2014-02-19 Thread Daniel Nordlund
as cut-n-paste from your email) and got a plot of the data with regression line without any error message. What version of R and ISwR are you running? Have you tried closing R and starting a clean session? Since the example worked for me, there is not much else I can help with. Dan Dan

Re: [R] Difference between two datetimes

2014-01-28 Thread Daniel Nordlund
e of 1.5 hours: > > > as.POSIXct("2010-04-04 03:00:00")- as.POSIXct("2010-04-04 02:30:00") > Time difference of 1.5 hours > > > > > > > Any suggestions? > Thanks, > David Fox. > Daylight savings time change in Australia? Dan Da

Re: [R] Select 5 identical numbers

2014-01-20 Thread Daniel Nordlund
read up on ?sample Dan Daniel Nordlund Bothell, WA USA > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Alaios > Sent: Monday, January 20, 2014 10:12 PM > To: Alaios; R-help@r-project.org > Subject

Re: [R] Wrong date fromat?

2013-12-06 Thread Daniel Nordlund
rted data starts > from January 2, 2000. > > What have I done wrong? > You need to specify an appropriate value for the origin parameter. It looks like as.Date in the zoo package (which masks the as.Date in base) defaults to the Unix epoch value, origin='1970-01-01'. Yo

Re: [R] Randomize two categories testing a specific condition R version 3.0.2 windows 32 bit

2013-11-23 Thread Daniel Nordlund
#check for excess of 'a's or 'b's if(suma - sumb > 2) p <- .2 if(sumb - suma > 2) p <- .8 } } If this doesn't do what you want, then write back to R-help describing what your ultimate goal is (i.e., what this method of randomization is supp

Re: [R] Cannot read XPT file using foreign package

2013-10-04 Thread Daniel Nordlund
oc CPORT was used to write the file, read.xport will not be able to read it. read.xport only reads files written using the XPORT engine. If you don't have access to SAS you will need to get whomever created the file to re-create it. Dan Daniel Nordlund Bothell, WA USA > -Original

Re: [R] multilevel analysis

2013-09-30 Thread Daniel Nordlund
cko > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@r-project.org mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > >

Re: [R] How to rebuild an R package that has been removed from CRAN?

2013-08-19 Thread Daniel Nordlund
Yeah, I tried building the package and got essentially the same warnings and decided that further assistance required someone above my pay grade. :-) Daniel Nordlund Bothell, WA USA > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org

Re: [R] Appropriateness of R functions for multicore

2013-08-19 Thread Daniel Nordlund
The R high performance computing sig might be useful for some of these questions. https://stat.ethz.ch/mailman/listinfo/r-sig-hpc Dan Daniel Nordlund Bothell, WA USA > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behal

Re: [R] How to rebuild an R package that has been removed from CRAN?

2013-08-19 Thread Daniel Nordlund
aniel Nordlund Bothell, WA USA _ From: Shang Zuofeng [mailto:zuofengsh...@gmail.com] Sent: Monday, August 19, 2013 2:16 PM To: Daniel Nordlund Cc: r-help@r-project.org Subject: Re: [R] How to rebuild an R package that has been removed from CRAN? Thanks, Dan! The package is "ass

Re: [R] How to rebuild an R package that has been removed from CRAN?

2013-08-19 Thread Daniel Nordlund
age, why it was removed from CRAN, and a host of other things. If you want more detailed help, you need to provide the "at a minimum" info requested in the posting guide. It would also help if you told us what package you are trying to install. Dan Daniel Nordlund Bothell, WA

Re: [R] changing colnames

2013-08-14 Thread Daniel Nordlund
, then it is even easier. I stored the following data in a file, temp.txt, X1 X2 X3 age race stat 12 2 35 17 6 55 and read it like this dat1<- read.table("c:/tmp/temp.txt", header=TRUE, skip=1) and got this > dat1 age race stat 1 122 35 2 176 55 > Hope

Re: [R] Fwd: Problem with ODBC connection

2013-06-10 Thread Daniel Nordlund
age on my system that I tried. So if you can't read the data one way, try another. You could install and load the sos package and runthe following function findFn('xls') and you will get all sorts of suggestions. Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA _

Re: [R] R does not subset

2013-05-03 Thread Daniel Nordlund
with). Try the following (and notice the space at the end of "Infected ". RECinf<-subset(REC2, INFECTION=="Infected ") David's suggestion worked because you did include a space there. Dan Daniel Nordlund Bothell, WA USA _

Re: [R] expanding a presence only dataset into presence/absence

2013-04-29 Thread Daniel Nordlund
pecies c present at site 1 on date 3, but it is not present in your desired data. It is not at all clear (nor is it deducible) how you get from your example data to your desired data. If you clarify your requirements, maybe someone will be able to help. Dan Daniel Nordlund Bothell, WA USA

Re: [R] How to read a *.csv file in R?

2013-03-13 Thread Daniel Nordlund
Thank you in advance for your help? > > The data appear to be tab delimited with the decimal point being a comma (','). So, try read.csv2() heisenberg <- read.csv2(file="comprice.csv", header=TRUE, sep="\t") Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] Random number generator used in 'runif'

2013-02-18 Thread Daniel Nordlund
thod actually used. No guessing necessary, as the R-help is quite explicit Details The currently available RNG kinds are given below. kind is partially matched to this list. The default is "Mersenne-Twister". Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA

Re: [R] sweave question

2013-02-13 Thread Daniel Nordlund
ot;\\begin{figure}\n") cat("\\includegraphics[width = ", wid, ", height = ", hei, "]{proj1-fig1}\n") cat("\\end{figure}\n") @ If I have got any of this wrong, I am sure someone will come along and correct me. Hope this is helpful, Dan Daniel Nordl

Re: [R] setting off-diagonals to zero

2013-01-23 Thread Daniel Nordlund
The statement print((731:1095)[-SEQ]) does not remove the values of SEQ (i.e. 731 732 733 734 735 736) from the printed sequence, but instead uses SEQ to index into the vector created by 731:1095. But the vector 731:1095 has length 365, so no elements are removed because the sm

Re: [R] How to construct a valid seed for l'Ecuyer's method withgiven .Random.seed?

2013-01-23 Thread Daniel Nordlund
flow going on. > > > > The internal L'Ecuyer RNG is a modification of the original one (and I'm > not > > familiar with it), but they seem to relax that restriction. > > > > Hana I apologize if this message is posted twice. I am having email problems. I t

Re: [R] random sampling matrix

2012-12-18 Thread Daniel Nordlund
22 [3,] 31 23 21 > matrix(sample(m),nrow=3) [,1] [,2] [,3] [1,] 21 23 1 [2,] 31 33 23 [3,]23 22 > matrix(sample(m),nrow=3) [,1] [,2] [,3] [1,] 312 21 [2,] 331 22 [3,] 23 233 > Hope this is helpful, Dan Daniel Nordlund Bot

Re: [R] remove last row of a data frame

2012-12-11 Thread Daniel Nordlund
work: b <- a[-nrow(a),] If you haven't already read the manual, "An Introduction to R", that ships with every copy of R, then now is the time. hope this is helpful, Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org ma

Re: [R] Ceiling function gives me wrong answer

2012-11-28 Thread Daniel Nordlund
value 1/3 ends up being slightly smaller that one-third. > print(1/3, digits=20) [1] 0.1483 > > b <- 1000^(1/3) > print(b, digits=20) [1] 9.9982236 Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA __

Re: [R] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-14 Thread Daniel Nordlund
;ll be playing with your code (which is a model of readability, and a > lesson to me on same, BTW) and keep you posted on my progress. > > Warmly, Andrew > Andrew, R-help is not really the venue for discussing SAS programming and how the SAS data step reads fixed width files. If yo

  1   2   3   >