There is an interesting item on stringsAsFactors in this useR! 2020 session:
https://www.youtube.com/watch?v=X_eDHNVceCU=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:
>>
>> Dear
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=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
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 <-
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)
...@r-project.org] On Behalf Of Borja
Rivier
Sent: Wednesday, July 24, 2013 8:25 AM
To: r-help@r-project.org
Subject: [R] Levels of a factor
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
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 -
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 elements, and when
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 factor.
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 elements, some
-project.org
Subject: [R] Levels of a factor
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
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
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 factor
Hi R
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:
Thanks for clarifying!
On Thu, Jan 10, 2013 at 12:47 PM, Uwe Ligges
lig...@statistik.tu-dortmund.de 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
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(x
analyst41 at hotmail.com analyst41 at 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:
On May 25, 4:46 am, Stefan ste...@inizio.se wrote:
analyst41 at hotmail.com analyst41 at 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
On May 25, 7:23 am, analys...@hotmail.com analys...@hotmail.com
wrote:
On May 25, 4:46 am, Stefan ste...@inizio.se wrote:
analyst41 at hotmail.com analyst41 at hotmail.com writes:
I have a data set that has some comma separated strings in each row.
I'd like to create a vector
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
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
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,
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
s - subset(m,
Hi Ulrik
On Sat, Sep 4, 2010 at 12:52 PM, Ulrik Stervbo ulrik.ster...@gmail.com 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
-
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,
When I subset a data.frame, the levels are not re
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.sub$X1)
# still gives
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 7:50 AM, Antje [EMAIL PROTECTED] wrote:
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 levels
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) - c(X1,X2,X3)
my.sub
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.sub$X1[drop=TRUE]
a lot more
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,5,6,7,8),
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.sub$X1)
# still
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 not
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 levels (that is, without the brackets
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)
hist()
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:
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
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
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
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 R community, I wish to ask a short question
concerning factor-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't know
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
44 matches
Mail list logo