Displaying 20 results from an estimated 4000 matches similar to: "complex splits"
2002 Jul 03
2
operating on a subset of a dataframe
Hi everyone,
I've got a dataframe with columns of different types. A certain number
of columns in the dataframe hold the results of a series of Likert-type
items. I've got a function that will print a simple table of frequencies
and I want to apply that function to those columns of the dataframe
only. What's the best approach?
-Tim
--
Tim Wilson | Visit Sibley online: |
2011 Mar 16
3
making dataframes
Dear all,
I have a dataframe which looks like this (dummy):
date<-c("jan", "feb", "mar", "apr", "may", "june", "july",
"aug","sep","oct","nov","dec")
col1<-c(8.2,5.4,4.3,4.1,3.1,2.5,1.1,4.5,3.2,1.9,7.8,6.5)
col2<-c(3.1,2.3,4.7,6.9,7.5,1.1,3.6,8.5,7.5,2.5,4.1,2.3)
2006 Mar 16
3
Did I use "step" function correctly? (Is R's step() function reliable?)
Hi all,
I put up an exhaustive model to use R's "step" function:
------------------------
mygam=gam(col1 ~ 1
+ col2 + col3 + col4
+ col2 ^ 2 + col3 ^ 2 + col4 ^ 2
+ col2 ^ 3 + col3 ^ 3 + col4 ^ 3
+ s(col2, 1) + s(col3, 1) + s(col4, 1)
+ s(col2, 2) + s(col3, 2) + s(col4, 2)
+ s(col2, 3) + s(col3, 3) + s(col4, 3)
+ s(col2, 4) + s(col3, 4) + s(col4, 4)
+ s(col2, 5) + s(col3,
2017 Aug 23
0
Comparing 2 dale columns
Patrick,
## Run the following script an notice the different values of the dataframe "data" in each instance.
# I understand you have done something like the following:
data <- data.frame(COL1 = c("6/1/14", "7/1/14"),
COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE)
data$Date_Flag <- ifelse(data$COL2 >
2018 Feb 25
0
include
Hi Val,
My fault - I assumed that the NA would be first in the result produced
by "unique":
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
val23<-unique(unlist(mydat[,c("Col2","col3")]))
napos<-which(is.na(val23))
preval<-data.frame(Col1=val23[-napos],
2018 Feb 25
2
include
HI Jim and all,
I want to put one more condition. Include col2 and col3 if they are not
in col1.
Here is the data
mydat <- read.table(textConnection("Col1 Col2 col3
K2 X1 NA
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
The desired out put would be
Col1 Col2 col3
1 X1 0 0
2 K1 0 0
3 Y1 0 0
4 W1 0 0
6 K2 X1
2018 Feb 25
3
include
Thank you Jim,
I read the data as you suggested but I could not find K1 in col1.
rbind(preval,mydat) Col1 Col2 col3
1 <NA> <NA> <NA>
2 X1 <NA> <NA>
3 Y1 <NA> <NA>
4 K2 <NA> <NA>
5 W1 <NA> <NA>
6 Z1 K1 K2
7 Z2 <NA> <NA>
8 Z3 X1 <NA>
9 Z4 Y1 W1
On Sat, Feb 24, 2018 at 6:18 PM, Jim
2018 Feb 25
2
include
Sorry , I hit the send key accidentally here is my complete message.
Thank you Jim and all, I got it.
I have one more question on the original question
What does this "[-1] " do?
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2
2018 Feb 25
0
include
Jim has been exceedingly patient (and may well continue to be so), but this smells like "failure to launch". At what point will you start showing your (failed) attempts at solving your own problems so we can help you work on your specific weaknesses and become self-sufficient?
--
Sent from my phone. Please excuse my brevity.
On February 25, 2018 7:55:55 AM PST, Val <valkremk at
2018 Feb 25
0
include
hi Val,
Your problem seems to be that the data are read in as a factor. The
simplest way I can think of to get around this is:
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
rbind(preval,mydat)
2005 Oct 07
2
finding missing lines...
Take this as an example:
> a=data.frame(col1=c(1,2,3,4,5), col2=c
("my","beloved","daughter","son","wife"))
> b=data.frame(col1=c(1,2,4),
col2=c("my","beloved","son"))
> a
col1 col2
1 1 my
2
2 beloved
3 3 daughter
4 4 son
5 5 wife
> b
col1 col2
1 1 my
2
2006 Mar 06
1
Sort problem in merge()
Hello!
I am merging two datasets and I have encountered a problem with sort.
Can someone please point me to my error. Here is the example.
## I have dataframes, first one with factor and second one with factor
## and integer
> tmp1 <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0")))
> tmp2 <- data.frame(col1 =
2017 Aug 23
2
Comparing 2 dale columns
Thanks. But when I apply your codes I get all NA instead of TRUE and FALSE
________________________________
From: PIKAL Petr <petr.pikal at precheza.cz>
Sent: Wednesday, August 23, 2017 11:20:00 AM
To: Patrick Casimir; r-help at r-project.org
Subject: RE: Comparing 2 dale columns
Hi
your code is wrong.
I get
> test<-read.table("clipboard", header=T)
> str(test)
2010 May 13
1
merge for data.frame and matrix
Hello,
how to merge a data.frame and a matrix by one column in the data.frame and rownames of the matrix?
df <- data.frame(col1=c("kk","yy","kk"),col2=c(6,4,3))
> df
col1 col2
1 kk 6
2 yy 4
3 kk 3
m<-matrix(c(3,8,56,9), nrow=2, dimnames = list(c("aa","kk"),c("col1","col2")))
> m
col1 col2
aa
2018 Feb 24
0
include
Thank you Jim and all, I got it.
I have one more question on the original question
What does this "[-1] " do?
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE)
2012 Aug 13
4
if else elseif for data frames
Hi all,
It seems like I cannot use normal 'if' for data frames. What would be the
best way to do the following.
if data$col1='high'
data$col2='H'
else if data$col1='Neutral'
data$col2='N'
else if data$col='low'
data$col2='L'
else
#chuch a warning?
Note that col2 was not an existing column and was newly assigned for this
2002 Jul 26
3
Fisher r-to-z transformation
Hi everyone,
I want to use the Fisher r-to-z transformation as part of a hypothesis
test of r. I can't find an R function that can do that. Am I missing
it?
-Tim
--
Tim Wilson | Visit Sibley online: | Check out:
Henry Sibley HS | http://www.isd197.org | http://www.zope.com
W. St. Paul, MN | | http://slashdot.org
wilson at visi.com | <dtml-var
2010 Jul 24
2
union data in column
Is there any function/way to merge/unite the following data
GENEID col1 col2 col3 col4
G234064 1 0 0 0
G234064 1 0 0 0
G234064 1 0 0 0
G234064 0 1
2011 Jun 03
2
modify a data frame by values in the columns
I have a data frame like this:
col1 col2
r1 2 1
r2 4 3
r3 6 5
r4 8 7
r5 10 9
r6 12 11
r7 14 13
r8 16 15
r9 18 17
r10 20 19
I want to modify this data frame, for example, assign every row in column
col1 and col2 to -1 if the values in col1 is less than 12 and values in col2
is greater than 10. The result should look like this:
col1
2017 Aug 23
2
Comparing 2 dale columns
Dear R fellows,
I created a new column Date_flag to compare the dates of COL1 and COL2 using the code
below. But it showed that 5/1/15 is greater than 6/1/2014 and 5/1/2015 greater than
7/1/2014 despite the year is greater. How do I fix that? I did try to format as %y/%m/%d
but it does not fix that.
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
COL1 COL2
6/1/14