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, opts_rege
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., e
y(stringr)
> >>> str_count(text1, "Example")
> >>> # [1] 5 5 5 5
> >>>
> >>> I guess that would be the neater solution.
> >>>
> >>> B.
> >>>
> >>>
> >>>
> >>>>
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 ex
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 th
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]]
___
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" comic strip )
>
>
>
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
[[alte
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
_
TRUE)
>
> best,
> Ista
>
> On Tue, May 26, 2015 at 9:30 PM, Dan Abner 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
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
>> 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-project.org
>> Subject: Re: [R] Custom sampling method in R
>>
>> Hi Greg,
&
robabilities that you specify.
>
> On Mon, Jun 23, 2014 at 3:11 PM, Dan Abner 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.
>>
>
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 valu
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"
> by(urpdata[,2],urpdata[,12],med
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 0.57
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 spe
Hi David,
1) Thanks very much. Your code shows that this was much simpler than I
anticipated.
2) I have made the appropriate changes to email in plain text. My apologies.
Thanks!
Dan
On Wed, Oct 30, 2013 at 1:17 PM, David Winsemius wrote:
>
> On Oct 30, 2013, at 4:07 AM, Dan Abner
Barradas 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,
&
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
all())[-1],deparse)
> }
>
> and the example should now work.
>
> Sheepishly,
>
> -Bert
>
>
> On Fri, Oct 18, 2013 at 10:21 AM, Dan Abner wrote:
> > Hi Bert,
> >
> > Thank you for the code.
> >
> > However, I don't see what I am d
in of salt. It is
> fragile at best.
>
> 2. I think ?match.call and ?deparse are what you're looking for:
>
> f <- function(...){
> deparse(match.call())
> }
>
> > g(a,b,sqrt(c(1,2,5)))
> [1] "a""b"&q
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 versi
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 fn
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
+
+ get(d[i])<-read.csv(paste("C
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, ho
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 l
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 wrote:
> On Mon, Mar 11, 2013 at 3:17 PM, Dan Abner wrote:
>> Hi everyone,
>>
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
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"
3"
> [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
o nothing
> to "5". Pad with 0's before calling sub if that is
> required.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
>> Beh
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
bably want grepl not grep
> any(grepl("\\$",x) )
> ? 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,
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
le: " " for a space
> and "\t" for a tab. E.g., read.table(text = data3, sep = " ", header =
> TRUE)
>
> Take a look at ?read.table for more info about the sep argument (In
> particular the special behavior of the default sep = "")
>
> Thank
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
8
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 aggrega
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 f
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,
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`(
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 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 not
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]]
__
R-h
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"
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 d
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]]
__
R-help@r-project.or
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
[[alternativ
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)]
>
> leve
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 OD
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 wan
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 r
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 err
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 t
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 pos
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 s
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: unexpe
>
> 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 separa
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
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 Name",Value=as.ch
Perfect Erik! Thank you!
On Wed, May 4, 2011 at 4:22 PM, Erik Iverson 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 error me
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 ty
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