I think this is a simple question but can't figure it out. I'm trying to build a frame and hoping I can add a title to it. For example, I like to create a slider in a frame. But to identify the frame I'd like to add a title to it. I have no reputation so I can't add a picture, but something like the word "title" below:
--- title --------------------------------
| ===[ ]=================== |
-----.-----------------------------------
Or:
How can I do it?
Look at the ttklabelframe function in the tcltk package.
There is a package called rpanel, where somehow the frames are all titled. You might want to look into that one.
Related
I am looking to tidy a data set using R Studio. I was wondering how I can clean this data set step by step.
The data look like the following:
enter image description here
but I want them to look like this:
enter image description here
Any idea what the r code I need to do this?
I think this does what you need.
#Creating the dataframe
country=c("Aghanistan","Aghanistan","Aghanistan","Brazil","Brazil","Brazil","China","China","China")
Indicator=c("ind1","ind2","ind3","ind1","ind2","ind3","ind1","ind2","ind3")
`1999`=c(745,19987071,0.373,NA,NA,NA,NA,NA,NA)
`2000`=c(2666,20595360,1.29,NA,NA,NA,NA,NA,NA)
df<-as.data.frame(cbind(country,Indicator,`1999`,`2000`))
library(tidyr)
df.long<-gather(df,Year,measurement,`1999`:`2000`,factor_key = T)#get the years right
df.final<-spread(df.long,Indicator,measurement)#reformat for final
df.final#scope the result
I am using googleVis and shiny to (automatically) create a Organizational Chart.
Similar to this question:
Google Visualization: Organizational Chart with fields named the same, I want to use formatted values in googleVis to be able to create fields in an organizational chart, which have the same name. I suspect it has something to do with roles but I cannot figure the correct syntax out.
The help page for gvisOrgChart mentiones formatted values but does not say how to set them:
"You can specify a formatted value to show on the chart instead, but the unformatted value is still used as the ID."
## modified example from help page
library(googleVis)
Regions[7,1] = Regions[8,1] # artificially create duplicated name in another parent node
Org <- gvisOrgChart(Regions)
plot(Org)
In the above example the duplicated name (Mexico) is only shown once in the chart. I want both of them to be drawn (One in the Europe and one in the America parent node).
Thank you for your help
cateraner
After talking to one of the developers of the googleVis package I got the solution to the problem now. The formatted value contains extra speak marks, which have to be removed before the text is usable as HTML.
## modified example from help page
library(googleVis)
# add new entry
levels(Regions$Region) = c(levels(Regions$Region), "{v: 'Germany.2', f: 'Germany'}")
Regions[8,1] = "{v: 'Germany.2', f: 'Germany'}"
Org <- gvisOrgChart(Regions)
# remove extra speak marks
Org$html$chart <- gsub("\"\\{v", "\\{v", Org$html$chart)
Org$html$chart <- gsub("\\}\"", "\\}", Org$html$chart)
plot(Org)
In the resulting graph you have two times "Germany", one under node "America" and one under "Europe". The same way you could add HTML formations to your text (color, font, etc.).
Thanks too Markus Gesmann for helping me on that.
I'm not too advanced with R so any help would be appreciated. I am trying to add values to columns in my dataset and my dataset is called 'katie'.
For example, in the column 'word' I'd like to select instances where 'SUBJECTED' is written and then post 'middle' in the column 'pre.environment', on the same line as 'SUBJECTED' is written. Is there something that I am doing wrong? With this code, the initial line definitely works (as I can see how many "SUBJECTED" items are recognized in the column 'word') but nothing happens when I enter the second line of code.
>x=grep("SUBJECTED", katie$word)
>katie[x,]$pre.environment= c('middle')
I hope this example is sufficient. Thanks in advance for your help.
Try the following code, if I understand your question correctly,
katie$pre.environment <- ifelse(grepl("SUBJECTED", katie$word),
yes = "middle",
no = katie$pre.environment)
I'm new here and new to R and I think I have a simple question but don't know how to name it so I can't find any help by searching the web.
I have a data set and want to form a new Data set with several variables from the first one.
The working code looks like this:
em.table2 <- data.frame(em.table$item1,em.table$item2,...[here are some more]...,em.table$item22)
In order to keep it more simple, I want to get rid of the "em.table$"-construction in front of every variable... unfortunately i don't know the function to do so...
I tried it like this, but it didn't work (and is a pretty embarrasing try i guess):
em.table2 <- data.frame(em.table$(item1,item2,item3,item4))
Anyone here to help? Thanks a lot!
Instead of the $ operator, try the following:
em.table2 <- em.table[,c("item1","item2","item3","item4")]
Try with
em.table2 <- with(em.table, data.frame(item1, item2, item3, item4))
But if you just want to subset the data, there are better solutions.
Built a summary table, but the labels of the row groups are not showing up.
args(data)
summary1 <- list("Gender"= list("Female"
=~qwraps2::n_perc0(Sex==0, na_rm=TRUE))
table1 <- summary_table(data, summary1)
My table looks like this: table1:
How do I get the "Gender" group name to show-up in the table?
It looks like you are viewing the table in RStuido via double clicking on the table1 in the "Environment" tab. The display is as expected. The structure of the qwraps2_summary_table object is a character matrix. In or outside of RStudio you can get the same result shown in the question post via View(table1).
To see the well rendered html you'll need to knit a .Rmd to html. Or, in RStuido you can upon a "R Notebook." A screen capture of of a simple example from an R Notebook follows:
This may be related to how you "show" your table (You did not write anything about how you got it). When I use qwraps in rmarkdown in edit mode. When I just select the table (in your case table1) and press ctrl + enter I get the result you're asking for. If I use kable(table1) this removes this labelling.
I think the print() function recognized the qwrap table and prints it with the group names.
Ask a minimally reproducible example if you want more help.