Hi, I am trying to plot several rows out of a list of thousands. I have 40 columns, and about 16,000 rows with the following Df structure. ID X01 X02 X03..X40 AI456 45 64 23... AI943 14 3 45 .. AI278 78 12 68.. BW768 -2 -7 34.. ... My question is, I have a list of 100 IDs generated elsewhere (Df-"Ofinterest"), I would like to plot the 100 IDs from that data frame over the 40 columns (40 points per ID, with each column being 1 x value). But I cant figure out how to retrieve the values from the main Df and plot them. Ive tried looking at order, rank etc, but these seem to apply to numbers, and not text strings. thanks Simon.
Hello, I would like to call C code from R. My C code is divided in two files. In the file "testpermut.c", I have the following lines: #include "adesub.h" In my working folder, I have the files: - adesub.c which contains general functions - adesub.h with the header of functions contained in adesub.c - testpermut.c which call some functions defined in adesub.c When I try to create my dll (Work on Windows XP, R-1.8.1), I obtain error message: $ Rcmd shlib testpermut.c making adesub.d from adesub.c making testpermut.d from testpermut.c gcc -Ic:/Rdev/R-1.8.1/src/include -Wall -O2 -c testpermut.c -o testpermut.o ar cr testpermut.a *.o ranlib testpermut.a gcc --shared -s -o testpermut.dll testpermut.def testpermut.a -Lc:/Rdev/R-1.8 .1/src/gnuwin32 -lg2c -lR testpermut.a(testpermut.o.b)(.text+0x35):testpermut.c: undefined reference to `taballoc' testpermut.a(testpermut.o.b)(.text+0x49):testpermut.c: undefined reference to `taballoc' testpermut.a(testpermut.o.b)(.text+0x62):testpermut.c: undefined reference to `taballoc' testpermut.a(testpermut.o.b)(.text+0x14c):testpermut.c: undefined reference to `freetab' testpermut.a(testpermut.o.b)(.text+0x156):testpermut.c: undefined reference to `freetab' testpermut.a(testpermut.o.b)(.text+0x160):testpermut.c: undefined reference to `freetab' testpermut.a(testpermut.o.b)(.text+0x192):testpermut.c: undefined reference to `taballoc' testpermut.a(testpermut.o.b)(.text+0x22b):testpermut.c: undefined reference to `taballoc' testpermut.a(testpermut.o.b)(.text+0x23f):testpermut.c: undefined reference to `vecalloc' testpermut.a(testpermut.o.b)(.text+0x24b):testpermut.c: undefined reference to `vecalloc' testpermut.a(testpermut.o.b)(.text+0x339):testpermut.c: undefined reference to `freevec' testpermut.a(testpermut.o.b)(.text+0x343):testpermut.c: undefined reference to `freevec' testpermut.a(testpermut.o.b)(.text+0x34d):testpermut.c: undefined reference to `freetab' testpermut.a(testpermut.o.b)(.text+0x412):testpermut.c: undefined reference to `taballoc' make: *** [testpermut.dll] Error 1 $ The functions taballoc, freetab, vecalloc and freevec are defined in adesub files. So it seems that gcc does not make the links between my files. If I include the problematic functions in testpermut.c, gcc works perfectly and my dll is created. Perhaps someone could explain me what is my problem although it is not an R problem but probably a misuse of gcc ?. Thanks in advance. St?phane DRAY -------------------------------------------------------------------------------------------------- D?partement des Sciences Biologiques Universit? de Montr?al, C.P. 6128, succursale centre-ville Montr?al, Qu?bec H3C 3J7, Canada Tel : 514 343 6111 poste 1233 E-mail : stephane.dray at umontreal.ca -------------------------------------------------------------------------------------------------- Web http://www.steph280.freesurf.fr/
On Mon, 2004-02-02 at 14:13, Simon Melov wrote:> Hi, > I am trying to plot several rows out of a list of thousands. I have 40 > columns, and about 16,000 rows with the following Df structure. > > ID X01 X02 X03..X40 > AI456 45 64 23... > AI943 14 3 45 .. > AI278 78 12 68.. > BW768 -2 -7 34.. > ... > > My question is, I have a list of 100 IDs generated elsewhere > (Df-"Ofinterest"), I would like to plot the 100 IDs from that data > frame over the 40 columns (40 points per ID, with each column being 1 x > value). But I cant figure out how to retrieve the values from the main > Df and plot them. Ive tried looking at order, rank etc, but these seem > to apply to numbers, and not text strings. > > thanks > > Simon.I am not entirely sure what type of plot you want, however the following will enable you to subset the main dataframe, based upon matching ID's: # Create an example vector of the ID's you want df.index <- c("AI456", "AI278", "BW768")> df.index[1] "AI456" "AI278" "BW768" # Create a df with the subset of data you have above df <- data.frame(ID = c("AI456", "AI943", "AI278", "BW768"), X01 = c(45, 14, 78, -2), X02 = c(64, 3, 12, -7), X03 = c(23, 45, 68, 34))> dfID X01 X02 X03 1 AI456 45 64 23 2 AI943 14 3 45 3 AI278 78 12 68 4 BW768 -2 -7 34 # Use which() and %in% to get a vector containing the # row indices in df that match the three entries in df.index found <- which(df$ID %in% df.index)> found[1] 1 3 4 # Now subset df to include only those rows that match MySubset <- df[found, ]> MySubsetID X01 X02 X03 1 AI456 45 64 23 3 AI278 78 12 68 4 BW768 -2 -7 34 MySubset now contains only those rows that match based upon your IDs in the "index" vector. If you know how to generate the plot you want from here, have at it. If not, let me know what you wish to do and I can help further. See ?which and ?%in% for more information. Also, see ?subset for additional ways to subset dataframes using more complex logicals. HTH, Marc Schwartz
On Mon, 2 Feb 2004, Stephane DRAY wrote:> Hello, > > I would like to call C code from R. My C code is divided in two files. In > the file "testpermut.c", I have the following lines: > > #include "adesub.h" > > In my working folder, I have the files: > - adesub.c which contains general functions > - adesub.h with the header of functions contained in adesub.c > - testpermut.c which call some functions defined in adesub.c > > When I try to create my dll (Work on Windows XP, R-1.8.1), I obtain error > message: > > $ Rcmd shlib testpermut.cYou only included one of the files. You need Rcmd SHLIB testpermut.c adesub.c I believe. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595