[R] cpquery problem

2016-07-28 Thread ross.chapman
Hi all I have a problem with the cpquery function in the bnlearn package. I have constructed a hybrid network (using a mix of continuous and discrete variables). The network is named "fitted". I am interested in predicting the probability of observing a value greater that a particul

Re: [R] How to pass na.rm=T to a user defined function

2016-07-28 Thread David Winsemius
> On Jul 28, 2016, at 7:37 PM, Jun Shen wrote: > > Because in reality the NA may appear in one variable but not others. For > example for ID=1, CL may be NA but not for others, For ID=2, V1 may be NA > etc. To keep all the IDs and all the variables in one data frame, it's > inevitable to see som

Re: [R] EM algorithm for maximizing the likelihood of Multivariate Hawkes process

2016-07-28 Thread Jeff Newmiller
How did you try to find the answer before posting? Some possibilities might be go ogling [1] or perusing CRAN to find [2]... Note that HTML tends to mangle code... please follow the Posting Guide and send plain text email to this list. [1] http://bfy.tw/6y3o [2] https://cran.r-project.org/web/v

Re: [R] Extract data

2016-07-28 Thread roslinazairimah zakaria
Thank you very much Jim. It works beautifully. Best regards, On Fri, Jul 29, 2016 at 11:56 AM, Jim Lemon wrote: > Hi Roslina, > Try this: > > aggbalok_mth[aggbalok_mth$year %in% 2009:2014,] > > Jim > > > On Fri, Jul 29, 2016 at 1:12 PM, roslinazairimah zakaria > wrote: > > Dear r-users, >

Re: [R] Extract data

2016-07-28 Thread Jim Lemon
Hi Roslina, Try this: aggbalok_mth[aggbalok_mth$year %in% 2009:2014,] Jim On Fri, Jul 29, 2016 at 1:12 PM, roslinazairimah zakaria wrote: > Dear r-users, > > I would like to extract year from 2009 to 2014 with the corresponding month > and rain amount. > > I tried this: > aggbalok_mth[aggbalo

[R] Extract data

2016-07-28 Thread roslinazairimah zakaria
Dear r-users, I would like to extract year from 2009 to 2014 with the corresponding month and rain amount. I tried this: aggbalok_mth[aggbalok_mth$year == 2009:2014, ] but some of the data is missing. > dput(aggbalok_mth[aggbalok_mth$year == 2009:2014, ] ) structure(list(month = c(1, 7, 2, 8, 3

Re: [R] How to pass na.rm=T to a user defined function

2016-07-28 Thread Jun Shen
Because in reality the NA may appear in one variable but not others. For example for ID=1, CL may be NA but not for others, For ID=2, V1 may be NA etc. To keep all the IDs and all the variables in one data frame, it's inevitable to see some NA On Thu, Jul 28, 2016 at 10:22 PM, Jeff Newmiller wrot

Re: [R] How to pass na.rm=T to a user defined function

2016-07-28 Thread Jeff Newmiller
Why not remove it yourself before passing it to those functions? -- Sent from my phone. Please excuse my brevity. On July 28, 2016 5:51:47 PM PDT, Jun Shen wrote: >Dear list, > >I write a small function to calculate multiple stats on multiple >variables >and export in a format exactly the way I

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

2016-07-28 Thread Dalthorp, Daniel
The trouble is getting the figs to look right for different users who happen to have different display settings. Nearly all my users will be on MS Windows, and, for the parameter set you gave, the figs will look different, depending on which "display size" parameter value is active and the screen r

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

2016-07-28 Thread Duncan Mackay
Hi Dan This is one of the features/problems of proportional graphing – getting it exactly right. Anyway good graphs usually take time I wonder if aspect in both base and lattice may be of use. Also I have a default par settings for base graphics where I sometimes change the mai comm

[R] How to pass na.rm=T to a user defined function

2016-07-28 Thread Jun Shen
Dear list, I write a small function to calculate multiple stats on multiple variables and export in a format exactly the way I want. Everything seems fine until NA appears in the data. Here is my function: do.stats <- function(data, stats.func, summary.var) as.data.frame(signif(sappl

Re: [R] Subtraction with aggregate

2016-07-28 Thread Jim Lemon
Hi Gang, This is one way: gangdat<-read.table(text="subject QMemotion yi s1 75.1017 neutral -75.928276 s2 -47.3512 neutral -178.295990 s3 -68.9016 neutral -134.753906 s1 17.2099 negative -104.168312 s2 -53.1114 negative -182.373474 s3 -33.0322 negative -137.

Re: [R] Converting string to data frame

2016-07-28 Thread Bert Gunter
Although others may be better able to decipher your messed up html post than I, you are more likely to get a helpful response if you **follow the posting guide** and post in plain text only, using ?dput() to input example data in a form that makes it easy for R helpers to input your data, scrutiniz

[R] Converting string to data frame

2016-07-28 Thread Steven Kang
Hi R users, I would like to convert a string into a data frame by creating a separator (ie pipe) between each potential fields (then using *read.table* function). ie. Here is the dummy input data for illustration (4 x 5) Date Type Description

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

2016-07-28 Thread Dalthorp, Daniel
Thanks, Duncan. This is close to what I was looking for. But I'm not using lattice. And the fontsize$text and fontsize$points are independent of display settings in Windows (screen resolution and 'size of objects'). I need to make my graphs [esp. placement and size of text(), mtext()] look good re

Re: [R] Subtraction with aggregate

2016-07-28 Thread jim holtman
One thing to watch out for are there always two samples (one of each type) for each subject? You had better sort by the emotion to make sure that when you do the difference, it is always with the data in the same order.Here is an example of some of these cases where they are ignored: > libra

Re: [R] Subtraction with aggregate

2016-07-28 Thread Gang Chen
Hi Jim and Jeff, Thanks for the quick help! Sorry I didn't state the question clearly: I want the difference between 'neutral' and 'negative' for each subject. And another person offered a solution for it: aggregate(cbind(QM, yi) ~ subject, data = mydata, FUN = diff) On Thu, Jul 28, 2016 at 4:

Re: [R] Subtraction with aggregate

2016-07-28 Thread Jeff Newmiller
What represents the difference when multiple values are present? sd? -- Sent from my phone. Please excuse my brevity. On July 28, 2016 1:40:16 PM PDT, Gang Chen wrote: >With the following data in data.frame: > >subject QMemotion yi > s1 75.1017 neutral -75.928276 > s2 -47.3512

Re: [R] Subtraction with aggregate

2016-07-28 Thread jim holtman
Not sure what you mean by "nice way", but here is a dplyr solution: > library(dplyr) > mydata <- read.table(text = "subject QMemotion yi +s1 75.1017 neutral -75.928276 +s2 -47.3512 neutral -178.295990 +s3 -68.9016 neutral -134.753906 +s1 17.2099 negative -10

Re: [R] about file name

2016-07-28 Thread ruipbarradas
Hello, Just use ?sub. x <- "35.84375_.100.71875" y <- sub("_\\.", "_-", x) Hope this helps, Rui Barradas   Citando lily li : > Thanks, but how to get the string like this: > "35.84375_-100.71875" use the minus sign instead of dot. > > On Thu, Jul 28, 2016 at 2:38 PM, jim holtman wrote: >> ju

Re: [R] about file name

2016-07-28 Thread jim holtman
add another step: (need to learn about regular expressions) > a [1] "X35.84375_.100.71875" > a.new <- sub("^.", '', a) > a.new [1] "35.84375_.100.71875" > sub("_.", "_-", a.new) [1] "35.84375_-100.71875" > Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me wh

Re: [R] about file name

2016-07-28 Thread lily li
Thanks, but how to get the string like this: "35.84375_-100.71875" use the minus sign instead of dot. On Thu, Jul 28, 2016 at 2:38 PM, jim holtman wrote: > just strip off the first character: > > > a > [1] "X35.84375_.100.71875" > > a.new <- sub("^.", '', a) > > a.new > [1] "35.84375_.100.71875"

[R] Subtraction with aggregate

2016-07-28 Thread Gang Chen
With the following data in data.frame: subject QMemotion yi s1 75.1017 neutral -75.928276 s2 -47.3512 neutral -178.295990 s3 -68.9016 neutral -134.753906 s1 17.2099 negative -104.168312 s2 -53.1114 negative -182.373474 s3 -33.0322 negative -137.420410 I can

Re: [R] about file name

2016-07-28 Thread jim holtman
just strip off the first character: > a [1] "X35.84375_.100.71875" > a.new <- sub("^.", '', a) > a.new [1] "35.84375_.100.71875" > Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Jul 28, 2016 at 3:51

[R] about file name

2016-07-28 Thread lily li
Hi R users, I have a string for example 'X35.84375_.100.71875', and I have another dataframe df that I want to export with the transformed string name '35.84375_-100.71875' with no extension. How to do this in R? Thanks for your help. a = 'X35.84375_.100.71875' write.table(df, file='', row.names=

Re: [R] Reduce woes

2016-07-28 Thread jeremiah rounds
Basically using Reduce as an lapply in that example, but I think that was caused by how people started talking about things in the first place =) But the point is the accumulator can be anything as far as I can tell. On Thu, Jul 28, 2016 at 12:14 PM, jeremiah rounds wrote: > Re: > "What I'm tryi

Re: [R] Reduce woes

2016-07-28 Thread jeremiah rounds
Re: "What I'm trying to work out is how to have the accumulator in Reduce not be the same type as the elements of the vector/list being reduced - ideally it could be an S3 instance, list, vector, or data frame." Pretty sure that is not true. See code that follows. I would never solve this task i

[R] How to Display Value Labels in R Outputs?

2016-07-28 Thread Courtney Benjamin
Hello R Experts, I am using the Survey Package in R to do some initial descriptive stats for my dissertation. With the outputs for both the svymean and the barplot, I would like the value labels to be displayed for the variable-it would make the descriptive statistics much easier to interpret.

Re: [R] problems reading XML type file from ishares website

2016-07-28 Thread Jeff Newmiller
Er, I failed to include the step to write the repaired data to a file... fnamenobom <- "nobom.xml" cat( paste( txt, collapse="\n" ), file=fnamenobom ) xmlfile <- xmlTreeParse( fnamenobom ) -- Sent from my phone. Please excuse my brevity. On July 28, 2016 11:20:23 AM PDT, Jeff Newmiller wrot

Re: [R] Fuzzy variable universe

2016-07-28 Thread Sarah Goslee
On Thu, Jul 28, 2016 at 2:46 PM, Arthur Rodrigues Stilben wrote: > > > Em 28-07-2016 15:45, Arthur Rodrigues Stilben escreveu: >> >> Sarah, >> >> First of all, thanks for reply. >> >> Second, It really works, but in fact I would to like to set individuals >> universe groups for each fuzzy_variable

Re: [R] Fuzzy variable universe

2016-07-28 Thread Arthur Rodrigues Stilben
Thanks for reply, Bert. Em 28-07-2016 15:31, Bert Gunter escreveu: Below. -- 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 Thu, Jul 28, 2016 at 11:11

Re: [R] Fuzzy variable universe

2016-07-28 Thread Arthur Rodrigues Stilben
Em 28-07-2016 15:45, Arthur Rodrigues Stilben escreveu: Sarah, First of all, thanks for reply. Second, It really works, but in fact I would to like to set individuals universe groups for each fuzzy_variable. Something like this: > test1 = fuzzy_variable( a = fuzzy_trapezoid( corners = c( 0

Re: [R] Help on improving an algorithm

2016-07-28 Thread li li
Thanks very much Don! You alternative method does make it much faster. However I think I made a mistake in my previous coding. Sorry. Instead of checking whether each row sum is larger than 8, what I wanted is to check whether each column sum is lager than 8. See the code below. So in this case,

Re: [R] Fuzzy variable universe

2016-07-28 Thread Bert Gunter
Below. -- 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 Thu, Jul 28, 2016 at 11:11 AM, Arthur Rodrigues Stilben wrote: > Sorry, I forgot to mention: > >

Re: [R] Fuzzy variable universe

2016-07-28 Thread Sarah Goslee
As Jeff suggested, I read the help for you. Based on the examples, you need: ## set universe sets_options("universe", seq(from = 0, to = 10, by = 0.1)) teste2 = fuzzy_variable( a = fuzzy_trapezoid( corners = c( 0, 1, 2, 3 ) ) ) comparing plot(teste) # complete with Warning and pl

Re: [R] problems reading XML type file from ishares website

2016-07-28 Thread Jeff Newmiller
Please keep the list included in the thread (e.g. reply-all?). I looked at the file and agree that it looks like xml with a utf8 byte order mark and Unix line endings, which means it is not XLS and it is not XLSX (which is a zipped directory of xml files with DOS line endings). Excel complains b

Re: [R] Fuzzy variable universe

2016-07-28 Thread Arthur Rodrigues Stilben
Sorry, I forgot to mention: > install.packages("sets") ... > library(sets) > teste = fuzzy_variable( a = fuzzy_trapezoid( corners = c( 0, 1, 2, 3 ) ), universe = seq( from = 0, to = 10, by = 0.1 ) ) > teste A fuzzy variable with values: a, universe The ideia is to set the universe group for th

Re: [R] Reduce woes

2016-07-28 Thread William Dunlap via R-help
I am not as familiar with those other languages as I should be, but in both examples aren't you using 'map' to call 'reduce' on each component of a list? In R the basic mapping function is lapply. > data <- list(one = c(1, 1), three = c(3), two = c(2, 2)) > rData <- lapply(X=data, FUN=functio

Re: [R] Help on improving an algorithm

2016-07-28 Thread MacQueen, Don
This is a good example to illustrate that R is a vectorized language, and programming concepts that would work in fortran, C, or any of many other languages are not always effective in R. The vectorized method below has produced the same value for 'p' in every example I¹ve tried, and is much faste

Re: [R] Estimators for non-normal data

2016-07-28 Thread Nika Sušac
Yes, I meant confirmatory factor analysis, I'm sorry if I wasn't clear. I was doing my analyses in lavaan and saw that there are several robust options (MLM, MLMVS, MLMV, MLF, MLR), but I wasn't sure about their specifics, so that was what I was actually asking about. I will definitely consult the

[R] EM algorithm for maximizing the likelihood of Multivariate Hawkes process

2016-07-28 Thread Ramkishore Swaminathan
I am trying to model data with multivariate Hawkes distribution. Take the below example. I am able to compute likelihood but don't know how to maximize it. library(hawkes) lambda0 <- c(0.2,0.2) alpha <- matrix(c(0.5,0,0,0.5),byrow=TRUE,nrow=2) beta<- c(0.7,0.7) history <- simulateHawkes(lamb

Re: [R] problems reading XML type file from ishares website

2016-07-28 Thread Jeff Newmiller
XLS has nothing to do with XML. The shift from XLS to XLSX/XLSM formats was where XML was introduced. You might occasionally find mislabelled files that seem to work anyway, but there is a significant difference inside true XLS files. Use a package designed to handle your data format. There ar

Re: [R] Fuzzy variable universe

2016-07-28 Thread Jeff Newmiller
This appears to be a question about a contributed package, though you have not specified which one (so your example code is not reproducible). Be warned that I have never seen discussion of fuzzy logic on this list, so any help you get here is likely to be from someone reading the documentation

[R] problems reading XML type file from ishares website

2016-07-28 Thread Bos, Roger
The ishares website has the S&P 500 stocks you can download as a XLS file, which opens fine in Excel, but I am not able to open it in R due to what seems to be invalid XML formatting. I tried using XLConnect and XML as shown below. Does anyone know a workaround or can point out what I am doin

[R] Fuzzy variable universe

2016-07-28 Thread Arthur Stilben
Hello, everyone! Is there a way to set universe group for each fuzzy_variable? I try to do this: > teste = fuzzy_variable( a = fuzzy_trapezoid( corners = c( 0, 1, 2, 3 ) ), > universe = seq( from = 0, to= 10, by = 0.1 ) ) But when I print teste: > teste A fuzzy variable with values: a, univer

Re: [R] Spread data.frame on 2 variables

2016-07-28 Thread Ulrik Stervbo
Hi Georg, it is difficult to figure out what happens between your expectation and the outcome if we cannot see a minimal dataset. Based on your description I did this library(tidyr) library(dplyr) test_df <- data_frame(channel = LETTERS[1:5], unit = letters[1:5], custID = c(1:5), dummy = 1) tes

Re: [R] SegFault when trying to install an inhouse package

2016-07-28 Thread Duncan Murdoch
On 28/07/2016 7:19 AM, Joanne Thomas wrote: Hi, Apologies if something similar has come up but I have been unable to find it in the archive. The company I work for has an issue with a package they've developed called ESVP. This is dependent on OpenSM, which I'm told is already somewhat delica

Re: [R] Reduce woes

2016-07-28 Thread Stefan Kruger
Ulrik - many thanks for your reply. I'm aware of many simple solutions as the one you suggest, both iterative and functional style - but I'm trying to learn how to bend Reduce() for the purpose of using it in more complex processing tasks. What I'm trying to work out is how to have the accumulator

[R] SegFault when trying to install an inhouse package

2016-07-28 Thread Joanne Thomas
Hi, Apologies if something similar has come up but I have been unable to find it in the archive. The company I work for has an issue with a package they've developed called ESVP. This is dependent on OpenSM, which I'm told is already somewhat delicate with respect to calls on rJava. When tryin

Re: [R] Reduce woes

2016-07-28 Thread Ulrik Stervbo
Hi Stefan, in that case,lapply(data, length) should do the trick. Best wishes, Ulrik On Thu, 28 Jul 2016 at 12:57 Stefan Kruger wrote: > David - many thanks for your response. > > What I tried to do was to turn > > data <- list(one = c(1, 1), three = c(3), two = c(2, 2)) > > into > > result <-

Re: [R] Spread data.frame on 2 variables

2016-07-28 Thread Ulrik Stervbo
Hi Georg, it's hard to tell without a reproducible example. Should spread really merge elements? Does spread know anything about CustID? Maybe you need to make a useful key of the CustIDs first and spread on that? Maybe I'm all off, because I'm really just guessing. Best, Ulrik On Thu, 28 Jul

Re: [R] Reduce woes

2016-07-28 Thread Stefan Kruger
David - many thanks for your response. What I tried to do was to turn data <- list(one = c(1, 1), three = c(3), two = c(2, 2)) into result <- list(one = 2, three = 1, two = 2) that is creating a new list which has the same names as the first, but where the values are the vector lengths. I kno

[R] Spread data.frame on 2 variables

2016-07-28 Thread G . Maubach
Hi All, I need to spread a data.frame on 2 variables, e. g. "channel" and "unit". If I do it in two steps spreads keeps all cases that does not look like the one before although it contains the same values for a specific case. Here is what I have right now: -- cut -- test1$dummy <- 1 test2 <-

Re: [R] Please advice me about nls.lm

2016-07-28 Thread peter dalgaard
I think you need someone who speaks your own language. Have a look at https://www.facebook.com/groups/KoreaRUsers/ - Peter D. > On 28 Jul 2016, at 08:54 , 박희국 wrote: > > Dear Sir/Madam > > > Dear > > Hello, I am a student in South Korea, and I would like to analysis genome > converge and

[R] [R-pkgs] new package clubSandwich: Cluster-Robust (Sandwich) Variance Estimators with Small-Sample Corrections

2016-07-28 Thread James Pustejovsky
Dear R users: I'm happy to announce the first CRAN release of the clubSandwich package: https://cran.r-project.org/web/packages/clubSandwich clubSandwich provides several variants of the cluster-robust variance estimator for ordinary and weighted least squares linear regression models, including

[R] Please advice me about nls.lm

2016-07-28 Thread 박희국
Dear Sir/Madam Dear Hello, I am a student in South Korea, and I would like to analysis genome converge and fit curve using nls.lm in R. But I am a very beginner user R. So this is not easy for me. I try to find and implement many example and tutorial. But it dose not help for me. And I fina

[R] Example for multivariate hawkes distribution

2016-07-28 Thread Ramkishore Swaminathan
Hi, I have a list of N categories that a user can click on. Lets say there are K such users totally. I have the past 3 months data which tells which user has clicked on which category on which date for how many times. For ex - {20th June 2016 : [10,15,12,15]} this dict is for a particular user and