Hi all,
I have a large number of text strings to search for enumerated items.
However, I am receiving this error message even though I thought that I
properly escaped the special character closed parenthesis:
> Count<-str_count(text3,keywords)
Error in stri_count_regex(string, pattern,
Hi all,
I have a situation where I have 16 bins. I generate a random number and
then want to know which bin number the random number falls in. Right now, I
am using a serious of 16 if() else {} statements which get very complicated
with the embedded curly braces. Is there a more efficient (i.e.,
;>
> >>> B.
> >>>
> >>>
> >>>
> >>>> On Apr 25, 2017, at 8:23 PM, Boris Steipe <boris.ste...@utoronto.ca>
> wrote:
> >>>>
> >>>> How about:
> >>>>
> >>>> unlis
Hi all,
I am looking for a streamlined way of counting the number of enumerated
items are each element of a character vector. For example:
text1<-c("This is an example.
List 1
1) Example 1
2) Example 2
10) Example 10
List 2
1) Example 1
2) Example 2
These have been examples.","This is another
Hi all,
Is anyone aware of a package, function, or general R trick that would make
generating histograms like the one in the attachment easy in R (i.e.,
without manually drawing each individual horizontal line and specifying the
coordinates for a textbox for each number)?
I need to make ~12 of
Hi all,
I have 2 vectors and need to extract only the elements from v2 that do not
appear in v1. What is the most efficient way to do this?
In the example below, I need to extract "var1".
v1<-"b0"
v2<-c("b0","var1")
Thanks,
Dan
[[alternative HTML version deleted]]
vily depends on the context you have in mind.
>
> Cheers,
> 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"
Hi all,
I need to generate heavy and light-tailed normal variates separately for
demonstration purposes. I figure for the heavy-tailed, I will just generate
variates from a t distribution with low degrees of freedom. How does one
generate light-tailed normal variates?
Thanks,
Dan
Hi all,
I want to select all variables in the data.frame with a name that
includes are certain string. Something like the following:
merge3[,names(merge3) %in% c("Email","Email.x")]
But there are too many variations on the Email variable names to list them all.
Can anyone advise?
Thanks!
Dan
Hi all,
I have a number of columns with spaces in the column names exactly as
I want them in R. When I go to export the data table to csv using
write.csv(), the fn adds periods in place of the spaces.
Is there a way to suppress the addition of the periods?
Thanks,
Dan
, May 26, 2015 at 9:30 PM, Dan Abner dan.abne...@gmail.com wrote:
Hi all,
I realize that the backslash is an escape character in R, therefore, I
am trying to replace it with a forward slash. Can someone please
suggest how to get this code to work?
lib-gsub(\,/,X:\Classes\TT\Automation)
Error
Hi all,
I realize that the backslash is an escape character in R, therefore, I
am trying to replace it with a forward slash. Can someone please
suggest how to get this code to work?
lib-gsub(\,/,X:\Classes\TT\Automation)
Error: unexpected symbol in lib-gsub(\,/,X
Thanks,
Dan
Of Dan Abner
Sent: Monday, June 23, 2014 3:19 PM
To: Greg Snow
Cc: r-help@r-project.org
Subject: Re: [R] Custom sampling method in R
Hi Greg,
Thanks, this makes sense. I can envision the call to the sample fn
like you are discribing. Any ideas on how to construct the vector? I
still am
Hi all,
I have the following situation and a good efficient way to perform
this operation in R has not come to me. Any suggestions/input are
welcome.
I have a user-defined parameter (let's call it x) whose value is
selected from a set of possible values (j). Once the user selects one
of the
.
On Mon, Jun 23, 2014 at 3:11 PM, Dan Abner dan.abne...@gmail.com wrote:
Hi all,
I have the following situation and a good efficient way to perform
this operation in R has not come to me. Any suggestions/input are
welcome.
I have a user-defined parameter (let's call it x) whose value
Hi all,
Can anyone please explain the following results (why does median()
work here but not mean())? Is there a fix or work around for this?
Thanks,
Dan
by(urpdata[,2],urpdata[,12],mean,na.rm=TRUE)
Error in FUN(X[[1L]], ...) : could not find function FUN
Hi all,
Can anyone explain what is happening with element 4,4 of c1? ifelse()
is not recongizing it as value 1:
c1
q1q2q3q4
q1 1.000 0.6668711 0.6948419 0.5758860
q2 0.6668711 1.000 0.6040746 0.4917447
q3 0.6948419 0.6040746 1.000 0.4730732
q4
Hi everybody,
I am using the apriori() fn in the arules package and am encountered an error.
rules - apriori(rdayst,parameter = list(support = 0.01, confidence = 0.6))
You chose a very low absolute support count of 0. You might run of memory.
I assume this is related to the value of .01
Hi everybody,
I have data in the format of the example data below where essentially a
large number of indicator variables (coded [0,1]) reflect traits of the
same id across multiple rows. I need to represent the data in a 1 row per
id format. I see this as being similar to converting from long to
wrote:
Hello,
If I understand it correctly, just change mysum to the following.
mysum-function(x) tapply(x,d1$id,sum)
Hope this helps,
Rui Barradas
Em 30-10-2013 11:07, Dan Abner escreveu:
Hi everybody,
I have data in the format of the example data below where essentially a
large
, Dan Abner wrote:
Hi everybody,
I have data in the format of the example data below where essentially a
large number of indicator variables (coded [0,1]) reflect traits of the
same id across multiple rows. I need to represent the data in a 1 row per
id format. I see this as being similar
Hi all,
I am using the ... argument to parmeterize a user define fn to accept
multiple input objects. I subsquently save all these data as a list.
Question: what is the best way to recover or extract the original object
names that were fed to the fn?
Thanks,
Dan
[[alternative HTML
] absqrt(c(1, 2, 5))
Cheers,
Bert
On Fri, Oct 18, 2013 at 9:36 AM, Dan Abner dan.abne...@gmail.com wrote:
Hi Bert,
Thanks for your response. Please see example below:
d1-data.frame(x1=runif(100),x2=runif(100))
d2-data.frame(x3=runif(100),x4=runif(100))
d3
should now work.
Sheepishly,
-Bert
On Fri, Oct 18, 2013 at 10:21 AM, Dan Abner dan.abne...@gmail.com wrote:
Hi Bert,
Thank you for the code.
However, I don't see what I am doing different, but my output is
different.
I would much rather have output similar to yours where only
Hi all,
I am attempting to write an R fn to produce a random sequence of 8 binaries
(4 ordered pairs). I would like to parmeterize the fn so that it takes 2
arguments: 1 that is an overall probability of a 1 vs. 0 and the other
which controls the likelihood of 1s on the 1st vs. the 2nd element of
Hi all,
I am attempting to write an R fn that will accept multiple (but varying on
how many) objects (usually data frames) as inputs and return summary output.
What is the best way to pass the object names to the fn (I have thought of
2 options below) AND how do I then use the names inside the
Hi everybody,
I thought I was using the get() fn correctly here to loop over multiple
data frame names in an R for() loop. Can someone advise?
miss-c(#NULL!,999)
d-c(d1,d2,d3,d4)
for(i in 1:4){
+
+ miss1-ifelse(i=2,miss[1],miss[2])
+ miss1
+
+
Hi everyone,
Is it possible to obtain the 1st 3rd quartiles the median in a sqldf()
select statement? If so, can you please provide the summary fn code?
Thanks!
Dan
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
Hi everyone,
I have the following call to the barplot() function which produces the
desired stacked bar chart. HOWEVER, barplot() chooses 4 different shades of
gray for the stacks. If I want to use the legend=NULL argument in
combination with a separate call to legend() to customize the legend,
Hi everyone,
I understand the process of obtaining the internal integer codes for
the raw values of a factor (using as.numeric() as below), but what is
the best way to obtain these codes for the levels() of a factor (since
the as.numeric() results don't really make clear which code maps to
which
Hi everyone,
I have the following call to the merge() function. How does one
prevent duplicate columns in the resulting data frame that the 2
parent data frames have in common but are not true key or by
variables?
data3-merge(data1,data2,by=id)
data3
id total.x total.y balance
1 78 78 90
2 91
Ok, let's say I only want the common columns from data1. Is there a
succinct way of doing this for potentially hundreds of in common
columns?
On Mon, Mar 11, 2013 at 3:25 PM, Ista Zahn istaz...@gmail.com wrote:
On Mon, Mar 11, 2013 at 3:17 PM, Dan Abner dan.abne...@gmail.com wrote:
Hi
Hi everyone,
I am familiar with using the chron package to work with date/time
values, but what about just time values with no date info present?
What is the best tool to convert character values to time values when
no date info is present?
Thanks!
Dan
Hello everyone,
I am trying to add the following text (in proper notation) to a
graphic using expression().
X-bar (with a subscript of cv) = XX.
Note: Ideally cv would be a subscript, but it doesn't have to be.
I have the following code:
text(625,.012,expression(bar(X)cv = 552.01))
Error:
Hi everyone,
What is the easiest way to remove the word Average and strip leading
and trailing blanks from the character vector (d5.Region) below?
.nrow.d5. d5.Region
11 Central Average
22 Coastal Average
33East Average
44
Hi everyone,
Any ideas on troubleshooting this memory issue:
d1-read.csv(arrears.csv)
Error: cannot allocate vector of size 77.3 Mb
In addition: Warning messages:
1: In class(data) - data.frame :
Reached total allocation of 1535Mb: see help(memory.size)
2: In class(data) - data.frame :
Hello everyone,
I have a character vector of 24 hour time values in the format hm
without the delimiting :. How can I insert the : immediately to
the left of the second digit from the right?
mytimes-scan(what=)
1457
1457
1310
1158
137
1855
Thanks!
Dan
-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Dan Abner
Sent: Thursday, January 26, 2012 6:50 AM
To: r-help@r-project.org
Subject: [R] Inserting a character into a character string
Hello everyone,
I have a character vector of 24 hour time values
:03
[7] 04:04 00:37 13:20 00:04 02:11 23:20
You could also check that tmp%/%100 (the hour) and tmp%%100
(the minute) are in their expected ranges before calling
sprintf.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: Dan Abner [mailto:dan.abne
Hello everyone,
I am writing my own function to return the column index of all variables
(these are currently character vectors) in a data frame that contain a
dollar sign($). A small piece of the data look like this:
can_sta can_zip ind_ite_con ind_uni_con AL 36106 $251,895.80 $22,874.43
AL
) )
? regexpr # $ has a special value
Michael
PS -- Stop with HTML postings (seriously, it actually does mess up
what the rest of us see and I think it causes trouble for the archives
as well)
On Tue, Jan 24, 2012 at 8:49 AM, Dan Abner dan.abne...@gmail.com wrote:
Hello everyone,
I am writing my
Hello everyone,
I use Bob Muenchen's approach for reading in in-stream (to use SAS
parlance) delimited data within a script. This works great:
mystring -
id,workshop,gender,q1,q2,q3,q4
1,1,f,1,1,5,1
2,2,f,2,1,4,1
3,1,f,2,2,4,3
4,2, ,3,1, ,3
5,1,m,4,5,2,4
6,2,m,5,4,5,5
7,1,m,5,3,4,4
(In
particular the special behavior of the default sep = )
Thanks for the well-posed question and working data.
Michael
On Thu, Jan 19, 2012 at 11:37 AM, Dan Abner dan.abne...@gmail.com wrote:
Hello everyone,
I use Bob Muenchen's approach for reading in in-stream (to use SAS
parlance
Hi everyone,
I have the following:
sqldf(select Premie,count(tpounds) N,avg(tpounds) Avg_Weight,
stddev_samp(tpounds) StdDev
from children
group by Premie
having !is.na(Premie))
sqldf() does not like the !is.na(Premie) specification. How does one
exclude a missing group in an aggregated
Hello everyone,
I have 1 data frame (just a vector in the example below) with 12
individuals listed and a separate vector of 36 days (in week intervals).
What is the best way to merge these together so that each individual
(specialist here) has all 36 days matched with their specialist number (a
Hello everyone,
What is the most efficient simpliest way to convert all components of a
list to separate columns in a matrix?
Is there an easy way to programmatically pad the length of the resulting
shorter character vectors so that they can be easily combined into a data
frame?
I have the
Hello everyone,
I have the following call to sapply() and error message. Is the most
efficient way to deal with this to make sum(!is.na(x)) a function in a
separate line prior to this call? If not, please advise.
N.Valid=sapply(x,sum(!is.na(x)))
Error in match.fun(FUN) :
'sum(!is.na(x))' is
Hello everyone,
After running the following code, I obtain this error message.
mydata - read.table(textConnection(mystring),
+header=TRUE, sep=,,
+row.names=id, na.strings= )
mydata
Warning message:
closing unused connection 3 (mystring)
=
However, when I attempt to run
Hello everyone,
I have two questions:
1)
I want to create a subset of a data frame column-wise and simultaneously
extract the row names into a proper variable. I tried this, but received
an error:
myleft-mydata[c(id=row.names(mydata),workshop,gender,q1,q2)]
Error in `[.data.frame`(mydata,
Hello everyone,
How does one pass multiple arguments of a user defined function to that
function when called within sapply()?
I have the following:
myna-function(x,miss.val) {x[x %in% miss.val]-NA;x}
mydataNA3-sapply(mydataNA,c(x=myna,miss.val=c(9,99)))
Error in match.fun(FUN) :
'c(x =
Hello everyone,
Can someone please suggest the most succinct method for extracting the
first value from each component of a list and saving the resulting vector
as a character vector?
Thank you,
Dan
[[alternative HTML version deleted]]
__
Hi everyone,
I am attempting to use the apply() function to obtain the mode and class of
each column in a data frame, however, I am encountering unexpected results.
I have the following example data:
v13-1:6
v14-c(1,2,3,3,NA,1)
v15-c(Good,Bad,NA,Good,Bad,Bad)
f4-factor(rep(c(Blue,Red,Green),2))
Hello everyone,
Is it possible to specify a 2 line y-axis label on the same lef-hand side
y-axis? I am using the \n regular expression, but only the 2nd line appears
(I assume the 1st line is printed off the page...)
plot(PRE_SHB,R1,
main=Figure 1.1: Scatterplot of Residualized
Post Score,
Hello everyone,
Can anyone suggest a decently documented (with good examples in the
documentation) R package/function that performs segmentation (cluster,
mixture modeling) of a population using both continuous and categorical
input variables?
Thank you,
Dan
[[alternative HTML version
Hi everyone,
How does one suppress only the x-axis tick mark labels (not the tick marks
themselves, I want those and the entire y-axis labels and marks) in the
plot() fn?
thanks!
Dan
[[alternative HTML version deleted]]
__
Hi everyone,
Is it possible to to specify titles and axis labels on 2 separate lines when
using the plot fn? What about tick mark labels?
Example of main title:
Figure 1: Side-by-side Boxplots
of Y by X
instead of
Figure 1: Side-by-side Boxplots of Y by X
Hello everyone,
I have the following factor:
levels(pp_income)
[1]1 2 3 4 5 6 7
[9] 8 9 Renter
I want to subset so that only values 1:9 are included. I have the following:
income-pp_income[pp_income %in% c(1:9)]
levels(income)
[1]1
Hello everyone,
I have been using the sink() function as follows:
x-rnorm(100)
sink(C:\\Users\\dan\\Desktop\\Current Events\\myhw.txt,
append=TRUE,split=TRUE)
m1-c(Mean=mean(x),SD=sd(x),Min=min(x),Max=max(x))
m1
sink()
===
Is it possible to create tabular style output very much like the ODS
Hello everyone,
What is the most elegant and efficient way to count non-missing values of a
vector?
Thanks!
Dan
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do
Hi everyone,
How does one place an object name (in this case a vector name) into another
object (while essentially masking the values of the first object?
For example:
JOBSAT-rnorm(40)
CI-function(x,alpha){
+ result-cbind(x,mean=mean(x),alpha)
+ print(result)
+ }
CI(JOBSAT,.05)
I want this
Hello everyone,
What is the simplest, most RELIABLE way to import data from MS EXCEL (.xls)
format to R? In the past I have used the read.xls() function from the
xlsReadWrite package, however, I have been wrestling with it all afternoon
long with no success. I continue to receive the following
Hello everyone,
I have the following x variable:
DATE-as.Date(as.character(data12$DATE),%m/%d/%Y)
This works fine, however, I want to plot multiple years of data on separate
plots by month. All years have all 12 months data except 2011; HOWEVER I
need the x axis limits to remain the same. I
Hello everyone,
Is there an R function that returns an object's search path position?
Thank you,
Dan
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the
Hello everyone,
I am attempting to use the %in% operator with the ! to produce a NOT IN type
of operation. Why does this not work? Suggestions?
data2[data1$char1 %in% c(string1,string2),1]-min(data1$x1)
data2[data1$char1 ! %in% c(string1,string2),1]-max(data1$x1)+1000
Error: unexpected '!' in
Hello everyone,
Below is a metadata summary of raw data in a data frame (which itself is a
data frame). I want to add 2 columns to the data frame below that will
contain the min and max for integer and numeric class columns and NA for
factors and character vectors. Can anyone suggestion the most
Hello everyone,
I have the following R code for a multivariable function:
fn2-function(x,y,z){(y+2*z)/(5*y-x*z)}
fn2(-5,-2,3)
[1] 0.8
No problems.
===
If, however, I call the function using a vector substitution for the
arguments, R sees this as 3 separate calls to the
Hello everyone,
What is the best way to have R print a title and then skip a line (both
without the [1] line preffix) when writing a function that prints an object
(to the console)? Simplified example:
fn3-function(x,y){
c1-cov(x,y)
print(c1)}
data1-data.frame(age=rnorm(50),weight=rnorm(50))
Hello everyone,
I have a few questions about the print() fn:
1) I have the following code that does not center the character string:
print(The TITLE,quote=FALSE,justify=center)
2) How can I get R to not print the leading [1], etc. when using print()?
(Sorry, I don't know what the leading [1]
Hello everyone,
I am attempting to write a function to count the number of non-missing
values of each column in a data frame using the sapply function. I have the
following code which is receiving the error message below.
n.valid-sapply(data1,sum(!is.na))
Error in !is.na : invalid argument
Perfect Erik! Thank you!
On Wed, May 4, 2011 at 4:22 PM, Erik Iverson er...@ccbr.umn.edu wrote:
Dan,
I am attempting to write a function to count the number of non-missing
values of each column in a data frame using the sapply function. I have
the
following code which is receiving the
Hello everyone,
How does one write a function to return the name of an input object (that is
assumed to be a data frame) as a character string? I tired using the get(),
but this does not work as I had hoped. For example:
myfn-function(x){
output-data.frame(Attribute=Data Set
Hello everyone,
This IFELSE function call is not working properly. I do not receive an error
message, but the actions are not executed conditional as I was hoping. Any
assistance is appreciated.
set.seed(12345)
res1-rbinom(1,1,.1)
rdata3-transform(data.frame(res1),input1=rnorm(1,50,10))
72 matches
Mail list logo