Displaying 20 results from an estimated 10000 matches similar to: "search and replace"
2012 Oct 16
2
List of Levels for all Factor variables
Hi,
I want to get a clean succinct list of all levels for all my factor variables.
I have a dataframe that's something like #1 below. This is just an example subset of my data and my actual dataset has 70 variables. I know how to narrow down my list of variables to just my factor variables by using #2 below (thanks to Bert Gunter). I can also get list of all levels for all my factor
2013 Sep 09
1
windowing
Is there a package or a command that does window aggregation like
select
sum(col1) over
(partition by col2, col3 order by col4
rows between unbounded preceding and current row) as sum1
from table1 ;
the above is Netezza syntax, but Postgre has same capability.
Stephen B
[[alternative HTML version deleted]]
2018 May 08
2
Dinamic variables in loop
Hello,
I am a newbie in R and I have a problem.
I want this line:
newMyData <-MyData[!(is.na(col1)) | !(is.na(col2)) | !(is.na(col3)) | !(
is.na(col4)) | !(is.na(col5)),]
write in for loop. The number of col[number] may be different from 3 to 8
Is there any ideas?
Thank you
Laura
[[alternative HTML version deleted]]
2013 Sep 15
1
Data labels in R
I need to put labels in plot in R. Can someone please help? The labels are
in the excel file and loaded into "lables"
library(xlsx)
library(zoo)
fPTAnalysis<-"Input.xls"
data<-read.xlsx(fPTAnalysis,9)
lables<-subset(data, select=c(Labels))
data<-subset(data, select=c(Date,col1, col2 ))
data<-read.zoo(data)
plot(data)
--
Regards,
Ankur Seth
[[alternative
2018 May 08
0
Dinamic variables in loop
Dear Laura,
It looks like you want to remove all rows for which each column is NA.
You can to that with the code below.
na.matrix <- is.na(MyData)
all.na.row <- apply(na.matrix, 1, all)
MyData[!all.na.row, ]
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
AND
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
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)
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
2004 Jul 05
2
More difficulties in getting data into R
In order to get around the problems of my posting a few minutes ago, I
thought:
$ awk -F\| '(NR > 2) {print $2}' cmie_firm_data.text > col2
$ awk -F\| '(NR > 2) {print $4}' cmie_firm_data.text > col4
$ paste col2 col4 | head -2
-510.45 -510.27
60700 101900
$ paste col2 col4 | tail -2
28648.12 31617.02
491014.77 494308.52
$ wc -l col2 col4
89323 col2
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
2010 Mar 22
1
help needed with boxplot
I am new to R, can anyone help with boxplot for a dataset like:
file1 col1 col2 col3 col4 col5
050350005 101 56.625 48.318 RED
051010002 106 50.625 46.990 GREEN
051190007 25 65.875 74.545 BLUE
051191002 246 52.875 57.070 RED
220050004 55 70 80.274 BLUE
220150008 75 67.750 62.749 RED
220170001 77 65.750 54.307 GREEN
file2
col1 col2 col3 col4 col5
050350005 101 56.625 57 RED
051010002 106 50.625 77
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)
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
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
2017 Jun 21
4
selecting dataframe columns based on substring of col name(s)
Suppose I have the following sort of dataframe, where each column name
has a common structure: prefix, followed by a number (for this example,
col1, col2, col3 and col4):
d = data.frame( col1=runif(10), col2=runif(10),
col3=runif(10),col4=runif(10))
What I haven't been able to suss out is how to efficiently
'extract/manipulate/play with' columns from the data frame, making use