There is an interesting item on stringsAsFactors in this useR! 2020 session:
https://www.youtube.com/watch?v=X_eDHNVceCU&feature=youtu.be
It's about 27 minutes in.
Chris Gordon-Smith
On 15/07/2020 17:16, Marc Schwartz via R-help wrote:
>> On Jul 15, 2020, at 4:31 AM, andy elprama wrote:
>>
>>
Thanks, I will check it out.
Op za 18 jul. 2020 om 00:47 schreef Chris Gordon-Smith <
c.gordonsm...@gmail.com>:
> There is an interesting item on stringsAsFactors in this useR! 2020
> session:
>
> https://www.youtube.com/watch?v=X_eDHNVceCU&feature=youtu.be
>
> It's about 27 minutes in.
>
> Chris
Hi Andy:
I just checked in "options", and the following appears:
$stringsAsFactors
[1] FALSE
I think this might be it.
You may want to look at options() in R-3.6.1.
Thanks,
Erin
Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com
On Wed, Jul 15, 2020 at 9:45 AM andy elprama wrote:
>
> On Jul 15, 2020, at 4:31 AM, andy elprama wrote:
>
> Dear R-users,
>
> Something strange happened within the command "levels"
>
> R version 3.6.1
> name <- c("a","b","c")
> values <- c(1,2,3)
> data <- data.frame(name,values)
> levels(data$name)
> [1] "a" "b" "c"
>
> R version 4.0
> name <
Read the NEWS about R4.0.0 [1] (search for stringsAsFactors), or read any of
the many announcements in blogs and forums around the Internet.
[1] https://cran.r-project.org/doc/manuals/r-release/NEWS.html
On July 15, 2020 1:31:06 AM PDT, andy elprama wrote:
>Dear R-users,
>
>Something strange ha
Hi Andy,
I believe this is because R 4.0 has changed the default behavior of
data.frame().
Prior to 4.0, the default was stringsAsFactors=TRUE.
In 4.0, the default is stringsAsFactors=FALSE.
If you run your code in R 3.6.1 and change the command to
data <- data.frame(name,values,stringsAsFactors=
Dear R-users,
Something strange happened within the command "levels"
R version 3.6.1
name <- c("a","b","c")
values <- c(1,2,3)
data <- data.frame(name,values)
levels(data$name)
[1] "a" "b" "c"
R version 4.0
name <- c("a","b","c")
values <- c(1,2,3)
data <- data.frame(name,values)
levels(data$nam
D" "F" "G" "H" "J" "K" "L" "M" "N" "O" "P" "Q"
> "R" "S" "T" "V" "X"
> # [20] "Y" "Z"
>
> There are times wh
; "P" "Q"
"R" "S" "T" "V" "X"
# [20] "Y" "Z"
There are times when you want to know if certain factor levels
do not appear in a subset of the original data.
-
David L Carls
On Jul 24, 2013, at 11:35 AM, David Winsemius wrote:
>
> On Jul 24, 2013, at 6:25 AM, Borja Rivier wrote:
>
>> Hi all,
>>
>> I am having a bit of trouble using the levels() function.
>> I have a factor with many elements, and when I use the function levels() to
>> extract the list of unique el
On Jul 24, 2013, at 6:25 AM, Borja Rivier wrote:
> Hi all,
>
> I am having a bit of trouble using the levels() function.
> I have a factor with many elements, and when I use the function levels() to
> extract the list of unique elements, some of the elements returned are not
> actually in the fa
Hi,
vec1<- factor(1:5,levels=1:10)
vec1
#[1] 1 2 3 4 5
#Levels: 1 2 3 4 5 6 7 8 9 10
vec2<-droplevels(vec1)
levels(vec2)
#[1] "1" "2" "3" "4" "5"
vec2
#[1] 1 2 3 4 5
#Levels: 1 2 3 4 5
A.K.
Hi all,
I am having a bit of trouble using the levels() function.
I have a factor with many element
Hi all,
I am having a bit of trouble using the levels() function.
I have a factor with many elements, and when I use the function levels() to
extract the list of unique elements, some of the elements returned are not
actually in the factor.
For example I would have this:
> vector <- dataset$Benc
Perhaps write.dta(..., convert.factors="string") might help.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of chong shiauyun
Sent: Mittwoch, 10. April 2013 10:01
To: r-help@r-project.org
Subject: [R] Levels and labels in fa
Hi R users, I have a imputed dataset of undefinedundefined cycles which I
generated using StAta version undefinedundefined. Then I imported my data from
Stata into R and I used a loop to run Mclust package in R. My observation
starts with ID=2 (ID=1 has been excluded from the sample) and ends wi
Thanks for clarifying!
On Thu, Jan 10, 2013 at 12:47 PM, Uwe Ligges
wrote:
>
>
> On 08.01.2013 21:14, Claus O'Rourke wrote:
>>
>> Hi all,
>> I've encountered an issue using svm (e1071) in the specific case of
>> supplying new data which may not have the full range of levels that
>> were present i
On 08.01.2013 21:14, Claus O'Rourke wrote:
Hi all,
I've encountered an issue using svm (e1071) in the specific case of
supplying new data which may not have the full range of levels that
were present in the training data.
I've constructed this really primitive example to illustrate the point:
Hi all,
I've encountered an issue using svm (e1071) in the specific case of
supplying new data which may not have the full range of levels that
were present in the training data.
I've constructed this really primitive example to illustrate the point:
> library(e1071)
> training.data <- data.frame
On May 25, 7:23 am, "analys...@hotmail.com"
wrote:
> On May 25, 4:46 am, Stefan wrote:
>
>
>
>
>
> > analyst41 hotmail.com hotmail.com> writes:
>
> > > I have a data set that has some comma separated strings in each row.
> > > I'd like to create a vector consisting of all distinct strings tha
On May 25, 4:46 am, Stefan wrote:
> analyst41 hotmail.com hotmail.com> writes:
>
>
>
> > I have a data set that has some comma separated strings in each row.
> > I'd like to create a vector consisting of all distinct strings that
> > occur. The number of strings in each row may vary.
>
> > Th
analyst41 hotmail.com hotmail.com> writes:
>
> I have a data set that has some comma separated strings in each row.
> I'd like to create a vector consisting of all distinct strings that
> occur. The number of strings in each row may vary.
>
> Thanks for any help.
>
>
#
#
# Some data:
d <- d
I have a data set that has some comma separated strings in each row.
I'd like to create a vector consisting of all distinct strings that
occur. The number of strings in each row may vary.
Thanks for any help.
__
R-help@r-project.org mailing list
https:
Hello everyone,
I have been working on a model to describe the counts of a certain event. I
use glm function with Poisson family and log link. the model is:
model<-glm(event~week+year+week:var1+year:var1+year:var2, family=poisson),
where week and season are factor variables with 52 and 7 leve
Thanks for the replies! Obviously I must have used to wrong search
terms - sorry.
@greg: I care about the levels after the subset, because if they are
not dropped, then they still appear in the subsequent heatmap I make
with ggplot (with my read data-set of course). Admittedly I am quite
green, a
ginal Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Ulrik Stervbo
> Sent: Saturday, September 04, 2010 6:53 AM
> To: r-help@r-project.org
> Subject: [R] Levels in returned data.frame after subset
>
> Dear List,
>
>
Hi Ulrik
On Sat, Sep 4, 2010 at 12:52 PM, Ulrik Stervbo wrote:
> Dear List,
>
> When I subset a data.frame, the levels are not re-adjusted (see
> example). Why is this? Am I missing out on some basic stuff here?
Only that this issue has come up many times before, and that this list
is archived a
Dear List,
When I subset a data.frame, the levels are not re-adjusted (see
example). Why is this? Am I missing out on some basic stuff here?
Thanks
Ulrik
> m <- data.frame(gender = c("M", "M","F"), ht = c(172, 186.5, 165), wt =
> c(91,99, 74))
> dim(m)
[1] 3 3
> levels(m$gender)
[1] "F" "M"
> I hope this question is not too stupid. I would like to know how to
update
> levels after subsetting data from a data.frame.
>
> df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8),
c(9,1,2,3,4))
> names(df) <- c("X1","X2","X3")
>
> my.sub <- subset(df, X1 == "a" | X1 == "b")
> lev
Thanks a lot!!!
the "drop" thing was exactly what I was looking for (I already used it some
time ago but forgot about it).
Thanks to everybody else too.
Antje
Prof Brian Ripley schrieb:
On Fri, 5 Dec 2008, jim holtman wrote:
try this:
df <- data.frame(factor(c("a","a","c","b","b")), c(4,
On Fri, 5 Dec 2008, jim holtman wrote:
try this:
df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8), c(9,1,2,3,4))
names(df) <- c("X1","X2","X3")
my.sub <- subset(df, X1 == "a" | X1 == "b")
levels(my.sub$X1)
[1] "a" "b" "c"
my.sub$X1 <- factor(my.sub$X1)
I find
my.sub$X1 <- my
On Fri, Dec 5, 2008 at 6:50 AM, Antje <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I hope this question is not too stupid. I would like to know how to update
> levels after subsetting data from a data.frame.
>
> df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8), c(9,1,2,3,4))
> names(df) <-
I do the following for a subsetted dataframe:
cleanfactors <- function(mydf){
outdf<-mydf
for (i in 1:dim(mydf)[2]){
if (is.factor(mydf[,i]))
outdf[,i]<-factor(mydf[,i])
}
outdf
}
Antje wrote:
> Hello,
>
> I hope this question is not too stupid. I would like to know how to
> update
try this:
> df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8), c(9,1,2,3,4))
> names(df) <- c("X1","X2","X3")
>
> my.sub <- subset(df, X1 == "a" | X1 == "b")
> levels(my.sub$X1)
[1] "a" "b" "c"
> my.sub$X1 <- factor(my.sub$X1)
> levels(my.sub$X1)
[1] "a" "b"
>
On Fri, Dec 5, 2008 at
Hello,
I hope this question is not too stupid. I would like to know how to update
levels after subsetting data from a data.frame.
df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8), c(9,1,2,3,4))
names(df) <- c("X1","X2","X3")
my.sub <- subset(df, X1 == "a" | X1 == "b")
levels(my.s
On Sat, 9 Aug 2008, baptiste auguie wrote:
Thank you all for the precious tips. For memory I've made the following
wrapper function for this. I wonder whether a short note on these regular
expressions could be useful on the help page of cut().
Already there in R-devel
cutIntervals <
Thank you all for the precious tips. For memory I've made the
following wrapper function for this. I wonder whether a short note on
these regular expressions could be useful on the help page of cut().
cutIntervals <- function(x, ...){
dotArgs <- unlist(c(...))
if( any(names(dotArgs
On Sat, 9 Aug 2008, baptiste auguie wrote:
Dear list,
I have the following example, from which I am hoping to retrieve numeric
values of the factor levels (that is, without the brackets):
x <- seq(1, 15, length=100)
y <- sin(x)
my.cuts <- cut(which(abs(y) < 1e-1), 3)
levels(my.cuts)
his
3.1
- Original Message
From: baptiste auguie <[EMAIL PROTECTED]>
To: r-help@r-project.org
Sent: Saturday, August 9, 2008 1:51:01 AM
Subject: [R] levels values of cut()
Dear list,
I have the following example, from which I am hoping to retrieve
numeric values of the factor l
Dear list,
I have the following example, from which I am hoping to retrieve
numeric values of the factor levels (that is, without the brackets):
x <- seq(1, 15, length=100)
y <- sin(x)
my.cuts <- cut(which(abs(y) < 1e-1), 3)
levels(my.cuts)
hist() does not suit me for this, as it does n
Gundala Viswanath gmail.com> writes:
>
> Hi all,
>
> After running this code (attaches is the input file):
>
> dat <- read.table("gene_prob.txt", sep = "\t")
> n <- length(dat$V1)
> print(n)
> print(dat$V1)
>
> I get this print out.
>
> ..
> [8541] LOC552889 GPR15 SLC2A11
Hi all,
After running this code:
__BEGIN__
dat <- read.table("gene_prob.txt", sep = "\t")
n <- length(dat$V1)
print(n)
print(dat$V1)
__END__
With this input in "gene_prob.txt"
__INPUT__
HFE 0.00107517988586552
NF1 0.000744355305599206
PML 0.000661649160532628
TCF30.000661649160532628
NF2 0.
) # now it is gone
B C D
1 1 1
HTH
Peter Alspach
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Georg Ehret
> Sent: Wednesday, 23 April 2008 8:58 a.m.
> To: r-help
> Subject: [R] levels in dataframes
>
> Dear
Dear R community, I wish to ask a short question concerning factor-data
in dataframes: When I subset the data and get rid of all data for one level,
I still retain the level name (obtained by levels(dataframe$variablename) ).
Is there a convenient way to get rid of the levels for which all data
Karen
levels returns the levels attribute of a variable, and a vector has no
such attribute. This is usually used with a factor, e.g.
> temp <- c(3, 5, 5, NA)
> levels(factor(temp))
[1] "3" "5"
Best wishes
Richard
Chang Liu wrote:
> Hello:
>
> I'm trying to use levels function, but I don
Hello:
I'm trying to use levels function, but I don't know why it's returning NULL.
For example:
> temp[1] 3 5 5 NA> levels(temp)NULL>
Also, I've tried:
> list(temp)[[1]][1] "3" "5" "5" NA
> levels(list(temp))NULL
Is there a specific requirement on the parameter?
Karen
45 matches
Mail list logo