Ah, thanks, that makes sense.
Peter
On Fri, Jul 1, 2022 at 10:01 PM Bill Dunlap wrote:
>
> This has to do with the mode of the subscript - logical subscripts are
> repeated to the length of x and integer/numeric ones are not. NA is logical,
> NA_integer_ is integer, so we get
>
> > x <- 1:10
Hello,
Maybe something like the following is what you want.
The code first creates a logical index of columns with at least one NA
or "NULL" (character string, not NULL) values. Then extracts only those
columns from the dataframe.
inx <- sapply(datos, function(x) any(x == "NULL" | is.na(x)))
Hi Paul,
Thanks for the reproducible data. You really only need to provide
enough to illustrate your question, but this works.
I suspect you have a data import problem - I doubt you really want so
many columns to be factors! Probably you need to specify that NULL
means something specific, rather
dear peter,
Its workingthanks a lot...
yours sincerely,
AKSHAY M KULKARNI
From: Peter Langfelder
Sent: Saturday, July 28, 2018 11:41 AM
To: akshay...@hotmail.com
Cc: r-help
Subject: Re: [R] subsetting ls() as per class...
Looking at ?rm
> objClasses <- unlist(eapply(.GlobalEnv, function(x)class(x)[1]))
> head(objClasses)
f E
"function" "environment"
df h
"tbl_df""function"
myData L
"list""list"
> names(objClasses)[objClasses=="tbl_df"]
[1]
The ll() function of R.oo returns a data.frame with various attributes that
you can subset on, e.g.
> subset(R.oo::ll(), data.class %in% c("zoo", "xts"))
member data.class dimension objectSize
2 fzzoo10 1344
4 sample.xtsxts c(180,4) 10128
5
You can extract the names into a character vector with ls and then use
grep(..., values=TRUE ) to select which ones you want to remove, and then pass
that list to rm.
However, due to the way R handles memory you are unlikely to see much savings
by doing this. I would recommend focusing on creat
Looking at ?rm, my solution would be something like
rm(list = grep("\\.NS$", ls(), value = TRUE))
But test it since I have not tested it.
Peter
On Fri, Jul 27, 2018 at 10:58 PM akshay kulkarni wrote:
>
> dear memebers,
>I am using R in AWS linux instance for my
The unlist solution is quite clever.
But I will note that none of the solutions offered so far succeed if the input
is, for example,
YH <- list(1:5, letters[1:3], 1:7)
iuhV <- c(2,2,4)
and the desire is to return a list whose elements are of the same types as the
input list. Which would
> On Jun 18, 2018, at 4:15 AM, akshay kulkarni wrote:
>
> correctionI want the method without a for loop
Here are two. The first is more readable, but the second is 5 times faster.
mapply("[", YH, iuhV)
unlist(YH, recursive = FALSE, use.names = FALSE)[cumsum( lengths(YH)) -
lengths(YH)
sapply( 1:length(YH), function(i) { YH[[i]][iuhV[i]]})
On Mon, Jun 18, 2018 at 1:55 PM, akshay kulkarni
wrote:
> dear members,
> I have list YH and index vector iuhV. I want
> to select iuhV[1] from YH[[1]], iuhv[2] from YH[[2]], iuhv[3] from
> YH[[3]]..iuhv[n] f
Hi Neha,
This might help:
R<-read.table(text="C1 C2 C3 C4
R1 0 1 0 1
R2 1 0 1 1
R3 1 0 0 0",
header=TRUE)
U<-read.table(text="C1 C2 C3 C4
U1 1 1 0 1
U2 1 1 1 1",
header=TRUE)
# these are matrices - I think this will work for dataframes as well
for(ui in 1:dim(U)[1]) {
for(ri in 1:dim(R)[1]) {
i
> On Mar 11, 2018, at 3:32 PM, Neha Aggarwal wrote:
>
> Hello All,
> I am facing a unique problem and am unable to find any help in R help pages
> or online. I will appreciate your help for the following problem:
> I have 2 data-frames, samples below and there is an expected output
>
> R Datafr
Responses inline.
On Sun, 11 Mar 2018, Neha Aggarwal wrote:
Hello All,
I am facing a unique problem and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output
R Dataframe1:
Thank you for the info. I did solve it using
unlist lapply strsplit functions.
On Wed, Feb 24, 2016 at 9:31 PM, Bert Gunter wrote:
> Have you gone through any R tutorials yet? I didn't entirely
> understand your question (and so cannot answer), but this sounds like
> a basic subsetting/data wr
A combination of subsetting and ?substr should get you close to a solution.
If the middle sequence you referenced isn't always the same distance from
the first character, you may have to involve regular expressions to find
"the middle".
On Wednesday, February 24, 2016, Bert Gunter wrote:
> Have
Have you gone through any R tutorials yet? I didn't entirely
understand your question (and so cannot answer), but this sounds like
a basic subsetting/data wrangling task that you should know how to do
if you have gone through a basic tutorial or two.
See also ?subset, ?"[" (basic indexing) and pos
tutorials so that you
understand how R works.
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah Goslee
Sent: Tue
It really isn't clear what you want, and posting in HTML has mangled
what you did provide.
Please use dput() to provide sample data, and give us a clear idea of
what you want, ideally an example of what the output should look like.
Adding the R code you've tried to use is also a good idea.
Sarah
HI Jean,
Here is part of my data. As you can see, I have cross-section point and
corresponding elevation of a river. Now I want to select cross-section
points by 50m interval. But the real cross-section data might not have
exact points say 0, 50, 100,…and so on. Therefore, I need to take points
> On Nov 9, 2015, at 9:19 AM, Adams, Jean wrote:
>
> Harun,
>
> Can you give a simple example?
>
> If your cross_section looked like this
> c(144, 179, 214, 39, 284, 109, 74, 4, 249)
> and your other vector looked like this
> c(0, 50, 100, 150, 200, 250, 300, 350)
> what would you want your su
Do you want the "closest" or what range it is in? If you want the range,
then use 'cut':
> x <- c(144, 179, 214, 39, 284, 109, 74, 4, 249)
> range <- c(0, 50, 100, 150, 200, 250, 300, 350)
> result <- cut(x, breaks = range)
> cbind(x, as.character(result))
x
[1,] "144" "(100,150]"
[2,] "1
Harun,
Can you give a simple example?
If your cross_section looked like this
c(144, 179, 214, 39, 284, 109, 74, 4, 249)
and your other vector looked like this
c(0, 50, 100, 150, 200, 250, 300, 350)
what would you want your subset to look like?
Jean
On Mon, Nov 9, 2015 at 7:26 AM, Harun Rashid v
I assume the solution is somewhat the same; you just have to define how to
determine what the "distinctive" names are to create the groupings. My
solution assumed it was the first character. If the group names end in a
unique sequence, you can use this to form the groups, or you can provide a
lis
Please learn to use dput() to post example data.
# This is your data:
data <- structure(c(1232, 0, 43, 357, 71, 919, 23, 9, , 0, 811, 0,
9871, 795, 76, 72, 743, 14), .Dim = c(3L, 6L), .Dimnames = list(
NULL, c("X1", "X2", "X3", "Y1", "Y2", "Y3")))
data
# define groups and threshold expl
sorry, for the misunderstanding. here is a more elaborate description of
what i would like to achieve.
I have a data set of counts from a RNA-Seq experiment and would like to
filter reads with low counts. I don't want to set everything to 0
automatically.
I would like to set each categorical grou
Is this what you want:
> x <- read.table(text = "X1X2X3Y1Y2Y3
+ 1232357230987172
+ 0719811795743
+ 4391907614", header = TRUE)
> x
X1 X2 X3 Y1 Y2 Y3
1 1232 357 23 0 9871 72
20 719 811 795
Lots of ways to do this, I use %in% with bracket notation [row, column].
The empty column argument below returns all columns but you could have
conditional logic there as well.
dd[dd$rows %in% test_rows, ]
On Mon, Jun 8, 2015 at 6:44 PM, Bogdan Tanasa wrote:
> Dear all,
>
> would appreciate y
Use is.element(elements,set), or its equivalent, elements %in% set:
df <- data.frame(dd = c(1, 2, 3),
rows = c("A1", "A2", "A3"),
columns = c("B1", "B2", "B3"),
numbers = c(400, 500, 600))
test_rows <-c("A1","A3")
df[ is.element(df$rows, test_rows
Assuming datums is a vector of the unique dates in Date... perhaps
datums <- sort(unique(dataset1$Date))
I usually set it up like this
for (i in 1:length(datums) ) {
crnt.date <- datums[i]
tmpdat <- subset(dataset1, Date==crnt.date)
cat(i, format(crnt.date), 'dim(tmpdat)',dim(tmpdat),'\n
Here is a self-contained example of what you might be trying to do.
You would get better answers if you supplied this yourself.
dataset1 <-
data.frame(Date=as.POSIXct(c("2015-04-01","2015-04-01","2015-04-07",
"2015-04-19")), Weight=11:14)
datums <- as.POSIXct(c("2015-04-01", "2015-04-08", "2015-04
Hi,
What about using functions like aggregate()?
Something like:
aggregate(Weight~datums, data=dataset1, FUN=mean)
If you need to do more things, you can create your own function for 'FUN'
HTH,
Ivan
--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplana
On Apr 28, 2015, at 12:20 PM, W Z wrote:
> I have a dataset of 20k records heavily right skewed as pareto
> distribution, I'd like to pull 1k subset of it with same distribution, any
> R package would do that?
Why not just:
subdat <- dat[sample( nrow(dat), 1000), ] # if "dataset" is a datafram
The elNamed(x, name) function can simplify this code a bit. The following
gives the same
result as David W's get_shas() for the sample dataset provided:
get_shas2 <- function (input) {
lapply(input, function(el) elNamed(elNamed(el, "content")[[1]],
"sha")[1])
}
Bill Dunlap
TIBCO Sof
On Feb 20, 2015, at 6:13 AM, Aron Lindberg wrote:
> Hmm…Chuck’s solution may actually be problematic because there are several
> entries which at the deepest level are called “sha”, but that should not be
> included, such as:
>
> input[[67]]$content[[1]]$commit$tree$sh
>
>
> and
>
> input[[
On Fri, 20 Feb 2015, Aron Lindberg wrote:
Hmm…Chuck’s solution may actually be problematic because there are several
entries which at the deepest level are called “sha”, but that should not be
included, such as:
input[[67]]$content[[1]]$commit$tree$sha
and
input[[67]]$content[[1]]
How can you expect a solution if you cannot specify the problem?
-- Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll
On Fri, Feb 20, 2015 at 6:13 AM, Aron Lindber
Hmm…Chuck’s solution may actually be problematic because there are several
entries which at the deepest level are called “sha”, but that should not be
included, such as:
input[[67]]$content[[1]]$commit$tree$sha
and
input[[67]]$content[[1]]$parents[[1]]$sha
it’s only the “sha” th
Thanks Chuck and Rolf.
While Rolf’s code also works on the dput that I actually gave you (a smaller
subset of the full dataset), it failed to work on the larger dataset, because
there are further exceptions:
input[[i]]$content[[1]] is sometimes a list, sometimes a character vector, and
Aron Lindberg case.edu> writes:
>
> Hi Everyone,
>
> I'm working on a thorny subsetting problem involving list of lists. I've put
> a
dput of the data here:
>
> https://gist.githubusercontent.com/aronlindberg/b916dee897d051ac5be5/
raw/a78cbf873a7e865c3173f943ff6309ea688c653b/dput
>
On 20/02/15 08:45, Aron Lindberg wrote:
Hi Everyone,
I'm working on a thorny subsetting problem involving list of lists.
If you think this is "thorny" you ain't seen nothin' yet!
But note that you've got a list of lists of lists ... i.e. the nesting
is at least 3 deep.
I've put a dput of
hi brennan, survey design objects can be subsetted with the same subset()
syntax as data.frame objects, so following jeff's advice maybe you want
svyglm( formula , design = subset( surveydesign , variable %in% c( 'value
a' , 'value b' ) ) )
for some examples of how to construct a survey design wi
This seems like a fundamental misunderstanding on your part of how operators,
and in particular logical expressions, work in computer languages. Consider
some examples:
1+2 has a numeric answer because 1 and 2 are both numeric.
1+"a" has at the very least not a numeric answer because the values
Your question is not clear to me.
> x$alpha[1:2]
[1] "a" "b"
> x$alpha[2]
[1] "b"
>
Is this what you are looking for? I hope this helps.
Chel Hee Lee
On 12/5/2014 11:12 AM, Dinesh Chowdhary wrote:
x <- list(seq = 3:7, alpha = c("a", "b", "c"))
x$alpha
[1] "a" "b" "c"
x["alpha"]
$alpha
[1
values.
hist(Out) # for a histogram of the correlation values
David C
From: Angela Boag [mailto:angela.b...@colorado.edu]
Sent: Friday, August 22, 2014 4:01 PM
To: David L Carlson
Subject: Re: [R] Subsetting data for split-sample validation, then repeating
1000x
Hi David,
Thanks for the f
You can use replicate() or a for (i in 1:1000){} loop to do your replications,
but you have other issues first.
1. You are sampling with replacement which makes no sense at all. Your 70%
sample will contain some observations multiple times and will use less than 70%
of the data most of the tim
Hi Monaly,
According to the description of ?tri2nb
The function uses the ‘deldir’ package to convert a matrix of
two-dimensional coordinates into a neighbours list of class ‘nb’
with a list of integer vectors containing neighbour region number
ids.
So, col.tri.nb is a list of leng
Hi Arun,
Thank you for your help, I have a few questions though if you don't mind.
I'm a bit confused about the following 2 lines of code:
col.tri.nb <- tri2nb(coords, row.names=ind)
lapply(col.tri.nb,function(x) ind[x])[1:5]
## from what I understand in the first line determines the neighbourin
Hi,
Sorry, there is a mistake. XO[2,] should be:
XO[2,] <- sapply(seq_along(col.tri.nb), function(i){ind1 <-
as.character(ind[i]); ind2 <- as.character(ind[col.tri.nb[[i]]]);
mean(abs(XO[1,ind1]-XO[1,ind2]))} )
A.K.
On Friday, May 23, 2014 12:56 PM, arun wrote:
Hi Monaly,
May be this hel
eb"), class = "data.frame", row.names = c(NA,
-99L))
#Code for tessellation
library(deldir)
ao= read.table("C:/Users/Monaly/Desktop/2012_malenest.txt", header=TRUE)
a29= deldir(ao$lat_xm, ao$long_ym)
a30=tile.list(a29)
plot(a30, close=TRUE, main="2012 Male Nest"
"latitude (m)",
ylab="longitude (m)", wpoints="real", verbose=FALSE,num=TRUE, rw=c(0, 1200,
0, 2000))
text(ao$lat_xm, ao$long_ym,col=c(2,1,4),labels=round(ao$NestkastNummer, 3),
pos=2, offset=0.2, cex=0.7) #this was to identify the points
On Fri, May 23, 2
])-XO[1,c("176","140","133","163")]))
> > > XO["avg", "15"]<- mean(abs((XO[1,"15"])-XO[1,c("16","19","14")]))
> > > XO["avg", "60"]<- mean(abs((XO[1,"60&qu
uot;,"97","90","84","82","81")]))
> > XO["avg", "31"]<- mean(abs((XO[1,"31"])-XO[1,c("2","3","36","35","34")]))
> > XO["avg", "73"]<- mean
quot;64"]<- mean(abs((XO[1,"64"])-XO[1,c("113","62","128","124")]))
> XO["avg", "74"]<- mean(abs((XO[1,"74"])-XO[1,c("51","73","185")]))
> XO["avg", "95"]<
XO["avg", "36"]<-
mean(abs((XO[1,"36"])-XO[1,c("28","38","86","709","707","35","3")]))
XO["avg", "80"]<- mean(abs((XO[1,"80"])-XO[1,c("42","79&quo
Follow the link at the bottom of this message!
-- Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch
On Thu, May 22, 2014 at 8:31 AM, Monaly Mistry wrote:
> Hi,
Hi,
Sorry I'm fairly new to R and I don't really understand using dput(), when
you say reproducible example do you mean the code with the output?
Best,
Monaly.
On Thu, May 22, 2014 at 4:03 PM, arun wrote:
> Hi,
>
> It would be helpful if you provide a reproducible example using ?dput().
>
>
t; -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Sneha Bishnoi
> Sent: Thursday, March 27, 2014 11:06 AM
> To: Sarah Goslee
> Cc: r-help
> Subject: Re: [R] Subsetting a dataframe by dynamic column name
>
> Hi Sara
e
Cc: r-help
Subject: Re: [R] Subsetting a dataframe by dynamic column name
Hi Sarah,
Thanks! Do agree its over complicated.
However looking at the solutions I think I did not state my
problem
completely.
V provides choices for only certain set of columns in Finaldata.
So v2 may not represent al
Hi Sarah,
Thanks! Do agree its over complicated.
However looking at the solutions I think I did not state my problem
completely.
V provides choices for only certain set of columns in Finaldata.
So v2 may not represent all columns of Finaldata.
I want to retain columns not provided as a choice for
There are many ways. You're making it overly complicated
Here, in an actual reproducible example (as you were requested to submit):
V <- data.frame(v1=c(1,0,0), v2=c("Shape", "Length", "Rate"),
stringsAsFactors=FALSE)
Finaldata <- data.frame(Shape = runif(5), Length = runif(5), Rate = runif(5))
On 14-03-10 10:47 AM, arun wrote:
Hi,
If 'dat' is the dataset:
Try
subset(dat, Start < MapInfo & End > MapInfo)
A bit of advice I think I read in The Elements of Programming Style:
try to make complex conjunctions look like their mathematical
equivalents, and they'll be easier to read. The
Hi,
If 'dat' is the dataset:
Try
subset(dat, Start < MapInfo & End > MapInfo)
A.K.
Dear All,
I want to subset a column (MapInfo in the attached photo) in csv
file if its values be ranged between values in two other columns (Start
and End in the attached photo) using R 3.0.1. Thank you in ad
fit is initialized as a vector of integers. How can you assign an mle
fit to an element of an integer vector?
Initialize fit as a list, use lapply, or whatever. Have you read An
Intro to R (ships with R) or other R (e.g. web) tutorial? This looks
like the sort of basic misunderstanding that one wh
Thanks so much Marc and for those that responded. Mark's suggestion with
droplevels gave me the desired result.
I'm new to figuring out how to post reproducible code. I'll try using the
set.seed and rnorm functions next time and hope that does the trick.
Thanks everyone!
On Tue, Jan 14, 2014 at
Here is a reproducible example of your problem where you do not
want to see a table entry for "Medium".
> tmp_df <- data.frame(Size=factor(rep(c("Small","Medium","Large"),1:3),
levels=c("Small","Medium","Large")))
> non_medium <- subset(tmp_df, Size != "Medium", select=Size)
> table(non_medi
On Jan 14, 2014, at 1:38 PM, Jeff Johnson wrote:
> I'm running the following to get what I would expect is a subset of
> countries that are not equal to "US" AND COUNTRY is not in one of my
> validcountries values.
>
> non_us <- subset(mydf, (COUNTRY %in% validcountries) & COUNTRY != "US",
> sel
Hi,
Try:
table(as.character(non_us[,"COUNTRY"]))
A.K.
On Tuesday, January 14, 2014 3:17 PM, Jeff Johnson
wrote:
I'm running the following to get what I would expect is a subset of
countries that are not equal to "US" AND COUNTRY is not in one of my
validcountries values.
non_us <- subset(myd
I figured it out:
dim(results[apply(results,1,sum)&TRUE,,])
#[1] 9 3 4
A.K.
On , arun wrote:
dim(results[,,apply(results,3,sum)&TRUE])
#[1] 10 3 4
dim(results[,,abs(apply(results,3,sum))>eps])
#[1] 10 3 4
dim(results2)
#[1] 9 3 4
A.K.
On Friday, January 10, 2014 12:56 AM, Bert Gunt
Just use apply() and indexing instead!
results[,,apply(results,3,sum)&TRUE]
## will do it.
However, note that numerical error may make a hash of this. So safer
would be something like:
eps <- 1e-15 ## i.e. something small
results[,,abs(apply(results,3,sum))>eps]
Cheers,
Bert
Bert Gunter
Gen
Hi Alex,
Try:
set.seed(345)
results<- array(sample(-5:5,120,replace=TRUE),dim=c(10,3,4))
indx <- !!apply(results,1,sum)
library(plyr)
results2 <- laply(lapply(seq(dim(results)[1]),function(i)
results[i,,])[indx],identity)
attr(results2,"dimnames") <- NULL
dim(results2)
#[1] 9 3 4
A.K.
I have
Hi
On 01/02/2014 04:04 PM, arun wrote:
Hi,
Try ?match
b[match(d,a)]
#[1] "Joe" "Bob" "Dick"
Or use 'a' to put names on 'b':
> names(b) <- a
> b
A B C D E
"Tom" "Dick" "Harry" "Bob" "Joe"
Then subset by names:
> b[d]
E D B
Hi,
Try ?match
b[match(d,a)]
#[1] "Joe" "Bob" "Dick"
A.K.
I have three vectors as follows:
> a <- c('A','B','C','D','E')
> b <- c('Tom','Dick','Harry','Bob','Joe')
> d <- c('E','D','B')
Subsetting b by using d on a, with b[a %in% d], gives the names in the order
they appear in b:
> b
Here is an approach using base R tools (not tested, so I hope I don't
embarrass myself!)
dayid <- format(data$TimeStamp, '%Y-%m-%d')
day.counts <- table(dayid)
good.days <- names(day.counts)[day.counts == 48]
subset(data, dayid %in% good.days)
This could be written in a one-liner, but it's much e
Hi,
May be this helps:
set.seed(45)
df1<-
data.frame(datetime=as.POSIXct("2011-05-25",tz="GMT")+0:200*30*60,value=sample(1:40,201,replace=TRUE),value2=
sample(45:90,201,replace=TRUE))
df2<- df1[ave(1:nrow(df1),as.Date(df1[,1]),FUN=length)==48,]
dim(df2)
#[1] 192 3
#or
library(plyr)
df3<-df
Hi Razi,
Using dat1:
dat1[apply(dat1[,2:4],1,function(x) any(x%in% vec1)),]
# ID diag1 diag2 diag3 proc1 proc2 proc3
#2 2 k69 i80 u456 z456 z123 z456
#3 3 l91 i801 g678 u456 u123 u123
#4 4 i80 i90 h983 z123 z456 z456
#similarly, if the columns are from 18:93, change ac
Hi,
Using the same example:
str1<-paste(colnames(dat1)[grepl("diag",colnames(dat1))],"%in%","vec1",collapse="|")
subset(dat1,eval(parse(text=str1)))
# ID diag1 diag2 diag3 proc1 proc2 proc3
#2 2 k69 i80 u456 z456 z123 z456
#3 3 l91 i801 g678 u456 u123 u123
#4 4 i80 i90 h983
Hi,
The expected output is not clear.
dat1<- read.table(text="ID diag1 diag2 diag3 proc1 proc2 proc3
1 k23 i269 j123 u123 u456 u123
2 k69 i80 u456 z456 z123 z456
3 l91 i801 g678 u456 u123 u123
4 i80 i90 h983 z123 z456 z456",sep="",header=TRUE,stringsAsFactors=FALSE)
vec1<- c("i80
row.names(carbon.fit),stringsAsFactors=FALSE)
#changed here
res1<-merge(dat1,carbon.fit1,by=c("x","y"))
row.names(res1)<- res1[,3]
res1<- res1[,-3]
A.K.
- Original Message -
From: William Dunlap
To: arun ; Shaun ♥ Anika
Cc: R help
Sent: Thursday, July 4, 2013 8:0
xt,y=yt), carbon.fit)
(You still want to round your numbers as before.)
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
> Behalf
> Of arun
> Sent: Wednesday, July 03, 201
Hi,
carbon.fit = expand.grid(list(x=seq(0, 5, 0.01), y=seq(0, 5, 0.01)))
dim(carbon.fit)
#[1] 251001 2
xtNew<-sprintf("%.2f",xt)
ytNew<- sprintf("%.2f",yt)
carbon.fit[]<- lapply(carbon.fit,function(x) sprintf("%.2f",x))
res<-do.call(rbind,lapply(seq_along(xtNew),function(i)
subset(carb
Hi,
Possibly, FAQ 7.31
Using the same example:
set.seed(24)
df<- data.frame(x=sample(seq(0.25,4.25,by=.05),1e5,replace=TRUE),y=
sample(seq(0.10,1.05,by=.05),1e5,replace=TRUE),z=rnorm(1e5))
dfOld<- df
df[,1:2]<- lapply(df[,1:2],function(x) sprintf("%.2f",x))
x1<- c(1.05,2.85,3.40,4.25,0.25)
y1<-
Hi,
Try this:
set.seed(24)
df<- data.frame(x=sample(seq(0.25,4.25,by=.05),1e5,replace=TRUE),y=
sample(seq(0.10,1.05,by=.05),1e5,replace=TRUE),z=rnorm(1e5))
#Used a shorter vector
x1<- c(1.05,2.85,3.40,4.25,0.25)
y1<- c(0.25,0.10,0.90,0.25,1.05)
res<-do.call(rbind,lapply(seq_along(x1),function
Daniel,
You need "==" instead of "=".
HTH,
Jorge.-
Sent from my phone. Please excuse my brevity and misspelling.
On Jun 6, 2013, at 10:36 AM, Daniel Tucker wrote:
> Also tried this but results werent any different
>
> subset1<- subset(dframe, glb_ind="Y" | sample==1 | !is.na(glb_ind))
> subset2
Also tried this but results werent any different
subset1<- subset(dframe, glb_ind="Y" | sample==1 | !is.na(glb_ind))
subset2<-subset(dframe, cwar_ind="Y" |sample==2 | !is.na(cwar_ind))
subset3<-subset(dframe, reg_ind="Y" | sample==3 | !is.na(reg_ind))
On Wed, Jun 5, 2013 at 9:33 AM, Daniel Tucke
The problem might be that "NAs" in the dataset are blank
On Wed, Jun 5, 2013 at 9:54 AM, Daniel Tucker wrote:
> Also tried this but results werent any different
>
> subset1<- subset(dframe, glb_ind="Y" | sample==1 | !is.na(glb_ind))
> subset2<-subset(dframe, cwar_ind="Y" |sample==2 | !is.na(cwar
http://r.789695.n4.nabble.com/as-vector-with-mode-quot-list-quot-and-POSIXct-td4667533.html
Interesting but I fail to see the connection to this instance other than R
behaving somewhat differently than we might at one time have expected.
--
David.
>
> A.K.
>
> - Original Mess
.
- Original Message -
From: Denis Chabot
To: arun
Cc: R help
Sent: Thursday, May 23, 2013 10:06 PM
Subject: Re: [R] subsetting and Dates
Thank you for the 2 methods to make the columns class Date, but I would really
like to know why these variables were not in Date class with my code
On May 23, 2013, at 7:06 PM, Denis Chabot wrote:
> Thank you for the 2 methods to make the columns class Date, but I would
> really like to know why these variables were not in Date class with my code.
> Do you know?
I suspect that the problem lies in the dispatch to `[<-.` or `$<-`. When
the
Thank you for the 2 methods to make the columns class Date, but I would really
like to know why these variables were not in Date class with my code. Do you
know?
Denis
Le 2013-05-23 à 21:44, arun a écrit :
> You could convert those columns to "Date" class by:
>
>
> Data[,c(4,6)]<-lapply(Da
You could convert those columns to "Date" class by:
Data[,c(4,6)]<-lapply(Data[,c(4,6)],as.Date,origin="1970-01-01")
#or
Data[,c(4,6)]<-lapply(Data[,c(4,6)],function(x) structure(x,class="Date"))
# dat1 dat2 Dat1a Dat1b Dat2a Dat2b
#1 41327 41327 2013-02-22 2013-02-22 201
Without a reproducible example it's hard to say for certain, but I
imagine you want
buybdge != badge
or
!(buybdge == badge)
Note that ?"==" (the help for == ) would have told you that.
Sarah
On Thu, May 9, 2013 at 4:05 PM, ramoss wrote:
> Hello,
>
> I have a simple question:
>
> I know how to s
I want to clarify we are talking about 2 variables in a datframe here.
--
View this message in context:
http://r.789695.n4.nabble.com/subsetting-by-is-not-tp4666706p4666707.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-pro
Hello,
Em 09-05-2013 20:44, Sarah Goslee escreveu:
Hi,
On Thu, May 9, 2013 at 12:28 PM, KatrinH Heimann
wrote:
Dear all,
I would like to subset a dataframe using multiple conditions.
So if I have two columns 1 and 2, I would like to EXCLUDE all rows in which
the value of column 1 is "a" AND t
Hello,
It's difficult to know what's going on without a data example. Can you
post the output of
dput(head(data, 30))
?
Maybe the columns are not of class "character" but of class "factor".
You should also post the output of
str(data)
In the mean time, try
subset(data, column1 != "a" &
Hi,
On Thu, May 9, 2013 at 12:28 PM, KatrinH Heimann
wrote:
> Dear all,
> I would like to subset a dataframe using multiple conditions.
> So if I have two columns 1 and 2, I would like to EXCLUDE all rows in which
> the value of column 1 is "a" AND the value of column 2 is "b".
> I tried data[(da
Hi Janesh,
This is a bit shorter:
library(seqinr)
sapply(split(as.numeric(s2c(x)),((seq(nchar(x))-1)%/%5)+1),prod)
A.K.
- Original Message -
From: arun
To: Janesh Devkota
Cc: R help
Sent: Thursday, April 18, 2013 8:55 AM
Subject: Re: [R] Subsetting a large number into smaller
Hi,
You could also use:
x <-
"73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557"
sapply(strsplit(substring(x,seq(1,nchar(x)-4,5),seq(5,nchar(x),5
Hi.
Here is one approach:
options(scipen=300)
numb <-
73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557
strsplit(as.character(numb), "")
blocks <-
Dear Janesh,
Here is one way:
# note "x" is a character
x <-
"73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557"
k <- nchar(x) # digits in x
b <
1 - 100 of 321 matches
Mail list logo