Re: [R] How to create a data set from object/data frame?

2019-07-20 Thread Richard O'Keefe
No, read.table() *isn't* about printing. If you have data stored as text in a tabular format, you use read.data, read.csv, read.csv2, read.delim, or read.delim2 to read it. This returns a new data frame. Example: > x <- read.table(textConnection(c( + "A B", + "1 2", + "3 4")), TRUE) > x A B 1

Re: [R] How to create a data set from object/data frame?

2019-07-20 Thread Richard O'Keefe
I'm having a little trouble believing what I'm seeing. To the best of my knowledge, sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), + stat=rep(c('cancer' , 'healthy'), each=4)) is not legal R syntax, and R 3.6.1 agrees with me Error: unexpected '=' in "x <- data.frame(+ spl=" Then I see

Re: [R] List of tables needed

2019-07-20 Thread David Winsemius
On 7/20/19 5:17 PM, Jackson Rodrigues wrote: Dear all, My name is Jackson and I need a help in applying functions to a list of tables. Could anyone help me to use loop/array on a list of tables ? I need to apply a group of functions (listed below) to a list of tables I am not that good wi

Re: [R] List of tables needed

2019-07-20 Thread Bert Gunter
?lapply See also the"Intro to R" tutorial that ships with R. We(or at least I) expect you to do your own homework learning basic R before posting here. This is not a substitute for such efforts, but we are willing to help when you get stuck. See the posting guide linked below and show us your own

Re: [R] Capturing positive and negative changes using R

2019-07-20 Thread Richard O'Keefe
If "Fardadj was expecting R to recognise the comma as the decimal" then it might be worth mentioning the 'dec = "."' argument of read.table and its friends. On Sun, 21 Jul 2019 at 12:48, Jeff Newmiller wrote: > It is possible that part of the original problem was that Fardadj was > expecting R

Re: [R] Capturing positive and negative changes using R

2019-07-20 Thread Jeff Newmiller
It is possible that part of the original problem was that Fardadj was expecting R to recognise the comma as the decimal and he read in that column as a factor without realizing it. Factors are discrete, not continuous. He should use the str() function to identify the column types in his data fra

[R] List of tables needed

2019-07-20 Thread Jackson Rodrigues
Dear all, My name is Jackson and I need a help in applying functions to a list of tables. Could anyone help me to use loop/array on a list of tables ? I need to apply a group of functions (listed below) to a list of tables I am not that good with loops or arrays or multiple functions. So, co

Re: [R] Capturing positive and negative changes using R

2019-07-20 Thread Jim Lemon
Hi Faradj, Rui's advice is correct, here's a way to do it. Note that I have replaced the comma decimal points with full stops for my convenience: fkdf<-read.csv(text="Year,Country,X1,X2 1990,United States,0,0.22 1991,United States,0,0.22 1992,United States,0,0.22 1993,United States,0,0.22 1994,Uni

Re: [R] Capturing positive and negative changes using R

2019-07-20 Thread Rui Barradas
Hello, Please don't post in HTML, the data is unreadable. Two ideas: 1) Why c(FALSE, diff()) if diff returns numeric values? Use c(0, diff) instead, and you won't need the coercion to numeric with the plus sign. 2) There are many ways to group by a variable, in this case 'Country'. See in base

[R] Capturing positive and negative changes using R

2019-07-20 Thread Faradj Koliev
Dear R-users, I have a country-year data for 180 countries from 1970 to 2010. I’m interested in capturing positive and negative changes in some of the variables. Some of these variables are continuous (0,25, 0,33, 1, 1,5 etc) others are ordered (0,1, 2). To do this, I use this code data$X1_c

[R] How to create the/an integer 'seed' for set.seed() from a given .Random.seed?

2019-07-20 Thread Marius Hofert
Hi, 1) Given .Random.seed, how can one compute *the* integer 'seed' such that set.seed(seed) generates .Random.seed? 2) If 1) is not possible, how can one compute *an* integer 'seed' from a given .Random.seed such that different .Random.seed's are guaranteed to give different integers 'seed' (or a

Re: [R] How to create a data set from object/data frame?

2019-07-20 Thread Jim Lemon
Hi Spencer, While Sarah has already given you very good advice, there is a rough method of checking whether one data set can be substituted for another: str(anno) str(Dilution) If you're lucky and the objects are not too complicated, this will give you a start on whether one can be substituted fo