Re: [R] print data.frame with a list column

2024-01-29 Thread Micha Silver

Excellent, many thanks.


On 29/01/2024 16:56, Ivan Krylov wrote:

On Mon, 29 Jan 2024 14:19:21 +0200
Micha Silver  wrote:


Is there some option to force printing the full list?
df <- data.frame("name" = "A", "bands" = I(list(1:20)))

format.AsIs is responsible for printing columns produced using I(). It
accepts a "width" argument:

format(x, width = )
#   name bands
# 1A 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20

It's more complicated with knitr::kable. Its format.args argument is
only used with numeric arguments, but you can pre-format the table with
knitr::kable(format(x, width = )).


--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[ESS] WG: ESS[SAS]: experience, fixes, and starting questions

2024-01-29 Thread Hüsing , Johannes via ESS-help
When I worked with SAS, I used ESS for handling SAS in batch mode. This was 
working perfectly for me. Among the upsides I remember were automatic 
indentation, output files saved while running the process, and a clean slate of 
settings each time I re-ran the script.

ESS for SAS was a higher productivity boost compared to "interactive" 
session-based SAS than ESS-R is over Rstudio.

Sorry for the signature.



Dr. Johannes Hüsing
Epidemiologie


Landeskrebsregister NRW gGmbH
Gesundheitscampus 10
44801 Bochum
T 0234 54509-216
F 0234 54509-499
johannes.hues...@krebsregister.nrw.de
www.landeskrebsregister.nrw.de


Newsletter LKR NRW jetzt anmelden unter Newsletter 

Geschäftsführer
Dr. Andres Schützendübel
Vorsitzender der Gesellschafterversammlung
Staatssekretär Dr. Edmund Heller
Sitz der Gesellschaft
Bochum
Registergericht
Amtsgericht Bochum
HRB 17715

HINWEIS: Diese Nachricht ist nur für den Adressaten bestimmt. Es ist nicht 
erlaubt, diese Nachricht zu kopieren oder Dritten zugänglich zu machen. Sollten 
Sie irrtümlich diese Nachricht erhalten haben, bitte ich um Ihre Mitteilung per 
E-Mail oder unter der oben angegebenen Telefonnummer.


__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[ESS] ESS[SAS]: experience, fixes, and starting questions

2024-01-29 Thread Sparapani, Rodney via ESS-help
Hi Federico:

iESS[SAS] goes way back to the beginning of ESS.  At that time, interactive SAS
was thought to be a good idea.  However, batch SAS was quickly adopted as a
more prudent approach given that there was comparatively little interactive
support relative to R.  And the reason the F-keys are NOT turned on globally
by default is due to the GNU elisp standards that do not allow it.  So you have
to turn on your F-keys by yourself.  I do it like this in ~/.emacs

(setq ess-sas-global-unix-keys t)
(require 'ess-site)

--
Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
Vice President, Wisconsin Chapter of the American Statistical Association
Institute for Health and Equity, Division of Biostatistics
Medical College of Wisconsin, Milwaukee Campus

If this is outside of working hours, then please respond when convenient.

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] print data.frame with a list column

2024-01-29 Thread Ivan Krylov via R-help
On Mon, 29 Jan 2024 14:19:21 +0200
Micha Silver  wrote:

> Is there some option to force printing the full list?

> df <- data.frame("name" = "A", "bands" = I(list(1:20)))

format.AsIs is responsible for printing columns produced using I(). It
accepts a "width" argument:

format(x, width = )
#   name bands
# 1A 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20

It's more complicated with knitr::kable. Its format.args argument is
only used with numeric arguments, but you can pre-format the table with
knitr::kable(format(x, width = )).

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] print data.frame with a list column

2024-01-29 Thread Micha Silver
I have a data.frame with one column as a list. When printing (or using 
knitr::kable) the list gets truncated. Is there some option to force 
printing the full list?



MWE:


df <- data.frame("name" = "A", "bands" = I(list(1:20))) > print(df) name 
bands 1 A 1, 2, 3, I'd like to avoid the ellipsis in "bands" column, 
rather print all list elements. Thanks


--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 2SLS with Fixed Effects and Control Variables

2024-01-29 Thread Kelis Wong
Dear John Fox, Christian Kleiber, and Achim Zeileis,

I am attempting to run various independent variable parameters to assess
their suitability. Unfortunately, I hit a snag and couldn't get the tests
to run properly. When I used ivreg, I got an error message saying: "Error
in eval(predvars, data, env) : object 'WageInequality' not found."

Can you please help?

Model: numeric(WageInequality) = numeric(EffectiveMinimum) +
numeric(EffectiveMinimum2)
(whereas EffectiveMinimum2 is the quadratic form of EffectiveMinimum)

Instruments: numeric(`Log Real Minimum Wage`) + numeric(`Log Real Minimum
Wage2`) + numeric(IVinteration)
(whereas Real Minimum Wage2 is the quadratic form of Real Minimum Wage)

Time and Region Fixed Effects: factor(Region) + numeric(Year) + Region:Year
(whereas Region:Year is and interaction term of Region and Year)

Control Variables: factor(Region), numeric(`Woman Percentage`),
numeric(`Noneducated Percentage`)

Parameter 1:
ivreg(WageInequality ~ EffectiveMinimum + EffectiveMinimum2 + Region | `Log
Real Minimum Wage` + `Log Real Minimum Wage2` + IVinteration + Region,
dataset))

Parameter 2:
ivreg(WageInequality ~ EffectiveMinimum + EffectiveMinimum2 + Region + Year
+ Region:Year | `Log Real Minimum Wage` + `Log Real Minimum Wage2` +
IVinteration + Region + Year + Region:Year, dataset))

Parameter 3:
ivreg(WageInequality ~ EffectiveMinimum + EffectiveMinimum2 + Region + Year
+ Region:Year + `Woman Percentage` + `Noneducated Percentage` | `Log Real
Minimum Wage` + `Log Real Minimum Wage2` + IVinteration + Region + Year +
Region:Year + `Woman Percentage` + `Noneducated Percentage`, dataset))

--
Peace,

Kelis Wong

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] DescTools::Quantile

2024-01-29 Thread Izmirlian, Grant (NIH/NCI) [E] via R-help
It looks like a homework assignment. It also looks like you didn't read the 
documentation carefully enough. The 'len.out' argument in seq is solely for 
specifying the length of a sequence. The 'quantile' function omputes the  
empirical quantile of raw data in the vector 'x' at cumulative 
probabilit(y)(ies) given in the weights' argument, with interpolation I'm 
between. For example

quantile(x=c(2.3, 1, 7, -4, 1), weights=c(0.60,0.45))
60%  45%
1.52 1.00

So to do what you want, there may be a canned function in R but you can always 
write your own.

First we write one that takes values in 'x' and weights in 'w', vectors of the 
same length, and returns the quantile at cumulative probability 'p' for a 'p' 
of length 1.

"%,%" <-paste0

qtl.one <-
function(p, x, w)
{
## argument checking
bad <- length(x)!=length(w)
bad <- bad || (length(p)!=1)
bad <- bad || any(diff(x)<=0)
if(bad)
  stop("Arguments 'x' and 'w' must be " %,%
  "vectors of the same legnth. Argument " %,%
  "'x' must be a vector of nondecreasing " %,%"values.")

if(any(w<=0)||(sum(w)!=1))
  stop("elements of 'w' must be positive " %,%"and sum to 1")

## the actual body of the function
x[max(which(cumsum(w)<=p))]
}

Now we write a vectorization of the above that will work given a vector of 'p' 
cumulative probabilities:


qtl <-
function(p, x, w)
{
if(length(p)==1) ans <- qtl.one(p, x, w)
if(length(p) >1)
   ans <- sapply(p, FUN=qtl.one, x=x,w=w)
ans
}


From: "Izmirlian, Grant (NIH/NCI) [E]" 
Date: Mon, Jan 29, 2024, 3:55 AM
To: "Izmirlian, Grant (NIH/NCI) [E]" 
Subject: Re: [R] DescTools::Quantile

Greetings,

I am having a problem with DescTools::Quantile
(a function computing quantiles from weighted samples):

# these sum to one
probWeights = c(
 0.0043, 0.0062, 0.0087, 0.0119, 0.0157, 0.0204, 0.0257, 0.0315, 0.0378,
 0.0441, 0.0501, 0.0556, 0.06, 0.0632, 0.0648, 0.0648, 0.0632, 0.06,
 0.0556, 0.0501, 0.0441, 0.0378, 0.0315, 0.0257, 0.0204, 0.0157, 0.0119,
 0.0087, 0.0062, 0.0043
  )
  x = seq(-100,100,length.out=length(probWeights))

  qtls <- DescTools::Quantile(x, weights=probWeights, probs=c(0.1,0.9))

cat("\nQuantiles:\n")
  print(qtls)


Both quantiles are equal to 100!
Is this function working or am I not using it correctly?

Michael Meyer

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.