Re: [R] Beginer data.frame

2010-01-12 Thread K. Elo
Hi! Jean-Baptiste Combes wrote: Hello, I use R 2.10, and I am new in R (I used to use SAS and lately Stata), I am using XP. I have a data which has a data.frame format called x.df (read from a csv file). I want to take from this data observations for which the variable Code starts with

Re: [R] recursive function

2010-06-14 Thread K. Elo
Hi! Do you mean something like this (df is your original data frame): --- cut here --- df1-df df1[[1]]-paste(R,df[[1]],sep=_) colnames(df1)-c(SERIES,YEAR,value) df1$value[ df1$YEAR==2009 ]-5 for (i in c(2009:2007)) { df1$value[ df1$YEAR==(i-1) ]-( df1$value[ df1$YEAR==i ]-df$DELTA[ df$year==i ]

Re: [R] Barplots in R

2010-01-15 Thread K. Elo
Hi! Let's suppose the values for the x axis are stored in 'values'. barplot(values, col=c(rep(Red,3),rep(1,length(values)-8),rep(Blue,5))) HTH, Kimmo vikrant kirjoitti: Suppose I need to draw a Grouped bar plot with 100 values on the X axis. Now my question is If I need to highlight suppose

Re: [R] cbind, row names

2010-01-29 Thread K. Elo
Hi! 29.01.2010 12:49, soeren.vo...@eawag.ch wrote: Hello, I read the help as well as the examples, but I can not figure out why the following code does not produce the *given* row names, x and y: x - 1:20 y - 21:40 rbind( x=cbind(N=length(x), M=mean(x), SD=sd(x)),

Re: [R] Deleting colmuns with 0's and also writing multple csv files

2010-02-18 Thread K. Elo
Dear Anna, 19.02.2010 08:17, Anna Carter wrote: (1) If the dataset contains some variables having all the entries = 0 and while analysing I want to delete those pericular columns, how do acheive this. i.e. Let's suppose 'df' is your data frame, then: subset(df, select=which(colSums(df)!=0))

Re: [R] Deleting colmuns with 0's and also writing multple csv files

2010-02-19 Thread K. Elo
Hi! Right, my solution did not take into accound paired negative values summing up to zero. This should work in all cases: df[, which(colSums(df!=0)!=0)] Kind regards, Kimmo __ R-help@r-project.org mailing list

Re: [R] how to make R plot under Linux

2010-02-22 Thread K. Elo
Hi! 22.02.2010 17:45, xin wei wrote: thank you for reply. I just type: hist(x) from SSH terminal, expecting a histogram to pop up like what i got under windows.instead I got the following error msg: Error in X11(d$display, d$width, d$height, d$pointsize, d$gamma, d$colortype, :

Re: [R] how to make R plot under Linux

2010-02-22 Thread K. Elo
Hi! 22.02.2010 19:53, xin wei wrote: hi, Kevin and K.Elo: thank you for the suggestion. Can you be more specific on these? (like how exactly get into x-switch or man ssh). I am totally ignorant about linux and SSH:( Memory limitation forces me to switch from windows to Linux

Re: [R] writing a function

2008-02-08 Thread K. Elo
Hi Mohamed, mohamed nur anisah wrote (8.2.2008): Dear lists, I'm in my process of learning of writing a function. I tried to write a simple functions of a matrix and a vector. Here are the codes: mm-function(m,n){ #matrix function w-matrix(nrow=m, ncol=n) for(i in

Re: [R] data frame question

2008-02-14 Thread K. Elo
Hi, joseph wrote (15.2.2008): Thanks. I have another question: In the following data frame df, I want to replace all values in col1 that are higher than 3 with NA. df= data.frame(col1=c(1:5, NA),col2= c(2,NA,4:7)) My suggestion: x-df$col1; x[ x3 ]-NA; df$col1-x; rm(x) -Kimmo

Re: [R] simple usage of for

2008-02-19 Thread K. Elo
Hi, Hans Ekbrand wrote (19.2.2008): I tried the following small code snippet which I copied from the Introduction to R: for (i in 2:length(meriter)) { table(meriter[[1]], meriter[[i]]) } Try: for (i in 2:length(meriter)) { print(table(meriter[[1]], meriter[[i]])) } Kind regards, Kimmo

Re: [R] plotting every ith data point?

2008-02-20 Thread K. Elo
Hi, this might also work for You: points(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR2[ (row(example.df)%%5)==0 ], type=p, pch=3) points(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR2[ (row(example.df)%%5)==0 ], type=p, pch=3) Kind regads, Kimmo Jessi

Re: [R] plotting every ith data point?

2008-02-20 Thread K. Elo
Hi, sorry, the correct commands should look like this: plot(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR1[ (row(example.df)%%5)==0 ], type=p, ylim=c(0.3,0.9)) points(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR2[ (row(example.df)%%5)==0 ], type=p, pch=3)

Re: [R] Combining series of variables using identifier

2008-02-26 Thread K. Elo
Hi, if the columns always follow the same order (indx,var#, var#_lab ...), then You could use the column numbers and do the following: 1) CN-colnames(df)[#] (#=colnum of 'var#') 2) df$NEW-(here the expression to create the new variable) 3) colnames(df)[ncol(df)]-c(paste(CN,new,sep=_)) This can

[R] SPSS import problem

2008-03-12 Thread K. Elo
Dear all, I have tried to import a SPSS file in R, but always get the following message: --- cut here --- Error in read.spss(spss-data.sav, : error reading system-file header In addition: Warning message: In read.spss(spss-data.sav, : spss-data.sav: Variable Y6B_A indicates variable label

Re: [R] SPSS import problem

2008-03-12 Thread K. Elo
Hi again, many thanks for Your answers. So, if I understood Wei right: Zhao, Wei (Cancer Center) wrote (12.3.2008): I had a similar problem when read one of my spss.sav with long variable label. But when I read another spss.sav with short label the same way, I don't have problem. Seems like

Re: [R] read.dta for files from stata 9.0

2008-03-18 Thread K. Elo
Hi, Albrecht Kauffmann wrote (18.03.2008): Dear R-helpers, if I want to read a .dta-file generated by stata 9.0 with read.dta (foreign), I get the message not a stata version 5-8 .dta-file. I'm using R-2.6.2 and the latest version of the foreign package. Has someone any hint? Seems quite

Re: [R] SPSS import problem

2008-03-21 Thread K. Elo
Hi, the problem were a couple of overlength labels, indeed. After having removed them, I was able to import the data without any problems. Thanks anyway for Your help. Happy Easter, Kimmo __ R-help@r-project.org mailing list

Re: [R] using a variable in a subset of a dataframe

2008-04-01 Thread K. Elo
Henrique Dallazuanna wrote (1.4.2008): You can try this: x - data.frame() for(i in LETTERS[1:5]) x[1:10, i] - rnorm(10) x Or this: --- cut here --- df-data.frame(0) [obsolet, if df already exists] for (i in 1:10) { df-data.frame(cbind(df,0)); names(df) [ncol(df)]-as.character(i) } --- cut

[R] How to print out console output

2008-08-27 Thread K. Elo
Dear R-helpers, I am desperately looking for a solution for how to print out the console output to a standard printer. For example, I would like to print out the summary.lm() output, the output of different ftable-functions etc. I use R on a linux machine. The only ways so far have been to

Re: [R] How to print out console output

2008-08-27 Thread K. Elo
0.3746872961 [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281 0.0414420397 0.2307212995 [13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864 0.6205502201 0.5352788521 [19] 0.4255279053 0.7711444888 On Wed, Aug 27, 2008 at 7:44 AM, K. Elo [EMAIL PROTECTED] wrote: Dear R-helpers, I am

Re: [R] How to print out console output

2008-08-29 Thread K. Elo
Hi, as mentioned in my previous posting, I run R on a linux machine. So a possible function for printing (in linux) could look like this: copy2lpr-function(..., PRINTER=lpr) { LPR-pipe(PRINTER,w) capture.output(..., file=LPR) close(LPR) } This seems to work... An allows the user to choose

[R] Lattice: how to reduce/shrink plot area

2008-09-24 Thread K. Elo
Hi, is there a command or parameter for reducing the plotting area with lattice? What I am looking for is an option similar to 'mai' or 'mar' from the graphs package. Background: I have plotted several charts with horizontal stacked bars and now I would like to add info about percentages of each

Re: [R] MCA in R

2008-06-12 Thread K. Elo
Dear John, thanks for Your quick reply. John Fox wrote: Dear Kimmo, MCA is a rather old name (introduced, I think, in the 1960s by Songuist and Morgan in the OSIRIS package) for a linear model consisting entirely of factors and with only additive effects -- i.e., an ANOVA model will no

Re: [R] NA value

2008-06-27 Thread K. Elo
Hi, cimfasy_rwl[ is.na(cimfasy_rwl) ] -0 Or did I understood Your right? HTH, Kimmo Alfredo Alessandrini wrote: I'm trying to replace NA with 0 value... I've write a loop, but don't work... Where's the problem? cimfasy_rwl 1991 0.92 0.72 0.50 1.29 0.54 1.22

[R] Data labels in barchart (lattice)

2008-04-21 Thread K. Elo
Dear all, I use the barchart-function (lattice) for plotting stacked barcharts. The data is a summary table (data frame) of likert-scale-evaluations (strongly agree, agree...strongly disagree) to different issues constructed as follows (L1=precentage of strongly agree evaluations,

Re: [R] Data labels in barchart (lattice)

2008-04-21 Thread K. Elo
Hi again, Deepayan Sarkar wrote (21.4.2008): Write your own panel function (which may or may not be a simple exercise depending on your level of expertise in R). You could use panel.barchart as a starting point. Basically, you need to insert some calls to panel.text() (or something

[R] Lattice problems / cannot load lattice

2008-05-06 Thread K. Elo
Hi, My problem is simple: since having updated the lattice package, I cannot load lattice anymore. If I type in the command 'library(lattice)' the loading fails with the following message: --- cut here --- Error in library.dynam(lib, package, package.lib) : shared library 'lattice' not

Re: [R] Lattice problems / cannot load lattice

2008-05-06 Thread K. Elo
Hi, thanks for the quick reply :) Prof Brian Ripley kirjoitti viestissään (06.05.2008): Try installing again by install.packages(lattice, .Library) (from an account with suitable privileges). Tried (as root) - not working :( If that still fails, we need to see the output produced during

Re: [R] Lattice problems / cannot load lattice

2008-05-06 Thread K. Elo
Prof Brian Ripley kirjoitti viestissään (06.05.2008): Does starting R --vanilla help? I am wondering if you have another corrupt copy of lattice somewhere. The latter was the problem, many thanks for this! I use Rkward as GUI and obviously some packages have been installed into the user

Re: [R] Pros and Cons of R

2008-05-22 Thread K. Elo
Hi, Monica Pisica wrote: - There is no perfect “beginner” book. How about - Crawley, Michael (2007). The R book, Wiley Sons. - Maindonald, John John Braun (2007): Data Analysis and Graphics Using R (2nd edition), Cambridge University Press. As a political scientist (with programming

Re: [R] How to read the summary

2009-04-28 Thread K. Elo
Hi! mathallan wrote: How can I from the summary function, decide which glm (fit1, fit2 or fit3) fits to data best? I don't know what to look after, so I would please explain the important output. Start with the AIC value (Akaike Information Criterion). The model having the lowest AIC is the

Re: [R] where does the null come from?

2009-05-13 Thread K. Elo
Hi! Wacek Kusnierczyk wrote: m = matrix(1:4, 2) apply(m, 1, cat, '\n') # 1 2 # 3 4 # NULL why the null? Could it be the return value of 'cat'. See ?cat, where: ---snip --- Value None (invisible NULL). ---snip --- Kind regrads, Kimmo

[R] Grouping data

2008-01-16 Thread K. Elo
Hi, I am quite new to R (but like it very much!), so please apologize if this is a too simple question. I have a large data frame consisting of data from a survey. There is, for example, information about age and education (a numeric value from 1-9). Now I would like to extract the total

Re: [R] how to quit this mailing list

2009-03-27 Thread K. Elo
Hi, https://stat.ethz.ch/mailman/listinfo/r-help and there You'll find the section: To unsubscribe from R-help, get a password reminder, or change your subscription options enter your subscription email address: Hope this helps, Kimmo __

Re: [R] A beginner's question

2009-03-27 Thread K. Elo
Hi, minben wrote: I am a new R-language user. I have set up a data frame mydata,one of the colume of which is skill. Now I want to select the observations whose skill value is equal to 1,by what command can I get it? Try this: mydata1-mydatasubset(mydata, skill==1) Maybe You should also read

Re: [R] Deleting rows that contain certain characters...or deleting ANOVA factors

2009-04-22 Thread K. Elo
Hi, Crosby, Jacy R wrote: i.e. I'd like to have aov(Phen1~L1) use only Pat1-Pat4,and Pat 10. Similarly, aov(Phen1~L2) should use Pat1, 6, and 10. Etc. Is this something I can do in the aov function, or do I need to modify my dataset before running aov? In either case, I need

Re: [R] subset

2009-03-05 Thread K. Elo
Hi Yannick, yannick misteli wrote: I have a vector x with certain ID numbers in it and want to create a subset from my dataset Y with this vector i.e extract only the data with the given IDs from vector x. example: x [1] 10066924 10207314 10257322 10334594 10348247 and now I want to

Re: [R] basic boxplot questions

2009-01-16 Thread K. Elo
ivo welch kirjoitti: dear R experts: I am playing with boxplots for the first time. most of it is intuitive, although there was less info on the web than I had hoped. alas, for some odd reason, my R boxplots have some fat black dots, not just the hollow outlier plots. Is there a

Re: [R] basic boxplot questions

2009-01-16 Thread K. Elo
Hi Ivo, ivo welch wrote: alas, for some odd reason, my R boxplots have some fat black dots, not just the hollow outlier plots. Is there a description of when R draws hollow vs. fat dots somewhere? [and what is the parameter to change just the size of these dots?] Have you tried the command

Re: [R] filling blanks with NA

2009-01-21 Thread K. Elo
Hi, kayj wrote: Hi, I do have a data set with some missing values that appear as blanks. I want to fill these blanks with an NA. How can this be done? Thanks for your help Something like this? my.data-data.frame(var=c(1,2,5,,66,4,3,,67,5,3,2,1,4,32,56,23), stringsAsFactors=F)

Re: [R] barplot (stacked)

2010-03-24 Thread K. Elo
Hi Jens! 23.03.2010 17:18, koj wrote: The problem is: I want to group the data. I want to have ten groups. The first two bars should be [1,1] and [2,1] together in one bar and in the second bar of the first obervation should be [1,2] and [2,2] (stacked with beside =TRUE). Therefore the first

Re: [R] barplot (stacked)

2010-03-24 Thread K. Elo
Hi Jens! 24.03.2010 14:48, koj wrote Hi Kimmo, thank you for your answer, but this is not the thing I am searching for. Unfortunately, I have not described the problem very good. But just in this moment I have a good idea: I use add=TRUE and paint two plots. And so I am sure that I can

Re: [R] Counting

2011-03-17 Thread K. Elo
Dear Jim, 17.03.2011 20:54, Jim Silverton wrote: I have a matrix say: 23 1 12 12 00 0 1 0 1 0 2 23 2 I want to count of number of distinct rows and the number of disinct element in the second column and put these counts in a column. SO at the end of the day I should have: c(1,

[R] Adding mean line to a lattice density plot

2012-03-07 Thread K. Elo
Hi! I have used the following command: densityplot(~PV1CIV, groups=SGENDER, data=ISGFINC2, lwd=2, col=1, lty=c(1,2), pch=c(+,o), key=list(text=list(lab=levels(ISGFINC2$SGENDER), col=1), space=bottom, columns=2, border=T, lines=T, lwd=2, lty=c(1,2), col=1), ref=T, plot.points=F) to

Re: [R] Re : Adding mean line to a lattice density plot

2012-03-08 Thread K. Elo
Hi, thank you, Pascal, for your quick reply. Unfortunately your suggestion is not working. Please have a look on the attachment, I have added manually the mean lines I am trying to plot. The problem with 'abilne' seems to be that the argument 'v' is relative to the graph area, not the x-axis

Re: [R] Re : Re : Adding mean line to a lattice density plot

2012-03-08 Thread K. Elo
HI again, thanks for the replies. Unfortunately, due to my deadlines, I had no time to test Petr's suggestion. I will test it later. I had to figure out an alternate solution, so I decided to use normal plotting functions: with(subset(ISGFINC2, as.numeric(SGENDER)==1), plot(density(PV1CIV),

Re: [R] multiple density plot

2012-03-19 Thread K. Elo
Hi, some sample data would be *very* helpful... Kind regards, Kimmo 16.03.2012 15:44, statquant2 wrote: Hello I am looking for a special plot. Let's suppose I have *100 days and *each day I have a (1D) distribution of the same variable. I would

Re: [R] grouping

2012-04-03 Thread K. Elo
Hi! Maybe not the most elegant solution, but works: for(i in seq(1,length(data)-(length(data) %% 3), 3)) { ifelse((length(data)-i)3, { print(sort(data)[ c(i:(i+2)) ]); print(mean(sort(data)[ c(i:(i+2)) ])) }, { print(sort(data)[ c(i:length(data)) ]); print(mean(sort(data)[ c(i:length(data))

Re: [R] test

2011-01-14 Thread K. Elo
Dear Romezo, a solution maybe not that elegant and effective, but seems to work: test_calculate-function() { tarrow-1 TARGET-data.frame(Thesis=0, Day=0,A=0,B=0,C=0) for (i in c(unique(my.data$Thesis))) { for (j in c(unique(my.data$Day[ my.data$Thesis==i ]))) {

Re: [R] Mlogit missing value problem

2011-12-19 Thread K. Elo
Hi, 19.12.2011 11:12, Ville Iiskola wrote: Error in if (abs(x - oldx) ftol) { : missing value where TRUE/FALSE needed The reason for this error is in the row 563. There the choice has value 1 and Ie has missing value. If the choice has value 0 and Ie has missing values, then there is no

Re: [R] Help in a project

2011-06-02 Thread K. Elo
Hello, three commands might do the job (NOTE: df=your data frame, obser=Observation, var1=Variable 1 [TYPE: string], var1flag=Variable 1 flag [TYPE: string]) 1. df$var1flag-NA 2. df$var1flag[ is.na(as.numeric(df$var1)) ]-df$var1[ is.na(as.numeric(df$var1)) ] 3. df$var1-as.numeric(df$var1)

Re: [R] how to add a vertical line for each panel in a lattice dotplot with log scale?

2012-06-07 Thread K. Elo
Hi! I recently posted a similar question (entitled Adding mean line to a lattice density plot). Have not got any usable solution forcing my to fall back to the use of the normal 'plot' function. The problem was the same as yours: using panel.abline simply did not work, the position of the

Re: [R] How to test if there is a subvector in a longer vector

2012-09-28 Thread K. Elo
Hi! 28.09.2012 08:41, Atte Tenkanen wrote: Sorry. I should have mentioned that the order of the components is important. So c(1,4,6) is accepted as a subvector of c(2,1,1,4,6,3), but not of c(2,1,1,6,4,3). How to test this? How about this: --- code --- g1- c(2,1,1,4,6,3) g2-

Re: [R] Simple Question

2012-09-28 Thread K. Elo
Hi! 28.09.2012 09:13, Bhupendrasinh Thakre wrote: Statement I tried : b - unclass(Sys.time()) b = 1348812597 c_b - rnorm(1,2,1) Do you mean this: --- code --- df-data.frame(x=0,y=0) colnames(df) [1] x y colnames(df)[2]-paste(b,unclass(Sys.time()),sep=_) colnames(df) [1] x

[R] Cannot install the 'igraph' package

2012-08-02 Thread K. Elo
Hi! I want to use R for network analysis and have tried to install the 'igraph' package. Unfortunately, the installation is aborted by an error: --snip-- gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/local/include -DUSING_R -I. -Ics -Iglpk -Iglpk/amd -Iglpk/colamd

Re: [R] Cannot install the 'igraph' package

2012-08-02 Thread K. Elo
Hi! On Thu, 2 Aug 2012, Uwe Ligges wrote: R.h should be part if your R installation, given the output above probably in /usr/lib64/R/include ? But there is no such file R.h in my system??? ~$ locate \/R.h ~$ Or with 'find': # find / -name R.h # Any ideas? Kind regards, Kimmo

Re: [R] Cannot install the 'igraph' package

2012-08-03 Thread K. Elo
Hi! On Thu, 2 Aug 2012, Prof Brian Ripley wrote: You may bave a micro-packaged distribution (some form of SuSE as I recall): is there a separate R-devel RPM? (Fedora had one an one time.) Thanks, this made the trick. After having R-base-devel installed I succeeded in intalling the 'igraph'

Re: [R] remove duplicated row according to NA condition

2014-05-28 Thread K. Elo
Hi! How about trying this: data[ data$col1!=data$col2 !is.na(data$col3), ] col1 col2 col3 2a1 ST001 3b2 ST002 HTH, Kimmo 28.05.2014 15:35, jeff6868 wrote: Hi everybody, I have a little problem in my R-code which seems be easy to solve, but I wasn't able to find the

Re: [R] Installation of packages

2011-02-08 Thread K. Elo
Dear Katharina, 08.02.2011 11:21, Katharina Lochner wrote: The following appeared on my console: install.packages(psych) Warnung in install.packages(psych) : 'lib = C:/PROGRA~1/R/R-212~1.1/library ist nicht schreibbar Apparently You do not have permissions to write to the target

Re: [R] (no subject)

2011-02-21 Thread K. Elo
Hi! 21.02.2011 08:50, Schmidt, Lindsey C (MU-Student) wrote: What is plot.new? How can I fix this data or add plot.new so it works? ?plot.new ?plot plot(u[h],v[h],type=l,asp=1) seems to work for me... HTH, Kimmo __ R-help@r-project.org mailing list

Re: [R] Plot

2011-02-21 Thread K. Elo
Hi! 21.02.2011 08:50, Schmidt, Lindsey C (MU-Student) wrote: What is plot.new? How can I fix this data or add plot.new so it works? ?plot.new ?plot plot(u[h],v[h],type=l,asp=1) seems to work for me... HTH, Kimmo __ R-help@r-project.org mailing list

Re: [R] reading as date

2015-06-10 Thread K. Elo
Hi! 10.06.2015, 13:20, khatri wrote: My date column is in following format : %m/%d H:M:S There is not mention of year in the data.So how can I read this using strptime function. I have tried strptime(dates,%m/%d H:M:S) but this is returning NA. Thanks How about: strptime(dates,%m/%d

Re: [R] Choosing columns by number

2015-08-25 Thread K. Elo
Hi! 25.08.2015, 18:17, Sam Albers wrote: Hi all, This is a process question. How do folks efficiently identify column numbers in a dataframe without manually counting them. For example, if I want to choose columns from the iris dataframe I know of two options. I can do this:

Re: [R] JSONlite import problem

2015-10-23 Thread K. Elo
Hi! You can download the example file with this link: https://www.dropbox.com/s/tlf1gkym6d83log/example.json?dl=0 BTW, I have used a JSON validator and the problem seems to related to wrong/missing EOF. --- snip --- Error: Parse error on line 1: ...:"1436705823768"} {"created_at":"Sun J

[R] JSONlite import problem

2015-10-23 Thread K. Elo
Hi! I have collected 500.000+ tweets with a Python script using 'tweepy', which stored the data in JSON format. I would like to use R for data analysis, but have encountered problems when trying to import the data file with 'jsonlite'. Here what I have tried: >

Re: [R] JSONlite import problem

2015-10-25 Thread K. Elo
Hi, thanks to Duncan and Jeroen to quick replies. I was actually my thinking error :) I suppoed 'fromJSON' to cope with a multi-line file or a list, but this seems not to be the case. So I first read the file with 'readLines' into a list and processed all items with 'fromJSON' within a

Re: [R] Scale y-labels based on a value with 'lattice'

2016-05-29 Thread K. Elo
Hi! Many thanks to Duncan and Jim for their quick replies. 27.05.2016, 01:08, Jim Lemon wrote: Hi Kimmo, par(mar=c(5,7,4,2)) dotchart(kedf$x) mtext(kedf$Group.2,side=2,at=1:6,line=0.5, las=2,cex=log(abs(kedf$Freq))+1) Jim This 'dotchart' solution worked fine and I got what I wanted :)

[R] Scale y-labels based on a value with 'lattice'

2016-05-26 Thread K. Elo
Dear R-helpers! I have a data frame storing data for word co-occurrences, average distances and co-occurence frequency: Group.1Group.2 x Freq 1 deutschland achtziger 2.001 2 deutschlandalt 1.254 3 deutschland anfang -2.001 4 deutschlandansehen

Re: [R] TwitteR - Number of tweets from multiple locations

2016-06-01 Thread K. Elo
Hi Juho! 01.06.2016, 14:40, Juho Kiuru wrote: Hi all, I am new to R and TwitteR and would love to get some advice from you. I managed to get list of tweets containing word 'innovation' tweeted in Helsinki with following script: searchTwitter('innovation', n=1,

Re: [R] Y in Kohonen xyf function

2016-06-22 Thread K. Elo
Hi again! 21.06.2016, 21:33, chalabi.el...@yahoo.de wrote: Hi Kimmo, Thanks for your reply. I think now my problem is that I don't understand what does factor(df.classes[training]) do? Sorry, my mistake, should habe been 'df$speed'. Please try the following: --- snip --- set.seed(7)

Re: [R] Y in Kohonen xyf function

2016-06-16 Thread K. Elo
Hi! Some sample data could help us to help you... But have you read '?xyf' in order to ensure that your 'Y' is what 'xyf' expects it to be? What kind of error messages do you get? Regards, Kimmo 16.06.2016, 15:13, ch.elahe via R-help wrote: Is there any answer? Hi all, I have a df and I

Re: [R] Y in Kohonen xyf function

2016-06-17 Thread K. Elo
my data based on speed, to see the coming costumer's protocols fall into which speed group and I think I need to bring this speed column in Y element of xyf On Thursday, June 16, 2016 2:29 PM, K. Elo <mailli...@pp.inet.fi> wrote: Hi! Some sample data could help us to help you... But have

Re: [R] Y in Kohonen xyf function

2016-06-22 Thread K. Elo
Hi! 22.06.2016, 22:00, chalabi.el...@yahoo.de wrote: Dear Kimmo, I already used df$speed[training] in df.xyf but I get this error: Error in xyf(Xtraining,factor(df$speed[training]),grid=somgrid(5, : NA/NaN/Inf in foreign function call (arg 1) Please check for zeros (0) and NAs in

Re: [R] Hierarchical Clustering in R

2016-08-24 Thread K. Elo
Hi, what is the exact problem? I tried you code and it works fine... Best, Kimmo 24.08.2016, 10:07, Serpil ŞEN wrote: Dear Authorized Sir / Madam, I need your help on clustering with R. I have symmetric distance matrix which i created usign ClustalOmega program. and used this R codes for

Re: [R] JSON to Dataframe

2016-10-18 Thread K. Elo
Hi! 18.10.2016, 14:38, Abhinaba Roy wrote: Hi R helpers, I have json inputs from an app which I want to convert to dataframes. Below are the two inputs. Can someone help me in converting these to dataframes [...] IMHO, the best way is to use the package 'jsonlite', see: *

[R] Maybe OT: Forking in R scripts?

2016-10-13 Thread K. Elo
Dear all, I am currently working a research project on social media interaction. As a part of this project, mostly for teaching purposes, I should develop a R-based approach for real-time visualisation of streamed data (from Twitter). My idea is simple (and working :) ): A Python-script

Re: [R] R studio Problem

2016-12-14 Thread K. Elo
Hi! Maybe this helps: http://r.789695.n4.nabble.com/Error-in-normalizePath-path-with-McAfee-td2532324.html Best, Kimmo 15.12.2016, 08:18, Amelia Marsh via R-help wrote: Hi I had installed R studio Desktop 1.0.44. However whenever I wanted to write any command, before I could complete, I

Re: [R] help matching rows of a data frame

2017-09-18 Thread K. Elo
Hi! 2017-09-18 07:13 -0500, Therneau, Terry M., Ph.D. wrote: > This question likely has a 1 line answer, I'm just not seeing > it.  (2, 3, or 10 lines is  > fine too.) > > For a vector I can do group  <- match(x, unqiue(x)) to get a vector > that labels each  > element of x. Actually, you get a

Re: [R] help with json data from the web into data frame in R

2018-05-12 Thread K. Elo
Hi! Seems to be an encoding problem. This worked for me (have not full- checked the output, though): fromJSON(encodeString(zWebObj)) HTH, Kimmo 2018-05-08 12:49 -0700, David Winsemius wrote: > > > > On May 8, 2018, at 10:08 AM, Evans, Richard K. (GRC-H000) > k.ev...@nasa.gov> wrote: > > > >

Re: [R] Split a data.frame

2018-05-19 Thread K. Elo
Hi! How about this: --- snip -- for (i in 1:(length(split_str)-1)) { assign(paste("DF",i,sep=""),DF[ c((which(DF$name==split_str[i])+1):(which(DF$name==split_str[i+1])-1)), ]) } --- snip --- 'assign' creates for each subset a new data.frame DFn, where n ist a count (1,2,...). But note:

Re: [R] Saving objects in RData file in different name

2018-07-28 Thread K. Elo
Hi! Maybe not the most elegant solution, but a workaround is to have a function: > save2<-function(y, ...) { save(y,...)} > save2(x1,x2,file="test.RData") The point is to include the variables to be "renamed" as parameters (in my example: y). The function will use the parameter variable names

Re: [R] how to write a loop to repetitive jobs

2018-04-17 Thread K. Elo
Hi! An alternative with 'assign': for ( i in 71:75) {   setwd(paste("C:/Awork/geneAssociation/removed8samples/neuhausen", i, sep=""))   temp.df<-read.csv("seg.pr3.csv", head=T)   temp.df$id<-paste0("sn",i,sep="")   assign(paste0("seg",i,sep=""),temp.df) } rm(temp.df,i)    # Clean up HTH, Kimmo

Re: [R] Hacked

2018-04-17 Thread K. Elo
Hi! Not just an gmail issue. After my last reply I have gotten tons of spams from "Samantha Smith". Keep hitting my "rank as spam"-button in the hope that my MUA could learn :) Best, Kimmo ti, 2018-04-17 kello 19:34 +, Ding, Yuan Chun kirjoitti: > No, I do not use gmail, still got dirty

Re: [R] Importing JSON Files

2018-11-05 Thread K. Elo
Hi! Have you tried to use 'fromJSON' with the parameter 'simplifyDataFrame' set to TRUE? See: https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart.html -> Section "Data Frames" explains how this affects the data frame structure. IMHO this should solve your problem...

Re: [R] data frame transformation

2019-01-06 Thread K. Elo
Hi! Maybe this would do the trick: --- snip --- library(reshape2) # Use 'reshape2' library(dplyr)# Use 'dplyr' datatransfer<-data %>% mutate(letter2=letter) %>% dcast(id+letter~letter2, value.var="weight") --- snip --- Or did I misunderstood something? Best, Kimmo 2019-01-06, 13:16

Re: [R] Mailinglist

2019-01-06 Thread K. Elo
Hi! Not having a data chunk prevents me from testing abit, but maybe you should take a look on: ?table ?xtabs to start with. But as already suggested by other users, a small data set would be of great help :) HTH, Kimmo su, 2019-01-06 kello 13:49 -0500, Rachel Thompson kirjoitti: > Hi Rich,

Re: [R] Printing vectrix

2019-03-25 Thread K. Elo
Hi! 2019-03-25 kello 09:30 +0800, Steven Yen wrote: > The second command is ugly. How can I print the 25 numbers into 2 > rows > of ten plus a helf row of 5? Thanks. Something like this? x<-1:25; for (i in seq(1,length(x),10)) print(x[i:ifelse((i+9)>length(x),length(x),i+9)]) HTH, Kimmo

Re: [R] color question

2019-02-27 Thread K. Elo
Hi! 2019-02-27 22:51 -0500, Aimin Yan wrote: > I have a question about assigning color based on the value of a > matrix > > The following is my matrix. > > d > lateRT earlyRT NAD ciLAD > lateRT 1.0 0.00 0.006224017 0.001260241 > earlyRT

Re: [R] Required help

2019-05-06 Thread K. Elo
Hi Rajesh, 2019-05-05 10:23 +0530, Rajesh Ahir_GJ wrote: > Hello R users, > > I am getting an error while running following code. > > library(ggplot2) > ggplot(hourly_data1,aes(hour, power))+ > geom_boxplot(aes(fill=monthname),outlier.shape=NA) + > facet_wrap(~monthname) >

Re: [R] what would break a citation network? [Error in as.igraph.vs(graph, vids) : Invalid vertex names]

2019-05-04 Thread K. Elo
Hi Drake, 2019-05-04, 17:34 -0700, Drake Gossi wrote: > Hello everyone, > > I'm trying to learn how to put together a citation network, and, in > doing so, I'm playing around with a data set of my own making. I'm > going back and forth between two .csv files. One has two columns and > is simply

Re: [R] How to extract or sort values from one column

2020-01-31 Thread K. Elo
nha kirjoitti: > Thanks for providing the code but I also needed the output sheet in > .csv format with all the four columns corresponding to the value > (Chrom, > Start_pos, End_pos & Value ranging from what I specified earlier). > > Puja > > On Fri, Jan 31, 2020 at 10:23

Re: [R] How to extract or sort values from one column

2020-01-31 Thread K. Elo
Hi! Let's assume your data is stored in a data frame called 'df'. So this code should do the job: df$Value[ (df$Value>=0.2 & df$Values<=0.4) | df$Value>=0.7 ] Best, Kimmo pe, 2020-01-31 kello 09:21 -0500, pooja sinha kirjoitti: > Hi All, > > I have a .csv file with four columns (Chrom,

Re: [R] How to extract or sort values from one column

2020-01-31 Thread K. Elo
Hi! Oh, sorry, one "s" too much in my code. Here the correct one: df$Value[ (df$Value>=0.2 & df$Value<=0.4) | df$Value>=0.7 ] Best, Kimmo pe, 2020-01-31 kello 17:12 +0200, K. Elo kirjoitti: > Hi! > > Let's assume your data is stored in a data frame calle

Re: [R] Strange behaviour of R?

2020-01-17 Thread K. Elo
Hi, cannot reproduce, either, on my Linuxmint 19.3 + R 3.6.2. Here the outputs: --- snip --- > test(mean, 1:10) [1] 5.5 > test(NULL, 1:10) NULL Error in FUN(args) : could not find function "FUN" > test(mean, list(x=1:10, na.rm=TRUE)) [1] NA Warning message: In mean.default(args) : argument is

Re: [R] TWITTER API environment variables

2020-04-07 Thread K. Elo
Hi! Have you already read this: https://cran.r-project.org/web/packages/rtweet/vignettes/auth.html I think they explain rather well how to use Twitter tokens with rtweet... HTH, Kimmo ke, 2020-04-08 kello 17:19 +1200, Patrick Connolly kirjoitti: > I'm using the rtweet package which makes use

Re: [R] TWITTER API environment variables

2020-04-08 Thread K. Elo
llo Kimmo, > > Yes. I did that and it worked fine -- as far as it goes. But it > didn't cover what to do when using the same twitter account on a > computer with a different user name -- which is what my question was > about. > > > On Wed, 08-Apr-2020 at 08:55AM +0300

Re: [R] How to combine two rows in a data table into a third new row, such that the values in the row are added together in the new row?

2020-05-06 Thread K. Elo
Hi! With 'dplyr': dt_count %>% mutate(STATUS=ifelse(STATUS %in% c("Resolved","Closed"),"Resolved/Closed",STATUS)) %>% group_by(STATUS) %>% summarise(n=sum(N)) Output: 1 Assigned 135 2 Cancelled 20 3 In Progress56 4 Pending75 5 Resolved/Closed 1180 HTH,